Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Courier Brands Demo using the Python SDK
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)
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)
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)
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)
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)
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