Skip to content

Commit 12ec70f

Browse files
committed
Update examples in subscribers.py file
1 parent 94f08b2 commit 12ec70f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

samples/subscribers.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,29 @@
66
listId = 'YOUR_LIST_ID'
77
emailAddress = 'YOUR_SUBSCRIBER_EMAIL_ADDRESS'
88

9+
subscriberName = "YOUR_SUBSCRIBER_NAME"
10+
subscriberCustomFields = []
11+
subscriberResubscribed = False
12+
subscriberConsentToTrack = 'Unchanged'
13+
subscriberMobileNumber = "+61491570006" # This is a reserved mobile number by the Australian Communications and Media Authority
14+
subscriberConsentToSendSms = "Yes"
15+
916
subscriber = Subscriber(auth, listId, emailAddress)
1017

1118
# Get the details for a subscriber
1219
subscriberDetail = subscriber.get()
1320
for property, value in vars(subscriberDetail).items():
1421
print(property, ":", value)
22+
23+
# Adding a subscriber
24+
#This implemntation defaults the value of 'restart_subscription_based_autoresponders' to false
25+
subscriber.add(listId, emailAddress, subscriberName, subscriberCustomFields, subscriberResubscribed, subscriberConsentToTrack)
26+
27+
# Adding a subscriber with a mobile number
28+
#This implemntation defaults the value of 'restart_subscription_based_autoresponders' to false
29+
#This also sets the default value of 'consent_to_track_sms' to 'unchanged', meaning new users will not receive SMS communications by default."
30+
subscriber.add(listId, emailAddress, subscriberName, subscriberCustomFields, subscriberConsentToTrack, mobile_Number=subscriberMobileNumber)
31+
32+
#Alternative to set SMS tracking permissions
33+
# This implemntation defaults the value of 'restart_subscription_based_autoresponders' to false
34+
subscriber.add(listId, emailAddress, subscriberName, subscriberCustomFields, subscriberConsentToTrack, mobile_Number=subscriberMobileNumber, consent_to_track_sms=subscriberConsentToSendSms)

samples/test.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
import os
3+
4+
# Add the lib folder to sys.path
5+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib')))
6+
7+
from createsend import *
8+
9+
key = 'MYSLlg+WX4DJqDPS6MwYqADJPsyg/EYGnhoBZ8SI4jrBB/3Ixp2WyQnkU507919NyVCszZnBygWIk1wlpVSopm9ePqtmAdzjOnr9EDvbwm+JZRgEybIZ8rrU34P6aH+3wjYVGD0mPv1/j3HAYrnvgg=='
10+
11+
cs = CreateSend({'api_key': key})
12+
clients = cs.clients()
13+
14+
for cl in clients:
15+
print("Client: %s" % cl.ClientID + " " + cl.Name)
16+
smsClient = Client({'api_key': key}, cl.ClientID)
17+
18+
for list in smsClient.lists():
19+
if(list.Name == "Alexis' Experimental List"):
20+
print(list.Name)
21+
testList = List({'api_key': key}, list.ListID)
22+
break
23+
24+
for subs in testList.active().Results:
25+
print(subs.Name)
26+
27+
testSubscriber = Subscriber({'api_key': key}, None, "[email protected]")
28+
testSubscriber.add(testList.list_id, "[email protected]", "Morning8", [], True, 'Unchanged', mobile_number="+61491570123", consent_to_track_sms="Yes" )
29+
# # testSubscriber.add(testList.list_id, "[email protected]", "Joe Joe", [], "yes", "yes")1
30+
# # .add(
31+
32+
# testSubscriber = Subscriber.({'api_key': key}, testList.list_id, "[email protected]")
33+
# testSubscriber.update("[email protected]", "UpdateTest", [], True, "Unchanged", False, "+6140899111")
34+
35+
subscriber = Subscriber({'api_key': key}, testList.list_id, "[email protected]")
36+
37+
subscriberDetail = subscriber.get()
38+
for property, value in vars(subscriberDetail).items():
39+
print(property, ":", value)

0 commit comments

Comments
 (0)