Skip to content

Commit b7eb6a8

Browse files
authored
Merge pull request #76 from campaignmonitor/EL-360
EL-360 -- Update to cater for the subscriber endpoints
2 parents 6a0bbd0 + 1a04ce6 commit b7eb6a8

17 files changed

Lines changed: 109 additions & 2 deletions

HISTORY.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# createsend-python history
22

3-
## v7.0.0 - 19 Nov, 2021
3+
## v7.0.0 - 15 Dec, 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)
66
* Added 'Tags' as another field that is returned in 'client.scheduled', 'client.drafts' and client.campaigns'
77
* Added 'Name' as another field that is returned in 'campaign.summary'
88
* Add new support for 'client.tags' endpoint (ie: getting list of tags for the client)
99
* Add support for pagination, filtering and sorting to 'client.campaigns' endpoint
1010
* Add Python 3.10 to `tox.ini`
11+
* Adding support for returning ListJoinedDate for each subscriber.
12+
* List.Active()
13+
* List.Bounced()
14+
* List.Unsubscribed()
15+
* List.Unconfirmed()
16+
* List.Deleted()
17+
* Segment.Subscribers()
18+
* Subscriber.Get()
1119

1220
## v6.1.2 - 10 Feb, 2021
1321
* Add `excludemessagebody` parameter for Transactional message details endpoint

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"EmailAddress": "[email protected]",
55
"Name": "Person One",
66
"Date": "2010-10-25 10:28:00",
7+
"ListJoinedDate": "2010-10-24 10:28:00",
78
"State": "Active",
89
"CustomFields": [
910
{
@@ -33,6 +34,7 @@
3334
"EmailAddress": "[email protected]",
3435
"Name": "Person Two",
3536
"Date": "2010-10-25 12:17:00",
37+
"ListJoinedDate": "2010-10-25 12:17:00",
3638
"State": "Active",
3739
"CustomFields": [
3840
{
@@ -46,6 +48,7 @@
4648
"EmailAddress": "[email protected]",
4749
"Name": "Person Three",
4850
"Date": "2010-10-25 12:52:00",
51+
"ListJoinedDate": "2010-10-25 12:52:00",
4952
"State": "Active",
5053
"CustomFields": [
5154
{
@@ -59,6 +62,7 @@
5962
"EmailAddress": "[email protected]",
6063
"Name": "Person Four",
6164
"Date": "2010-10-27 13:13:00",
65+
"ListJoinedDate": "2010-10-27 13:13:00",
6266
"State": "Active",
6367
"CustomFields": [],
6468
"ReadsEmailWith": ""
@@ -67,6 +71,7 @@
6771
"EmailAddress": "[email protected]",
6872
"Name": "Person Five",
6973
"Date": "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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"EmailAddress": "[email protected]",
55
"Name": "Person One",
66
"Date": "2010-10-25 10:28:00",
7+
"ListJoinedDate": "2010-10-24 10:28:00",
78
"State": "Active",
89
"CustomFields": [
910
{
@@ -34,6 +35,7 @@
3435
"EmailAddress": "[email protected]",
3536
"Name": "Person Two",
3637
"Date": "2010-10-25 12:17:00",
38+
"ListJoinedDate": "2010-10-25 12:17:00",
3739
"State": "Active",
3840
"CustomFields": [
3941
{
@@ -48,6 +50,7 @@
4850
"EmailAddress": "[email protected]",
4951
"Name": "Person Three",
5052
"Date": "2010-10-25 12:52:00",
53+
"ListJoinedDate": "2010-10-25 12:52:00",
5154
"State": "Active",
5255
"CustomFields": [
5356
{
@@ -62,6 +65,7 @@
6265
"EmailAddress": "[email protected]",
6366
"Name": "Person Four",
6467
"Date": "2010-10-27 13:13:00",
68+
"ListJoinedDate": "2010-10-27 13:13:00",
6569
"State": "Active",
6670
"CustomFields": [],
6771
"ReadsEmailWith": "",
@@ -71,6 +75,7 @@
7175
"EmailAddress": "[email protected]",
7276
"Name": "Person Five",
7377
"Date": "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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"EmailAddress": "[email protected]",
55
"Name": "Bounced One",
66
"Date": "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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"EmailAddress": "[email protected]",
55
"Name": "Deleted One",
66
"Date": "2010-10-25 13:11:00",
7+
"ListJoinedDate": "2010-10-25 13:11:00",
78
"State": "Deleted",
89
"CustomFields": [],
910
"ReadsEmailWith": "Gmail"
@@ -12,6 +13,7 @@
1213
"EmailAddress": "[email protected]",
1314
"Name": "Subscriber",
1415
"Date": "2010-10-25 13:04:00",
16+
"ListJoinedDate": "2010-10-25 13:04:00",
1517
"State": "Deleted",
1618
"CustomFields": [
1719
{
@@ -25,6 +27,7 @@
2527
"EmailAddress": "[email protected]",
2628
"Name": "Example One",
2729
"Date": "2010-10-26 10:56:00",
30+
"ListJoinedDate": "2010-10-26 10:56:00",
2831
"State": "Deleted",
2932
"CustomFields": [],
3033
"ReadsEmailWith": ""
@@ -33,6 +36,7 @@
3336
"EmailAddress": "[email protected]",
3437
"Name": "Example Two",
3538
"Date": "2010-10-26 10:56:00",
39+
"ListJoinedDate": "2010-10-26 10:56:00",
3640
"State": "Deleted",
3741
"CustomFields": [],
3842
"ReadsEmailWith": ""
@@ -41,6 +45,7 @@
4145
"EmailAddress": "[email protected]",
4246
"Name": "Example Three",
4347
"Date": "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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"EmailAddress": "[email protected]",
55
"Name": "Person One",
66
"Date": "2010-10-27 13:13:00",
7+
"ListJoinedDate": "2010-10-27 13:13:00",
78
"State": "Active",
89
"CustomFields": []
910
},
1011
{
1112
"EmailAddress": "[email protected]",
1213
"Name": "Person Two",
1314
"Date": "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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"EmailAddress": "[email protected]",
55
"Name": "Person One",
66
"Date": "2010-10-27 13:13:00",
7+
"ListJoinedDate": "2010-10-27 13:13:00",
78
"State": "Active",
89
"CustomFields": [],
910
"ConsentToTrack": "Yes"
@@ -12,6 +13,7 @@
1213
"EmailAddress": "[email protected]",
1314
"Name": "Person Two",
1415
"Date": "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)