From 319cac499c6d43e4339a322c174ae7fe04860d19 Mon Sep 17 00:00:00 2001 From: Grayson Chao Date: Fri, 17 Oct 2014 11:27:29 -0700 Subject: [PATCH 1/2] Break out examples into readable/runnable chunks --- examples/{example.py => bankAccount.py} | 56 +----------------------- examples/job.py | 58 +++++++++++++++++++++++++ examples/postcard.py | 40 +++++++++++++++++ 3 files changed, 99 insertions(+), 55 deletions(-) rename examples/{example.py => bankAccount.py} (59%) create mode 100644 examples/job.py create mode 100644 examples/postcard.py diff --git a/examples/example.py b/examples/bankAccount.py similarity index 59% rename from examples/example.py rename to examples/bankAccount.py index 58d77d0..c89cfd5 100644 --- a/examples/example.py +++ b/examples/bankAccount.py @@ -21,61 +21,7 @@ print "=======================================================" print "\n" -# Creating an Object - -example_object = lob.Object.create( - name='Example Object', - file='https://www.lob.com/test.pdf', - setting_id='201', - quantity=1, - double_sided=1 -) - -print "Object Response" -print "\n" -print "=======================================================" -print "\n" -print example_object -print "\n" -print "=======================================================" -print "\n" - -# Creating a Job using the previously created address and object - -example_job = lob.Job.create( - to_address = example_address, - from_address = example_address, - objects = example_object, -) - -print "Job Response" -print "\n" -print "=======================================================" -print "\n" -print example_job -print "\n" -print "=======================================================" -print "\n" - -# Creating a Postcard - -example_postcard = lob.Postcard.create( - to_address = example_address, - from_address = example_address, - front = 'https://www.lob.com/test.pdf', - back = 'https://www.lob.com/test.pdf' -) - -print "Postcard Response" -print "\n" -print "=======================================================" -print "\n" -print example_postcard -print "\n" -print "=======================================================" -print "\n" - -# Creating a Bank Account +# Creating a Bank Account using the previously created account_address example_bank_account = lob.BankAccount.create( routing_number = '123456789', diff --git a/examples/job.py b/examples/job.py new file mode 100644 index 0000000..9cd0237 --- /dev/null +++ b/examples/job.py @@ -0,0 +1,58 @@ +import lob +lob.api_key = "test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc" # Replace this API key with your own. + +# Creating an Address Object + +example_address = lob.Address.create( + name='Joe Smith', + address_line1='104, Printing Boulevard', + address_city='Boston', + address_state='MA', + address_country='US', + address_zip='12345' +) +print "\n" +print "Address Response" +print "\n" +print "=======================================================" +print "\n" +print example_address +print "\n" +print "=======================================================" +print "\n" + +# Creating an Object + +example_object = lob.Object.create( + name='Example Object', + file='https://www.lob.com/test.pdf', + setting_id='201', + quantity=1, + double_sided=1 +) + +print "Object Response" +print "\n" +print "=======================================================" +print "\n" +print example_object +print "\n" +print "=======================================================" +print "\n" + +# Creating a Job using the previously created address and object + +example_job = lob.Job.create( + to_address = example_address, + from_address = example_address, + objects = example_object, +) + +print "Job Response" +print "\n" +print "=======================================================" +print "\n" +print example_job +print "\n" +print "=======================================================" +print "\n" diff --git a/examples/postcard.py b/examples/postcard.py new file mode 100644 index 0000000..13ce240 --- /dev/null +++ b/examples/postcard.py @@ -0,0 +1,40 @@ +import lob +lob.api_key = "test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc" # Replace this API key with your own. + +# Creating an Address Object + +example_address = lob.Address.create( + name='Joe Smith', + address_line1='104, Printing Boulevard', + address_city='Boston', + address_state='MA', + address_country='US', + address_zip='12345' +) +print "\n" +print "Address Response" +print "\n" +print "=======================================================" +print "\n" +print example_address +print "\n" +print "=======================================================" +print "\n" + +# Creating a Postcard + +example_postcard = lob.Postcard.create( + to_address = example_address, + from_address = example_address, + front = 'https://www.lob.com/test.pdf', + back = 'https://www.lob.com/test.pdf' +) + +print "Postcard Response" +print "\n" +print "=======================================================" +print "\n" +print example_postcard +print "\n" +print "=======================================================" +print "\n" From d9d359e0e4568296c5b2c12bc1a1e631d5d5b6ce Mon Sep 17 00:00:00 2001 From: Grayson Chao Date: Mon, 20 Oct 2014 13:05:39 -0700 Subject: [PATCH 2/2] Rename bankaccount and fix equals sign spacing --- examples/{bankAccount.py => check.py} | 12 ++++++------ examples/job.py | 22 +++++++++++----------- examples/postcard.py | 12 ++++++------ 3 files changed, 23 insertions(+), 23 deletions(-) rename examples/{bankAccount.py => check.py} (90%) diff --git a/examples/bankAccount.py b/examples/check.py similarity index 90% rename from examples/bankAccount.py rename to examples/check.py index c89cfd5..6fdcd40 100644 --- a/examples/bankAccount.py +++ b/examples/check.py @@ -4,12 +4,12 @@ # Creating an Address Object example_address = lob.Address.create( - name='Joe Smith', - address_line1='104, Printing Boulevard', - address_city='Boston', - address_state='MA', - address_country='US', - address_zip='12345' + name = 'Joe Smith', + address_line1 = '104, Printing Boulevard', + address_city = 'Boston', + address_state = 'MA', + address_country = 'US', + address_zip = '12345' ) print "\n" print "Address Response" diff --git a/examples/job.py b/examples/job.py index 9cd0237..34c5ec7 100644 --- a/examples/job.py +++ b/examples/job.py @@ -4,12 +4,12 @@ # Creating an Address Object example_address = lob.Address.create( - name='Joe Smith', - address_line1='104, Printing Boulevard', - address_city='Boston', - address_state='MA', - address_country='US', - address_zip='12345' + name = 'Joe Smith', + address_line1 = '104, Printing Boulevard', + address_city = 'Boston', + address_state = 'MA', + address_country = 'US', + address_zip = '12345' ) print "\n" print "Address Response" @@ -24,11 +24,11 @@ # Creating an Object example_object = lob.Object.create( - name='Example Object', - file='https://www.lob.com/test.pdf', - setting_id='201', - quantity=1, - double_sided=1 + name = 'Example Object', + file = 'https://www.lob.com/test.pdf', + setting_id = '201', + quantity = 1, + double_sided = 1 ) print "Object Response" diff --git a/examples/postcard.py b/examples/postcard.py index 13ce240..c60ac1d 100644 --- a/examples/postcard.py +++ b/examples/postcard.py @@ -4,12 +4,12 @@ # Creating an Address Object example_address = lob.Address.create( - name='Joe Smith', - address_line1='104, Printing Boulevard', - address_city='Boston', - address_state='MA', - address_country='US', - address_zip='12345' + name = 'Joe Smith', + address_line1 = '104, Printing Boulevard', + address_city = 'Boston', + address_state = 'MA', + address_country = 'US', + address_zip = '12345' ) print "\n" print "Address Response"