Skip to content

Commit 923205d

Browse files
committed
Add SMS parameters to add() and update()
1 parent f4f79ed commit 923205d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

lib/createsend/subscriber.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get(self, list_id=None, email_address=None, include_tracking_preference=Fals
2222
(list_id or self.list_id), params=params)
2323
return json_to_py(response)
2424

25-
def add(self, list_id, email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False):
25+
def add(self, list_id, email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False, mobile_number=False, consent_to_track_sms="Unchanged"):
2626
"""Adds a subscriber to a subscriber list."""
2727
validate_consent_to_track(consent_to_track)
2828
body = {
@@ -32,11 +32,16 @@ def add(self, list_id, email_address, name, custom_fields, resubscribe, consent_
3232
"Resubscribe": resubscribe,
3333
"ConsentToTrack": consent_to_track,
3434
"RestartSubscriptionBasedAutoresponders": restart_subscription_based_autoresponders}
35+
36+
if mobile_number:
37+
body["MobileNumber"] = mobile_number
38+
body["ConsentToSendSms"] = consent_to_track_sms
39+
3540
response = self._post("/subscribers/%s.json" %
3641
list_id, json.dumps(body))
3742
return json_to_py(response)
3843

39-
def update(self, new_email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False):
44+
def update(self, new_email_address, name, custom_fields, resubscribe, consent_to_track, restart_subscription_based_autoresponders=False, mobile_number=False, consent_to_track_sms="Unchanged"):
4045
"""Updates any aspect of a subscriber, including email address, name, and
4146
custom field data if supplied."""
4247
validate_consent_to_track(consent_to_track)
@@ -48,6 +53,11 @@ def update(self, new_email_address, name, custom_fields, resubscribe, consent_to
4853
"Resubscribe": resubscribe,
4954
"ConsentToTrack": consent_to_track,
5055
"RestartSubscriptionBasedAutoresponders": restart_subscription_based_autoresponders}
56+
57+
if mobile_number:
58+
body["MobileNumber"] = mobile_number
59+
body["ConsentToSendSms"] = consent_to_track_sms
60+
5161
response = self._put("/subscribers/%s.json" % self.list_id,
5262
body=json.dumps(body), params=params)
5363
# Update self.email_address, so this object can continue to be used
@@ -93,4 +103,4 @@ def delete(self):
93103
"""Moves this subscriber to the deleted state in the associated list."""
94104
params = {"email": self.email_address}
95105
response = self._delete("/subscribers/%s.json" %
96-
self.list_id, params=params)
106+
self.list_id, params=params)

0 commit comments

Comments
 (0)