lob 1.9.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.travis.yml +3 -6
  4. data/CHANGELOG.md +46 -0
  5. data/README.md +125 -596
  6. data/Rakefile +0 -19
  7. data/examples/README.md +27 -0
  8. data/examples/checks.rb +22 -23
  9. data/examples/csv_postcards/create_postcards.rb +46 -0
  10. data/examples/csv_postcards/input.csv +7 -0
  11. data/examples/csv_postcards/postcard_back.html +38 -0
  12. data/examples/csv_postcards/postcard_front.html +25 -0
  13. data/examples/jobs.rb +65 -21
  14. data/examples/letters.rb +73 -0
  15. data/examples/postcards.rb +64 -12
  16. data/examples/verify/input.txt +7 -0
  17. data/examples/verify/verify.rb +38 -0
  18. data/lib/lob/errors/lob_error.rb +9 -6
  19. data/lib/lob/v1/address.rb +3 -4
  20. data/lib/lob/v1/area.rb +1 -1
  21. data/lib/lob/v1/bank_account.rb +5 -9
  22. data/lib/lob/v1/check.rb +1 -5
  23. data/lib/lob/v1/country.rb +1 -1
  24. data/lib/lob/v1/job.rb +1 -9
  25. data/lib/lob/v1/letter.rb +29 -0
  26. data/lib/lob/v1/object.rb +1 -1
  27. data/lib/lob/v1/postcard.rb +1 -9
  28. data/lib/lob/v1/resource.rb +4 -24
  29. data/lib/lob/v1/route.rb +9 -1
  30. data/lib/lob/v1/setting.rb +1 -1
  31. data/lib/lob/v1/state.rb +1 -1
  32. data/lib/lob/version.rb +1 -1
  33. data/lib/lob.rb +37 -16
  34. data/lob.gemspec +5 -7
  35. data/spec/lob/errors/lob_error_spec.rb +4 -2
  36. data/spec/lob/v1/address_spec.rb +24 -34
  37. data/spec/lob/v1/area_spec.rb +16 -38
  38. data/spec/lob/v1/bank_account_spec.rb +25 -79
  39. data/spec/lob/v1/check_spec.rb +38 -65
  40. data/spec/lob/v1/country_spec.rb +2 -4
  41. data/spec/lob/v1/job_spec.rb +116 -162
  42. data/spec/lob/v1/letter_spec.rb +75 -0
  43. data/spec/lob/v1/object_spec.rb +32 -50
  44. data/spec/lob/v1/postcard_spec.rb +66 -90
  45. data/spec/lob/v1/resource_spec.rb +0 -9
  46. data/spec/lob/v1/route_spec.rb +28 -6
  47. data/spec/lob/v1/setting_spec.rb +4 -12
  48. data/spec/lob/v1/state_spec.rb +2 -4
  49. data/spec/lob_spec.rb +25 -6
  50. data/spec/samples/8.5x11.pdf +0 -0
  51. data/spec/samples/postcardback.pdf +2288 -1
  52. data/spec/samples/postcardfront.pdf +1550 -0
  53. data/spec/spec_helper.rb +0 -6
  54. metadata +58 -62
  55. data/examples/create_pdf.rb +0 -25
  56. data/lib/lob/v1/packaging.rb +0 -21
  57. data/lib/lob/v1/service.rb +0 -21
  58. data/spec/lob/v1/packaging_spec.rb +0 -16
  59. data/spec/lob/v1/service_spec.rb +0 -16
data/Rakefile CHANGED
@@ -1,27 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
-
5
4
  Rake::TestTask.new do |t|
6
5
  t.libs.push "lib", "spec"
7
6
  t.test_files = FileList['spec/**/*_spec.rb']
8
7
  t.verbose = true
9
8
  end
