Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ghimes committed Jul 19, 2019
1 parent bcda058 commit a30171c
Show file tree
Hide file tree
Showing 39 changed files with 2,486 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

#PyCharm settins
.idea
11 changes: 11 additions & 0 deletions .idea/mailwizz-python-sdk.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
@@ -1 +1 @@
# mailwizz-python-sdk
# Mailwizz-python-sdk
1 change: 1 addition & 0 deletions __init__.py
@@ -0,0 +1 @@
name = 'Mailwizz Python SDK'
38 changes: 38 additions & 0 deletions examples/campaign_bounces.py
@@ -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)
183 changes: 183 additions & 0 deletions examples/campaigns.py
@@ -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)
48 changes: 48 additions & 0 deletions examples/campaigns_tracking.py
@@ -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)
32 changes: 32 additions & 0 deletions examples/countries.py
@@ -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)
41 changes: 41 additions & 0 deletions examples/customers.py
@@ -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)

0 comments on commit a30171c

Please sign in to comment.