Created
July 31, 2020 15:03
-
-
Save aydrian/5b1cc9fdb3fae6b126586c5e77b7928f to your computer and use it in GitHub Desktop.
Courier Brands Demo using the 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
import pprint | |
from trycourier import Courier | |
from trycourier.exceptions import CourierAPIException | |
pp = pprint.PrettyPrinter(indent=2) | |
client = Courier() | |
brand_settings = { | |
'colors': { | |
'primary': "#f02700", | |
'secondary': "#ff5f39", | |
'tertiary': "#000000" | |
}, | |
'email': { | |
'header': { | |
'barColor': "#f02700", | |
'logo': { | |
'href': "https://foxhub.io", | |
'image': "https://i.imgur.com/j3FDeA2.png" | |
} | |
}, | |
'footer': { | |
'markdown': "Follow us on Social!", | |
'social': { | |
'facebook': { | |
'url': "https://facebook.com/foxhub" | |
}, | |
'twitter': { | |
'url': "https://twitter.com/foxhub" | |
} | |
} | |
} | |
} | |
} | |
brand_snippets = { | |
'items': [ | |
{ | |
'format': "handlebars", | |
'name': "tagline", | |
'value': """<!-- block title --> | |
<style> | |
.hero { | |
font-size: 24px; | |
} | |
</style> | |
<div class="hero">Doing done well</div>""" | |
} | |
] | |
} | |
try: | |
resp = client.create_brand( | |
id="FOXHUB", | |
name="Foxhub", | |
settings=brand_settings, | |
snippets=brand_snippets | |
) | |
pp.pprint(resp) | |
except CourierAPIException as err: | |
print(err.message) |
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
from trycourier import Courier | |
from trycourier.exceptions import CourierAPIException | |
client = Courier() | |
brand_id = "FOXHUB" | |
try: | |
resp = client.delete_brand(brand_id) | |
print("Brand %s deleted." % brand_id) | |
except CourierAPIException as err: | |
print(err.message) |
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
import pprint | |
from trycourier import Courier | |
from trycourier.exceptions import CourierAPIException | |
pp = pprint.PrettyPrinter(indent=2) | |
client = Courier() | |
brand_id = "treva-primary" | |
try: | |
resp = client.get_brand(brand_id) | |
pp.pprint(resp) | |
except CourierAPIException as err: | |
print(err.message) |
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
import pprint | |
from trycourier import Courier | |
from trycourier.exceptions import CourierAPIException | |
pp = pprint.PrettyPrinter(indent=2) | |
client = Courier() | |
try: | |
resp = client.get_brands() | |
pp.pprint(resp) | |
except CourierAPIException as err: | |
print(err.message) |
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
import pprint | |
from trycourier import Courier | |
from trycourier.exceptions import CourierAPIException | |
pp = pprint.PrettyPrinter(indent=2) | |
client = Courier() | |
brand_id = "FOXHUB" | |
brand_settings = { | |
'colors': { | |
'primary': "#ff5f39", | |
'secondary': "#f02700", | |
'tertiary': "#000000" | |
}, | |
'email': { | |
'header': { | |
'barColor': "#f02700", | |
'logo': { | |
'image': "https://i.imgur.com/j3FDeA2.png" | |
} | |
}, | |
'footer': { | |
'markdown': "Follow us on Social!", | |
'social': { | |
'facebook': { | |
'url': "https://facebook.com/foxhub" | |
}, | |
'twitter': { | |
'url': "https://twitter.com/foxhub" | |
} | |
} | |
} | |
} | |
} | |
brand_snippets = { | |
'items': [ | |
{ | |
'format': "handlebars", | |
'name': "tagline", | |
'value': """<!-- block title --> | |
<style> | |
.hero { | |
font-size: 24px; | |
} | |
</style> | |
<div class="hero">Doing done well</div>""" | |
} | |
] | |
} | |
try: | |
resp = client.replace_brand( | |
brand_id, | |
name="New Foxhub", | |
settings=brand_settings, | |
snippets=brand_snippets | |
) | |
pp.pprint(resp) | |
except CourierAPIException as err: | |
print(err.message) |
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
import pprint | |
import random | |
import string | |
from trycourier import Courier | |
from trycourier.exceptions import CourierAPIException | |
pp = pprint.PrettyPrinter(indent=2) | |
client = Courier() | |
brand_id = "FOXHUB" | |
try: | |
resp = client.send( | |
event="TRIP_CONFIRM", | |
recipient="AYDRIAN10036", | |
profile={ | |
'email': "aydrian.demo@gmail.com" | |
}, | |
brand=brand_id, | |
data={ | |
'name': "Aydrian", | |
'company': "Courier", | |
'confirm_code': | |
''.join(random.choice(string.ascii_uppercase) for i in range(8)) | |
} | |
) | |
pp.pprint(resp) | |
except CourierAPIException as err: | |
print(err.message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment