Skip to content

Commit 5ef2cb4

Browse files
committed
EL-281 - Update the samples and readme file
1 parent 16d97a2 commit 5ef2cb4

4 files changed

Lines changed: 67 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ clients = cs.clients()
8989
```
9090

9191
## Basic usage
92-
This example of listing all your clients and their campaigns demonstrates basic usage of the library and the data returned from the API:
92+
This example of listing all your clients and their draft campaigns demonstrates basic usage of the library and the data returned from the API:
9393

9494
```python
9595
from createsend import *
@@ -104,7 +104,7 @@ for cl in clients:
104104
print("Client: %s" % cl.Name)
105105
client = Client(auth, cl.ClientID)
106106
print("- Campaigns:")
107-
for cm in client.campaigns().Results:
107+
for cm in client.drafts():
108108
print(" - %s" % cm.Subject)
109109
```
110110

samples/campaigns.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+
campaignId = 'YOUR_CAMPAIGN_ID'
7+
8+
campaign = Campaign(auth, campaignId)
9+
10+
# Get the summary info for a campaign
11+
summary = campaign.summary()
12+
for property, value in vars(summary).items():
13+
print(property, ":", value)

samples/clients.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from createsend import *
2+
3+
auth = {
4+
'access_token': 'YOUR_ACCESS_TOKEN',
5+
'refresh_token': 'YOUR_REFRESH_TOKEN' }
6+
clientId = 'YOUR_CLIENT_ID'
7+
8+
cs = CreateSend(auth)
9+
client = Client(auth, clientId)
10+
11+
# Get list of sent campaigns
12+
print("List of sent campaigns:")
13+
campaigns = []
14+
pageNumber = 1
15+
pagedCampaigns = client.campaigns(page = 1)
16+
numberOfPages = pagedCampaigns.NumberOfPages
17+
while pageNumber <= numberOfPages:
18+
if (pageNumber > 1):
19+
pagedCampaigns = client.campaigns(page = pageNumber)
20+
21+
print(" Page: %d" % pageNumber)
22+
for cm in pagedCampaigns.Results:
23+
print(" - %s" % cm.Subject)
24+
25+
pageNumber = pageNumber + 1
26+
27+
# Get list of drafts campaigns
28+
print("List of drafts campaigns:")
29+
for cm in client.drafts():
30+
print(" - %s" % cm.Subject)
31+
32+
# Get list of scheduled campaigns
33+
print("List of scheduled campaigns:")
34+
for cm in client.scheduled():
35+
print(" - %s" % cm.Subject)
36+
37+
# Get list of tags
38+
print("List of tags:")
39+
for tag in client.tags():
40+
print(" Tag: %s - NumberOfCampaigns: %d" % (tag.Name, tag.NumberOfCampaigns))

samples/general.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from createsend import *
2+
3+
auth = {
4+
'access_token': 'YOUR_ACCESS_TOKEN',
5+
'refresh_token': 'YOUR_REFRESH_TOKEN' }
6+
7+
cs = CreateSend(auth)
8+
clients = cs.clients()
9+
10+
# Get list of clients
11+
for cl in clients:
12+
print("Client: %s - Id: %s" % (cl.Name, cl.ClientID))

0 commit comments

Comments
 (0)