From 84de3e3efa497127137ec9affa01ae091430444b Mon Sep 17 00:00:00 2001 From: Elnaz Moshfeghian Date: Fri, 1 May 2015 12:13:01 -0700 Subject: [PATCH] feat(examples): add html, data, and custom fonts --- examples/check.py | 25 ++++++++++++++++++++++++- examples/create_pdf.py | 5 ++--- examples/job.py | 30 +++++++++++++++++++++++++----- examples/letter.py | 31 ++++++++++++++++++++++++++++--- examples/postcard.py | 27 ++++++++++++++++++++++++--- tests/test_area.py | 8 ++++---- 6 files changed, 107 insertions(+), 19 deletions(-) diff --git a/examples/check.py b/examples/check.py index 3b623ac..095ea88 100644 --- a/examples/check.py +++ b/examples/check.py @@ -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', @@ -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', @@ -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', @@ -79,6 +87,21 @@ bank_account = example_bank_account, amount = 1000, memo = 'Services Rendered', + file = """ + + + + +

Demo check for {{name}}

+ """, + data = { + 'name': example_address.name + }, logo = 'https://s3-us-west-2.amazonaws.com/lob-assets/lob_check_logo.png' ) diff --git a/examples/create_pdf.py b/examples/create_pdf.py index 052ff39..5f5aab9 100644 --- a/examples/create_pdf.py +++ b/examples/create_pdf.py @@ -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 diff --git a/examples/job.py b/examples/job.py index 61a49c1..67c7603 100644 --- a/examples/job.py +++ b/examples/job.py @@ -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', @@ -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 = """ + + + + +

Hi {{name}}

+ """, + data = { + 'name': example_address.name + }, setting = '201', - quantity = 1, - double_sided = 1 + quantity = 1 ) print "Object Response" @@ -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, diff --git a/examples/letter.py b/examples/letter.py index 6395330..b93ff3e 100644 --- a/examples/letter.py +++ b/examples/letter.py @@ -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', @@ -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 = '

Hello Julia

' + file = """ + + + + +

Special offer for {{company}}

+ """, + data = { + 'company': 'ACME' + }, + color = True ) print "Letter Response" diff --git a/examples/postcard.py b/examples/postcard.py index 6989754..3a3f92c 100644 --- a/examples/postcard.py +++ b/examples/postcard.py @@ -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', @@ -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 = """ + + + + +

Hi {{name}}

+ """, + data = { + 'name': example_address.name + }, + message = "Welcome to the club!" ) print "Postcard Response" diff --git a/tests/test_area.py b/tests/test_area.py index 96e53d7..ff9424a 100644 --- a/tests/test_area.py +++ b/tests/test_area.py @@ -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 = '

Hi

', + back = '

Goodbye

', routes = ['94158','60031'], target_type = '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 = '

Hi

', + back = '

Goodbye

', routes = self.route, target_type = 'all' )