10
-
11
-
12
- namespace :dev do
13
-
14
- desc "Download sample files to run tests with"
15
- task :setup do
16
- Dir.mkdir("spec/samples") unless File.exist?("spec/samples")
17
- files = [
18
- {url: "https://s3-us-west-2.amazonaws.com/lob-assets/postcardfront.pdf", name: "postcardfront.pdf"},
19
- {url: "https://s3-us-west-2.amazonaws.com/lob-assets/postcardback.pdf", name: "postcardback.pdf"},
20
- {url: "https://s3-us-west-2.amazonaws.com/lob-assets/test.pdf", name: "test.pdf"}
21
- ]
22
- files.each do |f|
23
- system "curl #{f[:url]} -o spec/samples/#{f[:name]}"
24
- end
25
-
26
- end
27
- end
@@ -0,0 +1,27 @@
1
+ # Ruby Examples
2
+
3
+ This directory contains a collection of ruby example to help get you started using the Lob API. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions.
4
+
5
+ ## /csv_postcards/
6
+
7
+ An example showing how to dynamically create postcards from a CSV using HTML, a custom font, variable data, and Lob's [Simple Postcard Service](https://lob.com/services/postcards).
8
+
9
+ ## /checks.rb
10
+
11
+ An example showing how to create a check using Lob's [Simple Check Service](https://lob.com/services/checks).
12
+
13
+ ## /jobs.rb
14
+
15
+ An example showing how to create objects and jobs using Lob's [Simple Print Service](https://lob.com/services/sps).
16
+
17
+ ## /letters.rb
18
+
19
+ And example showing how to create letters using Lob's [Simple Letter Service](https://lob.com/services/letters).
20
+
21
+ ## /postcards.rb
22
+
23
+ An example showing how to create postcards using Lob's [Simple Postcard Service](https://lob.com/services/postcards).
24
+
25
+ ## /verify.rb
26
+
27
+ An example showing how to verify an address using the [StreetAddress gem](https://github.com/derrek/street-address) and Lob's verify endpoint. This example saves verified addresses in a CSV file.
data/examples/checks.rb CHANGED
@@ -2,48 +2,47 @@ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
 
4
4
  # initialize Lob object
5
- Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
5
+ Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
6
6
  @lob = Lob.load
7
7
 
8
8
  # create an address
9
9
  to_address = @lob.addresses.create(
10
10
  name: "John Doe",
11
11
  address_line1: "104 Printing Boulevard",
12
- city: "Boston",
13
- state: "MA",
14
- country: "US",
15
- zip: 12345
12
+ address_city: "Boston",
13
+ address_state: "MA",
14
+ address_country: "US",
15
+ address_zip: "12345"
16
+ )
17
+
18
+ # create a from address
19
+ from_address = @lob.addresses.create(
20
+ name: "Jane Doe",
21
+ address_line1: "123 Hello Ave",
22
+ address_city: "Providence",
23
+ address_state: "RI",
24
+ address_country: "US",
25
+ address_zip: "02912"
16
26
  )
17
27
 
18
28
  # create a bank account
19
29
  bank_account = @lob.bank_accounts.create(
20
30
  routing_number: "322271627",
21
31
  account_number: "123456789",
22
- signatory: "John Doe",
23
- bank_address: {
24
- name: "Bank Address",
25
- address_line1: "120 6th Ave",
26
- city: "Boston",
27
- state: "MA",
28
- country: "US",
29
- zip: 12345
30
- },
31
- account_address: {
32
- name: "Account Address",
33
- address_line1: "120 6th Ave",
34
- city: "Boston",
35
- state: "MA",
36
- country: "US",
37
- zip: 12345
38
- }
32
+ account_type: "company",
33
+ signatory: "John Doe"
39
34
  )
40
35
 
36
+ puts bank_account
37
+ @lob.bank_accounts.verify(bank_account['id'], amounts: [23, 12])
38
+
41
39
  # send a $1000 check using an already created bank and address
42
40
  puts @lob.checks.create(
43
- name: "Test Check",
41
+ description: "Test Check",
44
42
  check_number: "10000",
45
43
  bank_account: bank_account["id"],
46
44
  to: to_address["id"],
45
+ from: from_address["id"],
47
46
  amount: 100,
48
47
  memo: "This is my first Check",
49
48
  message: "This check is for laundry"
@@ -0,0 +1,46 @@
1
+ $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
+ require 'lob'
3
+ require 'csv'
4
+
5
+ # Initialize Lob object
6
+ Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
7
+ @lob = Lob.load
8
+
9
+ # Load the HTML from postcard_front.html and postcard_back.html.
10
+ front_html = File.open(File.expand_path('../postcard_front.html', __FILE__)).read
11
+ back_html = File.open(File.expand_path('../postcard_back.html', __FILE__)).read
12
+
13
+ # Parse the CSV and create the postcards.
14
+ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
15
+ postcard = @lob.postcards.create(
16
+ description: 'CSV Test',
17
+ to: {
18
+ name: row[5],
19
+ address_line1: row[6],
20
+ address_line2: row[7],
21
+ address_city: row[8],
22
+ address_state: row[9],
23
+ address_zip: row[10],
24
+ address_country: row[11]
25
+ },
26
+ from: {
27
+ name: 'Lob',
28
+ address_line1: '123 Main Street',
29
+ address_city: 'San Francisco',
30
+ address_state: 'CA',
31
+ address_zip: '94185',
32
+ address_country: 'US'
33
+ },
34
+ size: "6x11",
35
+ front: front_html,
36
+ back: back_html,
37
+ data: {
38
+ background_image: row[1],
39
+ background_color: row[2],
40
+ name: row[0],
41
+ car: row[3],
42
+ mileage: row[4]
43
+ }
44
+ )
45
+ puts postcard['url']
46
+ end
@@ -0,0 +1,7 @@
1
+ Peter,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,LightBlue,Jeep Wrangler,65000,Peter,123 Main Street,Apt. 101,San Francisco,CA,94107,US
2
+ Marcus,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Bisque,Honda Pilot,65000,Marcus,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US
3
+ Leore,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleGreen,Jeep Wrangler,50000,Leore,123 Test Street,Apt. 101,San Francisco,CA,94105,US
4
+ Harry,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Thistle,Jeep Wrangler,50000,Harry,789 Elm Street,Apt. 101,San Francisco,CA,94107,US
5
+ Elnaz,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleTurqoise,Jeep Wrangler,35000,Elnaz,111 Washington Street,Apt. 101,San Francisco,CA,94112,US
6
+ Robin,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Wheat,Jeep Wrangler,35000,Robin,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US
7
+ Russell,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,WhiteSmoke,Jeep Wrangler,15000,Russell,1212 Fourth Street,Apt. 101,San Francisco,CA,94166,US
@@ -0,0 +1,38 @@
1
+ <html>
2
+ <head>
3
+ <title>Lob.com Sample 6x11 Postcard Back Template 1</title>
4
+ <style>
5
+ @font-face {
6
+ font-family: 'Arimo';
7
+ font-style: normal;
8
+ font-weight: 400;
9
+ src: url('https://s3-us-west-2.amazonaws.com/lob-assets/Arimo-Regular.ttf') format('truetype');
10
+ }
11
+ body {
12
+ width:11.25in;
13
+ height:6.25in;
14
+ margin:0;
15
+ padding:0;
16
+ background-size: 11.25in 6.25in;
17
+ }
18
+ #left-box {
19
+ font-family: Arimo;
20
+ font-size: .25in;
21
+ background-color: {{background_color}};
22
+ width: 5.85in;
23
+ height: 5.85in;
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ padding: .4in .6in 0 .4in;
28
+ }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div id="left-box">
33
+ Hey {{name}},<br><br>
34
+ Your {{car}} is due for its {{mileage}} mile service. Schedule an appointment today!<br><br>
35
+ Make sure to bring this card to receive great savings!<br><br>
36
+ </div>
37
+ </body>
38
+ </html>
@@ -0,0 +1,25 @@
1
+ <html>
2
+ <head>
3
+ <title>Lob.com Sample 6x11 Postcard Front</title>
4
+ <style>
5
+ *, *:before, *:after {
6
+ -webkit-box-sizing: border-box;
7
+ -moz-box-sizing: border-box;
8
+ box-sizing: border-box;
9
+ }
10
+ body {
11
+ width: 11.25in;
12
+ height: 6.25in;
13
+ margin: 0;
14
+ padding: 0;
15
+ /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
16
+ background-image: url({{background_image}});
17
+ background-size: 11.25in 6.25in;
18
+ background-repeat: no-repeat;
19
+ }
20
+ </style>
21
+ </head>
22
+
23
+ <body>
24
+ </body>
25
+ </html>
data/examples/jobs.rb CHANGED
@@ -1,47 +1,91 @@
1
1
  $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'open-uri'
2
3
  require 'lob'
3
4
 
4
5
  # initialize Lob object
5
- Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
6
+ Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
6
7
  @lob = Lob.load
7
8
 
8
- # find the setting_id for the object you want to create
9
- settings = @lob.settings.list
10
- setting_index = settings.find_index { |setting| setting["type"] === "documents" }
11
- setting_id = settings[setting_index]["id"]
9
+ html = %{
10
+ <html>
11
+ <head>
12
+ <title>Lob.com Sample Photo</title>
13
+ <style>
14
+ *, *:before, *:after {
15
+ -webkit-box-sizing: border-box;
16
+ -moz-box-sizing: border-box;
17
+ box-sizing: border-box;
18
+ }
12
19
 
13
- # create a file object to user later
14
- michigan_logo = @lob.objects.create(
15
- name: "Michigan Logo Document",
16
- file: "https://s3-us-west-2.amazonaws.com/lob-assets/goblue.pdf",
17
- setting: 101
20
+ @font-face {
21
+ font-family: 'Loved by the King';
22
+ font-style: normal;
23
+ font-weight: 400;
24
+ src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype');
25
+ }
26
+
27
+ body {
28
+ width: 6.25in;
29
+ height: 4.25in;
30
+ margin: 0;
31
+ padding: 0;
32
+ /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
33
+ background-image: url(https://s3-us-west-2.amazonaws.com/lob-assets/beach.jpg);
34
+ background-size: 6.25in 4.25in;
35
+ background-repeat: no-repeat;
36
+ }
37
+
38
+ .text {
39
+ margin: 50px;
40
+ width: 400px;
41
+ font-family: 'Loved by the King';
42
+ font-size: 50px;
43
+ font-weight: 700;
44
+ color: white;
45
+ text-shadow: 3px 3px black;
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <h1 class="text">Hello {{name}}!</h1>
52
+ <p class="text">Join us for the {{event}}!</p>
53
+ </body>
54
+
55
+ </html>
56
+ }
57
+
58
+ object = @lob.objects.create(
59
+ description: 'Test Object',
60
+ file: html,
61
+ data: { name: "Albert", event: "Summer 2015 Beach-athon" },
62
+ setting: 201
18
63
  )
19
64
 
20
65
  # create a to address
21
66
  to_address = @lob.addresses.create(
22
67
  name: "ToAddress",
23
68
  address_line1: "120 6th Ave",
24
- city: "Boston",
25
- state: "MA",
26
- country: "US",
27
- zip: 12345
69
+ address_city: "Boston",
70
+ address_state: "MA",
71
+ address_country: "US",
72
+ address_zip: 12345
28
73
  )
29
74
 
30
75
  # create a from address
31
76
  from_address = @lob.addresses.create(
32
77
  name: "FromAddress",
33
78
  address_line1: "120 6th Ave",
34
- city: "Boston",
35
- state: "MA",
36
- country: "US",
37
- zip: 12345
79
+ address_city: "Boston",
80
+ address_state: "MA",
81
+ address_country: "US",
82
+ address_zip: 12345
38
83
  )
39
84
 
40
-
41
85
  # send the object you created
42
86
  puts @lob.jobs.create(
43
- name: "Michigan Logo to Harry",
87
+ description: "Michigan Logo to Harry",
44
88
  to: to_address["id"],
45
89
  from: from_address["id"],
46
- objects: michigan_logo["id"]
90
+ objects: object["id"]
47
91
  )
@@ -0,0 +1,73 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob'
3
+
4
+ # initialize Lob object
5
+ Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
6
+ @lob = Lob.load
7
+
8
+ html = %{
9
+ <html>
10
+ <head>
11
+ <style>
12
+ *, *:before, *:after {
13
+ -webkit-box-sizing: border-box;
14
+ -moz-box-sizing: border-box;
15
+ box-sizing: border-box;
16
+ }
17
+
18
+ @font-face {
19
+ font-family: 'Loved by the King';
20
+ font-style: normal;
21
+ font-weight: 400;
22
+ src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype');
23
+ }
24
+
25
+ .text {
26
+ margin-left: 75px;
27
+ padding-top: 250px;
28
+ width: 400px;
29
+ font-family: 'Loved by the King';
30
+ font-size: 50px;
31
+ font-weight: 700;
32
+ color: black;
33
+ }
34
+ </style>
35
+ </head>
36
+
37
+ <body>
38
+ <p class="text">Hello {{name}}!<br/><br/>Join us for the {{event}}!</p>
39
+ </body>
40
+
41
+ </html>
42
+ }
43
+
44
+ # create a to address
45
+ to_address = @lob.addresses.create(
46
+ name: "ToAddress",
47
+ address_line1: "120 6th Ave",
48
+ address_city: "Boston",
49
+ address_state: "MA",
50
+ address_country: "US",
51
+ address_zip: 12345
52
+ )
53
+
54
+ # create a from address
55
+ from_address = @lob.addresses.create(
56
+ name: "FromAddress",
57
+ address_line1: "120 6th Ave",
58
+ address_city: "Boston",
59
+ address_state: "MA",
60
+ address_country: "US",
61
+ address_zip: 12345
62
+ )
63
+
64
+ # send the letter
65
+ puts @lob.letters.create(
66
+ description: "Test letter",
67
+ to: to_address["id"],
68
+ from: from_address["id"],
69
+ file: html,
70
+ data: { name: 'Albert', event: 'HTML Letter Conference'},
71
+ metadata: { campaign: 'HTML 1.0' },
72
+ color: false
73
+ )
@@ -2,34 +2,86 @@ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
 
4
4
  # initialize Lob object
5
- Lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc'
5
+ Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
6
6
  @lob = Lob.load
7
7
 
8
+ # HTML to send to the server
9
+ html = %{
10
+ <html>
11
+ <head>
12
+ <title>Lob.com Sample 4x6 Postcard Front</title>
13
+ <style>
14
+ *, *:before, *:after {
15
+ -webkit-box-sizing: border-box;
16
+ -moz-box-sizing: border-box;
17
+ box-sizing: border-box;
18
+ }
19
+
20
+ @font-face {
21
+ font-family: 'Loved by the King';
22
+ font-style: normal;
23
+ font-weight: 400;
24
+ src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype');
25
+ }
26
+
27
+ body {
28
+ width: 6.25in;
29
+ height: 4.25in;
30
+ margin: 0;
31
+ padding: 0;
32
+ /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
33
+ background-image: url(https://s3-us-west-2.amazonaws.com/lob-assets/beach.jpg);
34
+ background-size: 6.25in 4.25in;
35
+ background-repeat: no-repeat;
36
+ }
37
+
38
+ .text {
39
+ margin: 50px;
40
+ width: 400px;
41
+ font-family: 'Loved by the King';
42
+ font-size: 50px;
43
+ font-weight: 700;
44
+ color: white;
45
+ text-shadow: 3px 3px black;
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <h1 class="text">Hello {{name}}!</h1>
52
+ <p class="text">Join us for the {{event}}!</p>
53
+ </body>
54
+
55
+ </html>
56
+ }
57
+
8
58
  # create a to address
9
59
  to_address = @lob.addresses.create(
10
60
  name: "ToAddress",
11
61
  address_line1: "120 6th Ave",
12
- city: "Boston",
13
- state: "MA",
14
- country: "US",
15
- zip: 12345
62
+ address_city: "Boston",
63
+ address_state: "MA",
64
+ address_country: "US",
65
+ address_zip: 12345
16
66
  )
17
67
 
18
68
  # create a from address
19
69
  from_address = @lob.addresses.create(
20
70
  name: "FromAddress",
21
71
  address_line1: "120 6th Ave",
22
- city: "Boston",
23
- state: "MA",
24
- country: "US",
25
- zip: 12345
72
+ address_city: "Boston",
73
+ address_state: "MA",
74
+ address_country: "US",
75
+ address_zip: 12345
26
76
  )
27
77
 
28
78
  # send a postcard
29
79
  puts @lob.postcards.create(
30
- name: "John Joe",
80
+ description: "Beach Postcard",
31
81
  to: to_address["id"],
32
82
  from: from_address["id"],
33
- front: "https://s3-us-west-2.amazonaws.com/lob-assets/postcardfront.pdf",
34
- back: "https://s3-us-west-2.amazonaws.com/lob-assets/postcardback.pdf"
83
+ metadata: { campaign: "Summer 2015 Beach" },
84
+ data: { name: "Albert", event: "Summer 2015 Beach-athon" },
85
+ front: html,
86
+ message: "Please RSVP as soon as possible to reserve your lounge chair."
35
87
  )
@@ -0,0 +1,7 @@
1
+ 185 Berry St Unit 1510 San Francisco CA
2
+ 185 Berry St Ste 1510 SF CA
3
+ 185 Berry St SF CA
4
+ 185 NW Berry St, SF CA
5
+ 1600 Pennsylvania Ave, Washington, DC, 20500
6
+ 5904 Richmond Hwy Ste 340 Alexandria VA 22303-1864
7
+ 5905 Richmond Hwy Ste 340 Alexandria VA
@@ -0,0 +1,38 @@
1
+ $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
+
3
+ require 'csv'
4
+ require 'lob'
5
+
6
+ # Be sure to install the StreetAddress gem.
7
+ require 'street_address'
8
+
9
+ # Initialize Lob object
10
+ Lob.api_key = 'test_799ff27291c166d10ba191902ad02fb059c'
11
+ @lob = Lob.load
12
+
13
+ output = File.open(File.expand_path('../output.csv', __FILE__), 'w')
14
+
15
+ output.puts ['address_line1', 'address_city', 'address_state', 'address_zip', 'address_country'].join(',')
16
+
17
+ # Parse the CSV and create the postcards.
18
+ File.open(File.expand_path('../input.txt', __FILE__)).each_line do |line|
19
+ parsed_address = StreetAddress::US.parse(line)
20
+
21
+ verified_address = @lob.addresses.verify(
22
+ address_line1: parsed_address.to_s(:line1),
23
+ address_city: parsed_address.city,
24
+ address_state: parsed_address.state,
25
+ address_country: 'US'
26
+ )['address']
27
+
28
+ output.puts [
29
+ verified_address['address_line1'],
30
+ verified_address['address_city'],
31
+ verified_address['address_state'],
32
+ verified_address['address_zip'],
33
+ verified_address['address_country']
34
+ ].join(',')
35
+
36
+ end
37
+
38
+ output.close
@@ -1,17 +1,20 @@
1
1
  module Lob
2
+
2
3
  class LobError < StandardError
3
- attr_reader :message, :http_status, :http_body, :json_body
4
+ attr_reader :http_status, :http_body, :json_body
4
5
 
5
- def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
6
- @message = message
6
+ def initialize(message, http_status=nil, http_body=nil, json_body=nil)
7
7
  @http_status = http_status
8
8
  @http_body = http_body
9
9
  @json_body = json_body
10
+ status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
11
+ super("#{status_string}#{message} \n #{@http_body}")
10
12
  end
11
13
 
12
- def to_s
13
- status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
14
- "#{status_string}#{@message}"
14
+ def _response
15
+ @json_body
15
16
  end
17
+
16
18
  end
19
+
17
20
  end
@@ -7,12 +7,11 @@ module Lob
7
7
  end
8
8
 
9
9
  def verify(options={})
10
- params = @resource.format_address_params(options, false)
11
- Lob.submit(:post, address_verify_url, params)
10
+ Lob.submit(:post, address_verify_url, options)
12
11
  end
13
12
 
14
13
  def list(options={})
15
- Lob.submit(:get, address_url, options)["data"] || []
14
+ Lob.submit(:get, address_url, options)
16
15
  end
17
16
 
18
17
  def find(address_id)
@@ -20,7 +19,7 @@ module Lob
20
19
  end
21
20
 
22
21
  def create(options = {})
23
- Lob.submit :post, address_url, @resource.format_address_params(options)
22
+ Lob.submit :post, address_url, options
24
23
  end
25
24
 
26
25
  def destroy(address_id)
data/lib/lob/v1/area.rb CHANGED
@@ -6,7 +6,7 @@ module Lob
6
6
  end
7
7
 
8
8
  def list(options = {})
9
- Lob.submit(:get, area_url, options)["data"] || []
9
+ Lob.submit(:get, area_url, options)
10
10
  end
11
11
 
12
12
  def find(lob_object_id)
@@ -7,7 +7,7 @@ module Lob
7
7
  end
8
8
 
9
9
  def list(options={})
10
- Lob.submit(:get, bank_account_url, options)["data"] || []
10
+ Lob.submit(:get, bank_account_url, options)
11
11
  end
12
12
 
13
13
  def find(bank_account_id)
@@ -15,14 +15,6 @@ module Lob
15
15
  end
16
16
 
17
17
  def create(options = {})
18
- if !options[:bank_address].is_a?(String)
19
- options[:bank_address] = @resource.format_address_params(options[:bank_address])
20
- end
21
-
22
- if !options[:account_address].is_a?(String)
23
- options[:account_address] = @resource.format_address_params(options[:account_address])
24
- end
25
-
26
18
  Lob.submit :post, bank_account_url, options
27
19
  end
28
20
 
@@ -30,6 +22,10 @@ module Lob
30
22
  Lob.submit :delete, bank_account_url(bank_account_id)
31
23
  end
32
24
 
25
+ def verify(bank_account_id, options = {})
26
+ Lob.submit :post, "#{bank_account_url(bank_account_id)}/verify", options
27
+ end
28
+
33
29
  private
34
30
 
35
31
  def bank_account_url(bank_account_id = nil)