Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion examples/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

example_address = lob.Address.create(
name = 'Joe Smith',
description = 'Joe - Home',
metadata = {
'group': 'Members'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does group have to be in quotes to work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for python dictionaries you do

},
address_line1 = '104, Printing Boulevard',
address_city = 'Boston',
address_state = 'MA',
Expand All @@ -24,6 +28,7 @@
# Creating a Bank Account using the previously created account_address

example_bank_account = lob.BankAccount.create(
description = 'Example bank account',
routing_number = '122100024',
account_number = '1234564789',
signatory = 'John Doe',
Expand Down Expand Up @@ -66,7 +71,10 @@
# Creating a Check using the previously created and verified bank account

example_check = lob.Check.create(
name = 'Example Check',
description = 'Example Check',
metadata = {
'FY': '2015'
},
to_address = {
'name': 'Lob',
'address_line1': '185 Berry Street',
Expand All @@ -79,6 +87,21 @@
bank_account = example_bank_account,
amount = 1000,
memo = 'Services Rendered',
file = """
<html>
<head>
<style>
@font-face {
font-family: 'Loved by the King';
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf');
}
</style>
</head>
<body><h1>Demo check for {{name}}</h1></body>
</html>""",
data = {
'name': example_address.name
},
logo = 'https://s3-us-west-2.amazonaws.com/lob-assets/lob_check_logo.png'
)

Expand Down
5 changes: 2 additions & 3 deletions examples/create_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
})

example_object = lob.Object.create(
name='Example Object',
description='Example Object',
file=open('out.pdf', 'rb'),
setting_id=201,
full_bleed=1
setting_id=201
)

print "Check out the created PDF here: " + example_object.url
30 changes: 25 additions & 5 deletions examples/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

example_address = lob.Address.create(
name = 'Joe Smith',
description = 'Joe - Home',
metadata = {
'group': 'Members'
},
address_line1 = '104, Printing Boulevard',
address_city = 'Boston',
address_state = 'MA',
Expand All @@ -24,11 +28,24 @@
# Creating an Object

example_object = lob.Object.create(
name = 'Example Object',
file = 'https://s3-us-west-2.amazonaws.com/lob-assets/test.pdf',
description = 'Example Object',
file = """
<html>
<head>
<style>
@font-face {
font-family: 'Loved by the King';
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf');
}
</style>
</head>
<body><h1>Hi {{name}}</h1></body>
</html>""",
data = {
'name': example_address.name
},
setting = '201',
quantity = 1,
double_sided = 1
quantity = 1
)

print "Object Response"
Expand All @@ -43,7 +60,10 @@
# Creating a Job using the previously created address and object

example_job = lob.Job.create(
name = 'Test Job',
description = 'Test Job',
metadata = {
'campaign': 'Member survey'
},
to_address = example_address,
from_address = example_address,
objects = example_object,
Expand Down
31 changes: 28 additions & 3 deletions examples/letter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

example_address = lob.Address.create(
name = 'Julia Sanchez',
description = 'Julia - Home',
metadata = {
'department': 'marketing'
},
address_line1 = '104 Printing Boulevard',
address_city = 'Boston',
address_state = 'MA',
Expand All @@ -24,16 +28,37 @@
# Creating a Letter

example_letter = lob.Letter.create(
name = 'Test Letter',
description = 'Test Letter',
metadata = {
'campaign': 'enterprise offer'
},
to_address = {
'name': 'Antoinette Reynolds',
'address_line1': '1859 Kinney St',
'address_city': 'Agawam',
'address_zip': '01001',
'address_state': 'MA'
'address_state': 'MA',
'metadata': {
'customer_type': 'enterprise'
}
},
from_address = example_address,
file = '<html><p>Hello Julia</p></html>'
file = """
<html>
<head>
<style>
@font-face {
font-family: 'Loved by the King';
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf');
}
</style>
</head>
<body><h1>Special offer for {{company}}</h1></body>
</html>""",
data = {
'company': 'ACME'
},
color = True
)

print "Letter Response"
Expand Down
27 changes: 24 additions & 3 deletions examples/postcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

example_address = lob.Address.create(
name = 'Joe Smith',
description = 'Joe - Home',
metadata = {
'group': 'Members'
},
address_line1 = '104, Printing Boulevard',
address_city = 'Boston',
address_state = 'MA',
Expand All @@ -24,11 +28,28 @@
# Creating a Postcard

example_postcard = lob.Postcard.create(
name = 'Test Postcard',
description = 'Test Postcard',
metadata = {
'campaign': 'Member welcome'
},
to_address = example_address,
from_address = example_address,
front = 'https://s3-us-west-2.amazonaws.com/lob-assets/test.pdf',
back = 'https://s3-us-west-2.amazonaws.com/lob-assets/test.pdf'
front = """
<html>
<head>
<style>
@font-face {
font-family: 'Loved by the King';
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf');
}
</style>
</head>
<body><h1>Hi {{name}}</h1></body>
</html>""",
data = {
'name': example_address.name
},
message = "Welcome to the club!"
)

print "Postcard Response"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def setUp(self):
def test_create_area_with_zip(self):
area = lob.Area.create(
description = 'area_test_zip',
front = 'https://s3-us-west-2.amazonaws.com/lob-assets/areafront.pdf',
back = 'https://s3-us-west-2.amazonaws.com/lob-assets/areaback.pdf',
front = '<h1>Hi</h1>',
back = '<h1>Goodbye</h1>',
routes = ['94158','60031'],
target_type = 'all'
)
Expand All @@ -22,8 +22,8 @@ def test_create_area_with_zip(self):
def test_create_area_with_route(self):
area = lob.Area.create(
description = 'area_test_route',
front = 'https://s3-us-west-2.amazonaws.com/lob-assets/areafront.pdf',
back = 'https://s3-us-west-2.amazonaws.com/lob-assets/areaback.pdf',
front = '<h1>Hi</h1>',
back = '<h1>Goodbye</h1>',
routes = self.route,
target_type = 'all'
)
Expand Down