Skip to content

Commit f2ecf37

Browse files
committed
EL-360 -- Update python wrapper for subscriber ListJoinedDate changes
1 parent 16ae7e2 commit f2ecf37

17 files changed

Lines changed: 134 additions & 35 deletions

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## v7.0.0 - 19 Nov, 2021
44
* Upgrades to Createsend API v3.3 which includes new breaking changes
55
* Breaking: 'client.campaigns' now returned an object to support pagination (use .Results to get the array of campaigns)
6+
* Breaking: various subscribers related endpoints now returned listJoinedDate along with stateChangedDate (previously known as Date)
67
* Added 'Tags' as another field that is returned in 'client.scheduled', 'client.drafts' and client.campaigns'
78
* Added 'Name' as another field that is returned in 'campaign.summary'
89
* Add new support for 'client.tags' endpoint (ie: getting list of tags for the client)

samples/lists.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from createsend import *
2+
3+
auth = {
4+
'access_token': 'YOUR_ACCESS_TOKEN',
5+
'refresh_token': 'YOUR_REFRESH_TOKEN' }
6+
listId = 'YOUR_LIST_ID'
7+
8+
list = List(auth, listId)
9+
10+
# Get list of active subscribers in a list
11+
print("List of active subscribers:")
12+
for cm in list.active().Results:
13+
print(" - %s" % cm.EmailAddress)
14+
15+
# Get list of bounced subscribers in a list
16+
print("List of bounced subscribers:")
17+
for cm in list.bounced().Results:
18+
print(" - %s" % cm.EmailAddress)
19+
20+
# Get list of unconfirmed subscribers in a list
21+
print("List of unconfirmed subscribers:")
22+
for cm in list.unconfirmed().Results:
23+
print(" - %s" % cm.EmailAddress)
24+
25+
# Get list of unsubscribed subscribers in a list
26+
print("List of unsubscribed subscribers:")
27+
for cm in list.unsubscribed().Results:
28+
print(" - %s" % cm.EmailAddress)
29+
30+
# Get list of deleted subscribers in a list
31+
print("List of deleted subscribers:")
32+
for cm in list.deleted().Results:
33+
print(" - %s" % cm.EmailAddress)

samples/segments.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from createsend import *
2+
3+
auth = {
4+
'access_token': 'YOUR_ACCESS_TOKEN',
5+
'refresh_token': 'YOUR_REFRESH_TOKEN' }
6+
segmentId = 'YOUR_SEGMENT_ID'
7+
8+
segment = Segment(auth, segmentId)
9+
10+
# Get list of active subscribers in a segment
11+
print("List of active subscribers:")
12+
for cm in segment.subscribers().Results:
13+
print(" - %s" % cm.EmailAddress)

samples/subscribers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from createsend import *
2+
3+
auth = {
4+
'access_token': 'YOUR_ACCESS_TOKEN',
5+
'refresh_token': 'YOUR_REFRESH_TOKEN' }
6+
listId = 'YOUR_LIST_ID'
7+
emailAddress = 'YOUR_SUBSCRIBER_EMAIL_ADDRESS'
8+
9+
subscriber = Subscriber(auth, listId, emailAddress)
10+
11+
# Get the details for a subscriber
12+
subscriberDetail = subscriber.get()
13+
for property, value in vars(subscriberDetail).items():
14+
print(property, ":", value)

