Skip to content

Commit

Permalink
Update examples in subscribers.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisT-CM committed Jan 23, 2025
1 parent 4d1f5e8 commit 6ed35e5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
20 changes: 20 additions & 0 deletions samples/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@
listId = 'YOUR_LIST_ID'
emailAddress = 'YOUR_SUBSCRIBER_EMAIL_ADDRESS'

subscriberName = "YOUR_SUBSCRIBER_NAME"
subscriberCustomFields = []
subscriberResubscribed = False
subscriberConsentToTrack = 'Unchanged'
subscriberMobileNumber = "+61491570006" # This is a reserved mobile number by the Australian Communications and Media Authority
subscriberConsentToSendSms = "Yes"

subscriber = Subscriber(auth, listId, emailAddress)

# Get the details for a subscriber
subscriberDetail = subscriber.get()
for property, value in vars(subscriberDetail).items():
print(property, ":", value)

# Adding a subscriber
#This implemntation defaults the value of 'restart_subscription_based_autoresponders' to false
subscriber.add(listId, emailAddress, subscriberName, subscriberCustomFields, subscriberResubscribed, subscriberConsentToTrack)

# Adding a subscriber with a mobile number
#This implemntation defaults the value of 'restart_subscription_based_autoresponders' to false
#This also sets the default value of 'consent_to_track_sms' to 'unchanged', meaning new users will not receive SMS communications by default."
subscriber.add(listId, emailAddress, subscriberName, subscriberCustomFields, subscriberConsentToTrack, mobile_Number=subscriberMobileNumber)

#Alternative to set SMS tracking permissions
# This implemntation defaults the value of 'restart_subscription_based_autoresponders' to false
subscriber.add(listId, emailAddress, subscriberName, subscriberCustomFields, subscriberConsentToTrack, mobile_Number=subscriberMobileNumber, consent_to_track_sms=subscriberConsentToSendSms)
39 changes: 39 additions & 0 deletions samples/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import sys
import os

# Add the lib folder to sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib')))

from createsend import *

key = 'MYSLlg+WX4DJqDPS6MwYqADJPsyg/EYGnhoBZ8SI4jrBB/3Ixp2WyQnkU507919NyVCszZnBygWIk1wlpVSopm9ePqtmAdzjOnr9EDvbwm+JZRgEybIZ8rrU34P6aH+3wjYVGD0mPv1/j3HAYrnvgg=='

cs = CreateSend({'api_key': key})
clients = cs.clients()

for cl in clients:
print("Client: %s" % cl.ClientID + " " + cl.Name)
smsClient = Client({'api_key': key}, cl.ClientID)

for list in smsClient.lists():
if(list.Name == "Alexis' Experimental List"):
print(list.Name)
testList = List({'api_key': key}, list.ListID)
break

for subs in testList.active().Results:
print(subs.Name)

testSubscriber = Subscriber({'api_key': key}, None, "[email protected]")
testSubscriber.add(testList.list_id, "[email protected]", "Morning8", [], True, 'Unchanged', mobile_number="+61491570123", consent_to_track_sms="Yes" )
# # testSubscriber.add(testList.list_id, "[email protected]", "Joe Joe", [], "yes", "yes")1
# # .add(

# testSubscriber = Subscriber.({'api_key': key}, testList.list_id, "[email protected]")
# testSubscriber.update("[email protected]", "UpdateTest", [], True, "Unchanged", False, "+6140899111")

subscriber = Subscriber({'api_key': key}, testList.list_id, "[email protected]")

subscriberDetail = subscriber.get()
for property, value in vars(subscriberDetail).items():
print(property, ":", value)

0 comments on commit 6ed35e5

Please sign in to comment.