Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
2,486 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,6 @@ venv.bak/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
#PyCharm settins | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# mailwizz-python-sdk | ||
# Mailwizz-python-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name = 'Mailwizz Python SDK' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from setup_api import setup | ||
from endpoint.campaign_bounces import CampaignBounces | ||
|
||
|
||
""" | ||
SETUP THE API | ||
""" | ||
setup() | ||
|
||
""" | ||
CREATE THE ENDPOINT | ||
""" | ||
endpoint = CampaignBounces() | ||
|
||
""" | ||
GET ALL ITEMS | ||
""" | ||
response = endpoint.get_bounces(campaign_uid='CAMPAIGN_UID', page=1, per_page=10) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
""" | ||
CREATE BOUNCE | ||
""" | ||
response = endpoint.create('CAMPAIGN_UID', { | ||
# required | ||
'message': 'The reason why this email bounced', | ||
'bounce_type': 'hard', | ||
'subscriber_uid': 'SUBSCRIBER_UID' | ||
}) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
from datetime import datetime, timedelta | ||
from setup_api import setup | ||
from endpoint.campaigns import Campaigns | ||
|
||
""" | ||
SETUP THE API | ||
""" | ||
setup() | ||
|
||
""" | ||
CREATE THE ENDPOINT | ||
""" | ||
endpoint = Campaigns() | ||
|
||
""" | ||
GET ALL ITEMS | ||
""" | ||
response = endpoint.get_campaigns(page=1, per_page=10) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
GET ONE ITEM | ||
""" | ||
response = endpoint.get_campaign('CAMPAIGN_UID') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
CREATE ONE CAMPAIGN | ||
""" | ||
response = endpoint.create({ | ||
'name': 'My API Campaign', # required | ||
'type': 'regular', # optional: regular or autoresponder | ||
'from_name': 'John Doe', # required | ||
'from_email': 'john.doe@doe.com', # required | ||
'subject': 'Hey, i am testing the campaigns via API', # required | ||
'reply_to': 'john.doe@doe.com', # required | ||
'send_at': (datetime.now() + timedelta(hours=10)).strftime('%Y-%m-%d %H:%M:%S'), | ||
# required, this will use the timezone which customer selected | ||
'list_uid': 'LIST_UID', # required | ||
# 'segment_uid' : 'SEGMENT-UNIQUE-ID',# optional, only to narrow down | ||
|
||
# optional block, defaults are shown | ||
'options': { | ||
'url_tracking': 'no', # yes | no | ||
'json_feed': 'no', # yes | no | ||
'xml_feed': 'no', # yes | no | ||
'plain_text_email': 'yes', # yes | no | ||
'email_stats': None, # a valid email address where we should send the stats after campaign done | ||
|
||
# - if autoresponder uncomment bellow: | ||
# 'autoresponder_event' : 'AFTER-SUBSCRIBE', # AFTER-SUBSCRIBE or AFTER-CAMPAIGN-OPEN | ||
# 'autoresponder_time_unit' : 'hour', # minute, hour, day, week, month, year | ||
# 'autoresponder_time_value' : 1, # 1 hour after event | ||
# 'autoresponder_open_campaign_id' : 1, # INT id of campaign, only if event is AFTER-CAMPAIGN-OPEN, | ||
|
||
# - if this campaign is advanced recurring, you can set a cron job style frequency. | ||
# - please note that this applies only for regular campaigns. | ||
# 'cronjob' : '0 0 * * *', # once a day | ||
# 'cronjob_enabled' : 1, # 1 or 0 | ||
}, | ||
|
||
# required block, archive or template_uid or content : required. | ||
# the templates examples can be found here: Examples | ||
'template': { | ||
# 'archive' : open('template-example.zip', 'r').read(), | ||
'template_uid': 'TEMPLATE_UID', | ||
# 'content' : open('template-example.html', 'rb').read(), | ||
'inline_css': 'no', # yes | no | ||
# 'plain_text' : None, # leave empty to auto generate | ||
'auto_plain_text': 'yes', # yes | no | ||
}, | ||
}) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
UPDATE ONE CAMPAIGN | ||
""" | ||
response = endpoint.update('CAMPAIGN_UID', { | ||
'name': 'My API Campaign - UPDATED', # required | ||
'from_name': 'John Doe', # required | ||
'from_email': 'john.doe@doe.com', # required | ||
'subject': 'Hey, i am testing the campaigns via API', # required | ||
'reply_to': 'john.doe@doe.com', # required | ||
'send_at': (datetime.now() + timedelta(hours=10)).strftime('%Y-%m-%d %H:%M:%S'), | ||
# required, this will use the timezone which customer selected | ||
'list_uid': 'LIST_UID', # required | ||
# 'segment_uid' : 'SEGMENT-UNIQUE-ID',# optional, only to narrow down | ||
|
||
# optional block, defaults are shown | ||
'options': { | ||
'url_tracking': 'no', # yes | no | ||
'json_feed': 'no', # yes | no | ||
'xml_feed': 'no', # yes | no | ||
'plain_text_email': 'yes', # yes | no | ||
'email_stats': None, # a valid email address where we should send the stats after campaign done | ||
|
||
# - if autoresponder uncomment bellow: | ||
# 'autoresponder_event' : 'AFTER-SUBSCRIBE', # AFTER-SUBSCRIBE or AFTER-CAMPAIGN-OPEN | ||
# 'autoresponder_time_unit' : 'hour', # minute, hour, day, week, month, year | ||
# 'autoresponder_time_value' : 1, # 1 hour after event | ||
# 'autoresponder_open_campaign_id' : 1, # INT id of campaign, only if event is AFTER-CAMPAIGN-OPEN, | ||
|
||
# - if this campaign is advanced recurring, you can set a cron job style frequency. | ||
# - please note that this applies only for regular campaigns. | ||
# 'cronjob' : '0 0 * * *', # once a day | ||
# 'cronjob_enabled' : 1, # 1 or 0 | ||
}, | ||
|
||
# required block, archive or template_uid or content : required. | ||
# the templates examples can be found here: Examples | ||
'template': { | ||
# 'archive' : open('template-example.zip', 'r').read(), | ||
'template_uid': 'TEMPLATE_UID', | ||
# 'content' : open('template-example.html', 'rb').read(), | ||
'inline_css': 'no', # yes | no | ||
# 'plain_text' : None, # leave empty to auto generate | ||
'auto_plain_text': 'yes', # yes | no | ||
}, | ||
}) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
COPY ONE CAMPAIGN | ||
""" | ||
response = endpoint.copy('CAMPAIGN_UID') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
MARK ONE CAMPAIGN AS SENT | ||
""" | ||
response = endpoint.mark_sent('CAMPAIGN_UID') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
PAUSE/UNPAUSE ONE CAMPAIGN | ||
""" | ||
response = endpoint.pause_unpause('CAMPAIGN_UID') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
DELETE ONE CAMPAIGN | ||
""" | ||
response = endpoint.delete('CAMPAIGN_UID') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from setup_api import setup | ||
from endpoint.campaigns_tracking import CampaignsTracking | ||
|
||
""" | ||
SETUP THE API | ||
""" | ||
setup() | ||
|
||
""" | ||
CREATE THE ENDPOINT | ||
""" | ||
endpoint = CampaignsTracking() | ||
|
||
""" | ||
Track subscriber click for campaign click | ||
""" | ||
response = endpoint.track_url(campaign_uid='CAMPAIGN_UID', subscriber_uid='SUBSCRIBER_UID', hash_string='') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
Track subscriber open for campaign | ||
""" | ||
response = endpoint.track_opening(campaign_uid='CAMPAIGN_UID', subscriber_uid='SUBSCRIBER_UID') | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
|
||
""" | ||
Track subscriber unsubscribe for campaign | ||
""" | ||
response = endpoint.track_unsubscribe(campaign_uid='CAMPAIGN_UID', subscriber_uid='SUBSCRIBER_UID', data={ | ||
'ip_address': '123.123.123.123', | ||
'user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', | ||
'reason': 'Reason for unsubscribe!', | ||
}) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from setup_api import setup | ||
from endpoint.countries import Countries | ||
|
||
""" | ||
SETUP THE API | ||
""" | ||
setup() | ||
|
||
""" | ||
CREATE THE ENDPOINT | ||
""" | ||
endpoint = Countries() | ||
|
||
""" | ||
GET ALL ITEMS | ||
""" | ||
response = endpoint.get_countries(page=1, per_page=10) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) | ||
|
||
""" | ||
GET COUNTRY ZONES | ||
""" | ||
response = endpoint.get_zones(country_id=223, page=1, per_page=10) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from setup_api import setup | ||
from endpoint.customers import Customers | ||
|
||
""" | ||
SETUP THE API | ||
""" | ||
setup() | ||
|
||
""" | ||
CREATE THE ENDPOINT | ||
""" | ||
endpoint = Customers() | ||
|
||
""" | ||
CREATE CUSTOMER | ||
""" | ||
response = endpoint.create({ | ||
'customer': { | ||
'first_name': 'John', | ||
'last_name': 'Doe', | ||
'email': 'john.doe@doe.com', | ||
'password': 'superDuperPassword', | ||
'timezone': 'UTC', | ||
'birthDate': '1979-07-30' | ||
}, | ||
# company is optional, unless required from app settings | ||
'company': { | ||
'name': 'John Doe LLC', | ||
'country': 'United States', # see the countries endpoint for available countries and their zones | ||
'zone': 'New York', # see the countries endpoint for available countries and their zones | ||
'city': 'Brooklyn', | ||
'zip_code': 11222, | ||
'address_1': 'Some Address', | ||
'address_2': 'Some Other Address', | ||
}, | ||
}) | ||
|
||
""" | ||
DISPLAY RESPONSE | ||
""" | ||
print(response.content) |
Oops, something went wrong.