test/fixtures/active_subscribers.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{
44
"EmailAddress": "subs+7t8787Y@example.com",
55
"Name": "Person One",
6-
"Date": "2010-10-25 10:28:00",
6+
"StateChangedDate": "2010-10-25 10:28:00",
7+
"ListJoinedDate": "2010-10-24 10:28:00",
78
"State": "Active",
89
"CustomFields": [
910
{
@@ -32,7 +33,8 @@
3233
{
3334
"EmailAddress": "subs+7878787y8ggg@example.com",
3435
"Name": "Person Two",
35-
"Date": "2010-10-25 12:17:00",
36+
"StateChangedDate": "2010-10-25 12:17:00",
37+
"ListJoinedDate": "2010-10-25 12:17:00",
3638
"State": "Active",
3739
"CustomFields": [
3840
{
@@ -45,7 +47,8 @@
4547
{
4648
"EmailAddress": "subs+7890909i0ggg@example.com",
4749
"Name": "Person Three",
48-
"Date": "2010-10-25 12:52:00",
50+
"StateChangedDate": "2010-10-25 12:52:00",
51+
"ListJoinedDate": "2010-10-25 12:52:00",
4952
"State": "Active",
5053
"CustomFields": [
5154
{
@@ -58,15 +61,17 @@
5861
{
5962
"EmailAddress": "subs@example.com",
6063
"Name": "Person Four",
61-
"Date": "2010-10-27 13:13:00",
64+
"StateChangedDate": "2010-10-27 13:13:00",
65+
"ListJoinedDate": "2010-10-27 13:13:00",
6266
"State": "Active",
6367
"CustomFields": [],
6468
"ReadsEmailWith": ""
6569
},
6670
{
6771
"EmailAddress": "joey@example.com",
6872
"Name": "Person Five",
69-
"Date": "2010-10-27 13:13:00",
73+
"StateChangedDate": "2010-10-27 13:13:00",
74+
"ListJoinedDate": "2010-10-27 13:13:00",
7075
"State": "Active",
7176
"CustomFields": [],
7277
"ReadsEmailWith": "Gmail"

test/fixtures/active_subscribers_with_tracking_preference.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{
44
"EmailAddress": "subs+7t8787Y@example.com",
55
"Name": "Person One",
6-
"Date": "2010-10-25 10:28:00",
6+
"StateChangedDate": "2010-10-25 10:28:00",
7+
"ListJoinedDate": "2010-10-24 10:28:00",
78
"State": "Active",
89
"CustomFields": [
910
{
@@ -33,7 +34,8 @@
3334
{
3435
"EmailAddress": "subs+7878787y8ggg@example.com",
3536
"Name": "Person Two",
36-
"Date": "2010-10-25 12:17:00",
37+
"StateChangedDate": "2010-10-25 12:17:00",
38+
"ListJoinedDate": "2010-10-25 12:17:00",
3739
"State": "Active",
3840
"CustomFields": [
3941
{
@@ -47,7 +49,8 @@
4749
{
4850
"EmailAddress": "subs+7890909i0ggg@example.com",
4951
"Name": "Person Three",
50-
"Date": "2010-10-25 12:52:00",
52+
"StateChangedDate": "2010-10-25 12:52:00",
53+
"ListJoinedDate": "2010-10-25 12:52:00",
5154
"State": "Active",
5255
"CustomFields": [
5356
{
@@ -61,7 +64,8 @@
6164
{
6265
"EmailAddress": "subs@example.com",
6366
"Name": "Person Four",
64-
"Date": "2010-10-27 13:13:00",
67+
"StateChangedDate": "2010-10-27 13:13:00",
68+
"ListJoinedDate": "2010-10-27 13:13:00",
6569
"State": "Active",
6670
"CustomFields": [],
6771
"ReadsEmailWith": "",
@@ -70,7 +74,8 @@
7074
{
7175
"EmailAddress": "joey@example.com",
7276
"Name": "Person Five",
73-
"Date": "2010-10-27 13:13:00",
77+
"StateChangedDate": "2010-10-27 13:13:00",
78+
"ListJoinedDate": "2010-10-27 13:13:00",
7479
"State": "Active",
7580
"CustomFields": [],
7681
"ReadsEmailWith": "Gmail",
@@ -84,4 +89,4 @@
8489
"RecordsOnThisPage": 5,
8590
"TotalNumberOfRecords": 5,
8691
"NumberOfPages": 1
87-
}
92+
}

test/fixtures/bounced_subscribers.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{
44
"EmailAddress": "bouncedsubscriber@example.com",
55
"Name": "Bounced One",
6-
"Date": "2010-10-25 13:11:00",
6+
"StateChangedDate": "2010-10-25 13:11:00",
7+
"ListJoinedDate": "2010-10-25 13:11:00",
78
"State": "Bounced",
89
"CustomFields": [],
910
"ReadsEmailWith": ""

test/fixtures/deleted_subscribers.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
{
44
"EmailAddress": "subscriber@example.com",
55
"Name": "Deleted One",
6-
"Date": "2010-10-25 13:11:00",
6+
"StateChangedDate": "2010-10-25 13:11:00",
7+
"ListJoinedDate": "2010-10-25 13:11:00",
78
"State": "Deleted",
89
"CustomFields": [],
910
"ReadsEmailWith": "Gmail"
1011
},
1112
{
1213
"EmailAddress": "subscriberone@example.com",
1314
"Name": "Subscriber",
14-
"Date": "2010-10-25 13:04:00",
15+
"StateChangedDate": "2010-10-25 13:04:00",
16+
"ListJoinedDate": "2010-10-25 13:04:00",
1517
"State": "Deleted",
1618
"CustomFields": [
1719
{
@@ -24,23 +26,26 @@
2426
{
2527
"EmailAddress": "example+1@example.com",
2628
"Name": "Example One",
27-
"Date": "2010-10-26 10:56:00",
29+
"StateChangedDate": "2010-10-26 10:56:00",
30+
"ListJoinedDate": "2010-10-26 10:56:00",
2831
"State": "Deleted",
2932
"CustomFields": [],
3033
"ReadsEmailWith": ""
3134
},
3235
{
3336
"EmailAddress": "example+2@example.com",
3437
"Name": "Example Two",
35-
"Date": "2010-10-26 10:56:00",
38+
"StateChangedDate": "2010-10-26 10:56:00",
39+
"ListJoinedDate": "2010-10-26 10:56:00",
3640
"State": "Deleted",
3741
"CustomFields": [],
3842
"ReadsEmailWith": ""
3943
},
4044
{
4145
"EmailAddress": "example+3@example.com",
4246
"Name": "Example Three",
43-
"Date": "2010-10-26 10:56:00",
47+
"StateChangedDate": "2010-10-26 10:56:00",
48+
"ListJoinedDate": "2010-10-26 10:56:00",
4449
"State": "Deleted",
4550
"CustomFields": [],
4651
"ReadsEmailWith": "Gmail"

test/fixtures/segment_subscribers.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
{
44
"EmailAddress": "personone@example.com",
55
"Name": "Person One",
6-
"Date": "2010-10-27 13:13:00",
6+
"StateChangedDate": "2010-10-27 13:13:00",
7+
"ListJoinedDate": "2010-10-27 13:13:00",
78
"State": "Active",
89
"CustomFields": []
910
},
1011
{
1112
"EmailAddress": "persontwo@example.com",
1213
"Name": "Person Two",
13-
"Date": "2010-10-27 13:13:00",
14+
"StateChangedDate": "2010-10-27 13:13:00",
15+
"ListJoinedDate": "2010-10-27 13:13:00",
1416
"State": "Active",
1517
"CustomFields": []
1618
}

test/fixtures/segment_subscribers_with_tracking_preference.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
{
44
"EmailAddress": "personone@example.com",
55
"Name": "Person One",
6-
"Date": "2010-10-27 13:13:00",
6+
"StateChangedDate": "2010-10-27 13:13:00",
7+
"ListJoinedDate": "2010-10-27 13:13:00",
78
"State": "Active",
89
"CustomFields": [],
910
"ConsentToTrack": "Yes"
1011
},
1112
{
1213
"EmailAddress": "persontwo@example.com",
1314
"Name": "Person Two",
14-
"Date": "2010-10-27 13:13:00",
15+
"StateChangedDate": "2010-10-27 13:13:00",
16+
"ListJoinedDate": "2010-10-27 13:13:00",
1517
"State": "Active",
1618
"CustomFields": [],
1719
"ConsentToTrack": "No"

0 commit comments

Comments
 (0)