Skip to content

Commit 4aefc67

Browse files
author
Michael Gubarev
committed
Added methods for working with SMS service
1 parent 767030a commit 4aefc67

File tree

2 files changed

+429
-1
lines changed

2 files changed

+429
-1
lines changed

pysendpulse/examples/sendpulse-rest-api-example.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,106 @@
109109
]
110110
}
111111
SPApiProxy.smtp_send_mail(email)
112+
113+
# **************** SMS ***************
114+
115+
# Add phones to address book
116+
phones_for_add = [
117+
'11111111111',
118+
'22222222222'
119+
]
120+
SPApiProxy.sms_add_phones(ADDRESSBOOK_ID, phones_for_add);
121+
122+
# Add phones to address book
123+
phones_for_add = {
124+
"11111111111":
125+
[
126+
[
127+
{"name" : "test1", "type" : "date", "value" : "2018-10-10 23:00:00"},
128+
{"name" : "test2", "type" : "string", "value" : "asdasd"},
129+
{"name" : "test3", "type" : "number", "value" : "123"}
130+
]
131+
],
132+
"22222222222":
133+
[
134+
[
135+
{"name" : "test1", "type" : "date", "value" : "2018-10-10 23:00:00"},
136+
{"name" : "test2", "type" : "string", "value" : "czxczx"},
137+
{"name" : "test3", "type" : "number", "value" : "456"}
138+
]
139+
]
140+
}
141+
142+
SPApiProxy.sms_add_phones_with_variables(ADDRESSBOOK_ID, phones_for_add);
143+
144+
# Update phones variables from the address book
145+
phones_for_update = [
146+
'11111111111'
147+
]
148+
variables = [
149+
{
150+
"name":"name","type":"string", "value":"Michael"
151+
}
152+
]
153+
SPApiProxy.sms_update_phones_variables(ADDRESSBOOK_ID, phones_for_update, variables);
154+
155+
# Get information about phone from the address book
156+
SPApiProxy.sms_get_phone_info(ADDRESSBOOK_ID, '1111111111')
157+
158+
# Remove phones to address book
159+
phones_for_remove = [
160+
'11111111111',
161+
'22222222222'
162+
]
163+
SPApiProxy.sms_delete_phones(ADDRESSBOOK_ID, phones_for_remove);
164+
165+
# Get phones from the blacklist
166+
SPApiProxy.sms_get_blacklist()
167+
168+
# Add phones to blacklist
169+
phones_for_add_to_blacklist = [
170+
'111222227',
171+
'222333337'
172+
]
173+
SPApiProxy.sms_add_phones_to_blacklist(phones_for_add_to_blacklist, 'test');
174+
175+
# Remove phones from blacklist
176+
phones_for_remove = [
177+
'11111111111',
178+
'22222222222'
179+
]
180+
SPApiProxy.sms_delete_phones_from_blacklist(phones_for_remove);
181+
182+
# Get info by phones from the blacklist
183+
phones = [
184+
'11111111111',
185+
'22222222222'
186+
]
187+
SPApiProxy.sms_get_phones_info_from_blacklist(phones);
188+
189+
# Create new sms campaign
190+
SPApiProxy.sms_add_campaign(SENDER_NAME, ADDRESSBOOK_ID, 'test');
191+
192+
# Send sms by some phones
193+
phones_for_send = [
194+
'11111111111'
195+
]
196+
SPApiProxy.sms_send(SENDER_NAME, phones_for_send, 'test')
197+
198+
# Get list of sms campaigns
199+
date_from = '2018-04-10 23:00:00';
200+
date_to = '2018-05-10 23:00:00';
201+
SPApiProxy.sms_get_list_campaigns(date_from, date_to);
202+
203+
# Get information about sms campaign
204+
SPApiProxy.sms_get_campaign_info(CAMPAIGN_ID);
205+
206+
# Cancel sms campaign
207+
SPApiProxy.sms_cancel_campaign(CAMPAIGN_ID);
208+
209+
# Get cost sms campaign
210+
SPApiProxy.sms_get_campaign_cost('sender', 'test', ADDRESSBOOK_ID);
211+
#SPApiProxy.sms_get_campaign_cost('sender', 'test', None, ['111111111'])
212+
213+
# Remove sms campaign
214+
SPApiProxy.sms_delete_campaign(CAMPAIGN_ID);

0 commit comments

Comments
 (0)