Skip to content

Commit 94f08b2

Browse files
committed
Add SMS Fields to subscriber.py
1 parent 39fcf75 commit 94f08b2

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/createsend/subscriber.py

Lines changed: 14 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,12 @@ 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+
61+
5162
response = self._put("/subscribers/%s.json" % self.list_id,
5263
body=json.dumps(body), params=params)
5364
# Update self.email_address, so this object can continue to be used
@@ -93,4 +104,4 @@ def delete(self):
93104
"""Moves this subscriber to the deleted state in the associated list."""
94105
params = {"email": self.email_address}
95106
response = self._delete("/subscribers/%s.json" %
96-
self.list_id, params=params)
107+
self.list_id, params=params)

0 commit comments

Comments
 (0)