lob 5.3.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11eb162180fd2d34bf35f62e3b3e0abdb3319c55d126c0cde0b8653952bc3663
4
- data.tar.gz: 7631ad45c98fdd77acaef477d2ce59f63adad41c4f765f9f738a42808f7d2ba6
3
+ metadata.gz: 6d920a5ff8b4358b54f44f6812d0e38f976c1b248c5a7b9154c3d6eff9226869
4
+ data.tar.gz: b26009d8e3757fbebb1af09028667288481d7acb5afe79b0b7617c096017d7b3
5
5
  SHA512:
6
- metadata.gz: 1ce91dceebe1903673e9b782c5af29012f06c7b8aea44d399b49d7efd06cc5975b336db6c369cea13cab0c160511606ecd85fefdff52fe5f9761bd04bd8e5730
7
- data.tar.gz: 7cc830a0ac6fba54f81352c050b7baa2f732bb50146ac3dcedf5c9fc53b41dd2d1c4b3eed428639f254e25dfd77abd7aca67ae596986a236ff1d153073ad3d67
6
+ metadata.gz: 4f37e760d4b69d4cedcc9226c800807f8a100031a0c27dfc9a3390bf7851fd873f4b597332deec652e4c20ff27cf92d9aa949b7f92c574f6b66cf18373fd92c8
7
+ data.tar.gz: a4af769be0508a03a1f0b87223f07ebdb468971b2374aaaa8de099342d877950c6a25b9c7f92f845214c6586d0d563f7cec0039dafecce70191f3f0fb1ef740c
data/.travis.yml CHANGED
@@ -3,10 +3,9 @@ language: ruby
3
3
  rvm:
4
4
  - jruby-9.1.9.0
5
5
  - jruby-9.2.9.0
6
- - 2.4
7
- - 2.5
8
6
  - 2.6
9
7
  - 2.7
8
+ - 3.0
10
9
  env:
11
10
  JRUBY_OPTS=--2.0
12
11
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [**5.4.0**](https://github.com/lob/lob-ruby/releases/tag/v5.4.0) (2021-09-21)
2
+ - [**192**](https://github.com/lob/lob-ruby/pull/192) updated to 3.0.0
3
+ - [**191**](https://github.com/lob/lob-ruby/pull/191) feat(us_verifications): Reverse Geocoding endpoint
1
4
  ## [**5.3.0**](https://github.com/lob/lob-ruby/releases/tag/v5.3.0) (2021-08-25)
2
5
  - [**190**](https://github.com/lob/lob-ruby/pull/190) Adds support for bulk AV endpoints
3
6
  ## [**5.2.0**](https://github.com/lob/lob-ruby/releases/tag/v5.2.0) (2021-05-03)
data/README.md CHANGED
@@ -11,10 +11,14 @@ Supports Ruby 2.0.0 and greater.
11
11
 
12
12
  ## Table of Contents
13
13
 
14
+ - [Table of Contents](#table-of-contents)
14
15
  - [Getting Started](#getting-started)
15
16
  - [Registration](#registration)
16
17
  - [Installation](#installation)
17
18
  - [Usage](#usage)
19
+ - [Initialization and Configuration](#initialization-and-configuration)
20
+ - [Caution: Pass zero-prefixed zip codes as strings](#caution-pass-zero-prefixed-zip-codes-as-strings)
21
+ - [Accessing Response Headers](#accessing-response-headers)
18
22
  - [Examples](#examples)
19
23
  - [API Documentation](#api-documentation)
20
24
  - [Contributing](#contributing)
data/examples/README.md CHANGED
@@ -1,37 +1,111 @@
1
1
  # Ruby Examples
2
2
 
3
- Here we have put together a hand full of ruby examples to help get you started. Please read through the official [API Documentation](../README.md#api-documentation) to get a complete sense of what to expect from each endpoint. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions on implementation.
3
+ Here we have put together a handful of ruby examples to help get you started. Please read through the official [API Documentation](https://docs.lob.com) to get a complete sense of what to expect from each endpoint. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions on implementation.
4
+
5
+ To run these example commands, make sure you have a supported version of Ruby installed, including all the necessary gems.
4
6
 
5
7
  ## /csv_checks/
6
8
 
7
9
  An example showing how to dynamically create checks from a CSV using HTML, merge variables, and Lob's [Checks API](https://lob.com/services/checks).
8
10
 
11
+ ```
12
+ bundle exec ruby examples/csv_checks/create_checks.rb
13
+ ```
14
+
9
15
  ## /csv_letters/
10
16
 
11
17
  An example showing how to dynamically create letters from a CSV using HTML, a custom font, merge variables, and Lob's [Letters API](https://lob.com/services/letters).
12
18
 
19
+ ```
20
+ bundle exec ruby examples/csv_letters/create_letters.rb
21
+ ```
22
+
13
23
  ## /csv_postcards/
14
24
 
15
25
  An example showing how to dynamically create postcards from a CSV using HTML, a custom font, merge variables, and Lob's [Postcards API](https://lob.com/services/postcards).
16
26
 
27
+ ```
28
+ bundle exec ruby examples/csv_postcards/create_postcards.rb
29
+ ```
30
+
17
31
  ## /csv_verify/
18
32
 
19
33
  An example showing how to validate and cleanse a CSV spreadsheet full of shipping addresses using Lob's [US Verification API](https://lob.com/services/verifications).
20
34
 
21
- Please note that if you are running this with a Test API Key, the verification API will always return [a dummy address](https://lob.com/docs#us_verifications_create).
35
+ Please note that if you are running this with a Test API Key, the verification API will always return [a dummy address](https://docs.lob.com/#section/US-Verifications-Test-Env).
36
+
37
+ ```
38
+ bundle exec ruby examples/csv_verify/verify.rb
39
+ ```
22
40
 
23
41
  ## /checks.rb
24
42
 
25
43
  An example showing how to create a check using Lob's [Checks API](https://lob.com/services/checks).
26
44
 
45
+ ```
46
+ bundle exec ruby examples/checks.rb
47
+ ```
48
+
27
49
  ## /letters.rb
28
50
 
29
51
  An example showing how to create a letter using Lob's [Letters API](https://lob.com/services/letters).
30
52
 
53
+ ```
54
+ bundle exec ruby examples/letters.rb
55
+ ```
56
+
31
57
  ## /postcards.rb
32
58
 
33
59
  An example showing how to create a postcard using Lob's [Postcards API](https://lob.com/services/postcards).
34
60
 
61
+ ```
62
+ bundle exec ruby examples/postcards.rb
63
+ ```
64
+
65
+ ## /postcards_idempotent.rb
66
+
67
+ An example showing how to create an idempotent postcard request using Lob's [Postcards API](https://lob.com/services/postcards).
68
+
69
+ ```
70
+ bundle exec ruby examples/postcards_idempotent.rb
71
+ ```
72
+
73
+ ## /postcards_intl.rb
74
+
75
+ An example showing how to create an international postcard using Lob's [Postcards API](https://lob.com/services/postcards).
76
+
77
+ ```
78
+ bundle exec ruby examples/postcards_intl.rb
79
+ ```
80
+
81
+ ## /postcards_remote.rb
82
+
83
+ An example showing how to create a postcard with remote files, using Lob's [Postcards API](https://lob.com/services/postcards).
84
+
85
+ ```
86
+ bundle exec ruby examples/postcards_remote.rb
87
+ ```
88
+
89
+ ## /postcards_send_date.rb
90
+
91
+ An example showing how to create a postcard with a specified send date, using Lob's [Postcards API](https://lob.com/services/postcards).
92
+
93
+ ```
94
+ bundle exec ruby examples/postcards_send_date.rb
95
+ ```
96
+
97
+ ## /postcards_template.rb
98
+
99
+ An example showing how to create a postcard with a saved template, using Lob's [Postcards API](https://lob.com/services/postcards).
100
+
101
+ ```
102
+ bundle exec ruby examples/postcards_template.rb
103
+ ```
104
+
35
105
  ## /self_mailers.rb
36
106
 
37
107
  An example showing how to create a self mailer using Lob's Self Mailers API.
108
+
109
+ ```
110
+ bundle exec ruby examples/self_mailers.rb
111
+ ```
data/examples/checks.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
+ require 'pp'
3
4
 
4
5
  # initialize Lob object
5
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
6
7
 
7
8
  # create an address
8
9
  to_address = lob.addresses.create(
@@ -32,11 +33,11 @@ bank_account = lob.bank_accounts.create(
32
33
  signatory: "John Doe"
33
34
  )
34
35
 
35
- puts bank_account
36
+ pp bank_account
36
37
  lob.bank_accounts.verify(bank_account['id'], amounts: [23, 12])
37
38
 
38
39
  # send a $100 check using an already created bank and address
39
- puts lob.checks.create(
40
+ pp lob.checks.create(
40
41
  description: "Test Check",
41
42
  check_number: "10000",
42
43
  bank_account: bank_account["id"],
@@ -1,9 +1,10 @@
1
1
  $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
  require 'csv'
4
+ require 'pp'
4
5
 
5
6
  # Initialize Lob object
6
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
7
8
 
8
9
  # Create a bank account
9
10
  bank_account = lob.bank_accounts.create(
@@ -43,5 +44,5 @@ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
43
44
  amount: row[7],
44
45
  memo: "For travel reimbursement"
45
46
  )
46
- puts check['url']
47
+ pp check['url']
47
48
  end
@@ -1,9 +1,10 @@
1
1
  $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
  require 'csv'
4
+ require 'pp'
4
5
 
5
6
  # Initialize Lob object
6
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
7
8
 
8
9
  # Load the HTML from letter_template.html
9
10
  letter_html = File.open(File.expand_path('../letter_template.html', __FILE__)).read
@@ -36,5 +37,5 @@ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
36
37
  },
37
38
  color: false
38
39
  )
39
- puts letter['url']
40
+ pp letter['url']
40
41
  end
@@ -1,9 +1,10 @@
1
1
  $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
  require 'csv'
4
+ require 'pp'
4
5
 
5
6
  # Initialize Lob object
6
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
7
8
 
8
9
  # Load the HTML from postcard_front.html and postcard_back.html.
9
10
  front_html = File.open(File.expand_path('../postcard_front.html', __FILE__)).read
@@ -41,5 +42,5 @@ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
41
42
  mileage: row[4]
42
43
  }
43
44
  )
44
- puts postcard['url']
45
+ pp postcard['url']
45
46
  end
@@ -2,9 +2,10 @@ $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
2
 
3
3
  require 'csv'
4
4
  require 'lob'
5
+ require 'pp'
5
6
 
6
7
  # Initialize Lob object
7
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
8
+ lob = Lob::Client.new(api_key: 'live_ef27c53a56d2b1a4f6cff194f98eae91175')
8
9
 
9
10
  output = File.open(File.expand_path('../output.csv', __FILE__), 'w')
10
11
 
@@ -22,7 +23,7 @@ File.open(File.expand_path('../input.csv', __FILE__)).each_line do |line|
22
23
  state: address_components[4],
23
24
  zip_code: address_components[5]
24
25
  )
25
-
26
+
26
27
  output.puts [
27
28
  verified_address['primary_line'],
28
29
  verified_address['secondary_line'],
data/examples/letters.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
+ require 'pp'
3
4
 
4
5
  # initialize Lob object
5
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
6
7
 
7
8
  html = %{
8
9
  <html>
@@ -61,7 +62,7 @@ from_address = lob.addresses.create(
61
62
  )
62
63
 
63
64
  # send the letter
64
- puts lob.letters.create(
65
+ pp lob.letters.create(
65
66
  description: "Test letter",
66
67
  to: to_address["id"],
67
68
  from: from_address["id"],
@@ -0,0 +1,94 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob.rb'
3
+ require 'pp'
4
+
5
+ # initialize Lob object
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
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/public.lob.com/fonts/lovedByTheKing/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/public.lob.com/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
+ # create a to address
59
+ to_address = lob.addresses.create(
60
+ name: "ToAddress",
61
+ address_line1: "120 6th Ave",
62
+ address_city: "Boston",
63
+ address_state: "MA",
64
+ address_country: "US",
65
+ address_zip: 12345
66
+ )
67
+
68
+ # create a from address
69
+ from_address = lob.addresses.create(
70
+ name: "FromAddress",
71
+ address_line1: "120 6th Ave",
72
+ address_city: "Boston",
73
+ address_state: "MA",
74
+ address_country: "US",
75
+ address_zip: 12345
76
+ )
77
+
78
+ # send a postcard
79
+ pp lob.postcards.create(
80
+ description: "Beach Postcard",
81
+ to: to_address["id"],
82
+ from: from_address["id"],
83
+ metadata: { campaign: "Summer 2015 Beach" },
84
+ merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
85
+ front: html,
86
+ back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>"
87
+ )
88
+
89
+ pp lob.postcards.list(
90
+ metadata: {
91
+ campaign: 'Summer 2015 Beach'
92
+ },
93
+ limit: 1
94
+ )
@@ -1,8 +1,9 @@
1
1
  $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
- require 'lob'
2
+ require 'lob.rb'
3
+ require 'pp'
3
4
 
4
5
  # initialize Lob object
5
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
6
7
 
7
8
  # HTML to send to the server
8
9
  html = %{
@@ -29,7 +30,7 @@ html = %{
29
30
  margin: 0;
30
31
  padding: 0;
31
32
  /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
32
- background-image: url(https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg);
33
+ background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
33
34
  background-size: 6.25in 4.25in;
34
35
  background-repeat: no-repeat;
35
36
  }
@@ -75,7 +76,7 @@ from_address = lob.addresses.create(
75
76
  )
76
77
 
77
78
  # send a postcard
78
- puts lob.postcards.create(
79
+ pp lob.postcards.create(
79
80
  description: "Beach Postcard",
80
81
  to: to_address["id"],
81
82
  from: from_address["id"],
@@ -0,0 +1,92 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob.rb'
3
+ require 'pp'
4
+
5
+ # initialize Lob object
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
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/public.lob.com/fonts/lovedByTheKing/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/public.lob.com/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
+ # create a to address
59
+ to_address = lob.addresses.create(
60
+ name: "ToAddress",
61
+ address_line1: "120 6th Ave",
62
+ address_city: "Boston",
63
+ address_state: "MA",
64
+ address_country: "US",
65
+ address_zip: 12345
66
+ )
67
+
68
+ # create a from address
69
+ from_address = lob.addresses.create(
70
+ name: "FromAddress",
71
+ address_line1: "120 6th Ave",
72
+ address_city: "Boston",
73
+ address_state: "MA",
74
+ address_country: "US",
75
+ address_zip: 12345
76
+ )
77
+
78
+ # send a postcard
79
+ pp lob.postcards.create(
80
+ {
81
+ description: "Beach Postcard",
82
+ to: to_address["id"],
83
+ from: from_address["id"],
84
+ metadata: { campaign: "Summer 2015 Beach" },
85
+ merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
86
+ front: html,
87
+ back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>"
88
+ },
89
+ {
90
+ 'Idempotency-Key': '026e7634-24d7-486c-a0bb-4a17fd0eebc5'
91
+ }
92
+ )
@@ -0,0 +1,87 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob'
3
+ require 'pp'
4
+
5
+ # initialize Lob object
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
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/public.lob.com/fonts/lovedByTheKing/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/public.lob.com/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
+ # create a to address
59
+ to_address = lob.addresses.create(
60
+ name: "ToAddress",
61
+ address_line1: "370 Water St",
62
+ address_city: "Summerside",
63
+ address_state: "Prince Edward Island",
64
+ address_country: "CA",
65
+ address_zip: "C1N 1C4"
66
+ )
67
+
68
+ # create a from address
69
+ from_address = lob.addresses.create(
70
+ name: "FromAddress",
71
+ address_line1: "120 6th Ave",
72
+ address_city: "Boston",
73
+ address_state: "MA",
74
+ address_country: "US",
75
+ address_zip: 12345
76
+ )
77
+
78
+ # send a postcard
79
+ pp lob.postcards.create(
80
+ description: "Beach Postcard",
81
+ to: to_address["id"],
82
+ from: from_address["id"],
83
+ metadata: { campaign: "Summer 2015 Beach" },
84
+ merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
85
+ front: html,
86
+ back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>"
87
+ )
@@ -0,0 +1,87 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob.rb'
3
+ require 'pp'
4
+
5
+ # initialize Lob object
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
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/public.lob.com/fonts/lovedByTheKing/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/public.lob.com/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
+ # create a to address
59
+ to_address = lob.addresses.create(
60
+ name: "ToAddress",
61
+ address_line1: "120 6th Ave",
62
+ address_city: "Boston",
63
+ address_state: "MA",
64
+ address_country: "US",
65
+ address_zip: 12345
66
+ )
67
+
68
+ # create a from address
69
+ from_address = lob.addresses.create(
70
+ name: "FromAddress",
71
+ address_line1: "120 6th Ave",
72
+ address_city: "Boston",
73
+ address_state: "MA",
74
+ address_country: "US",
75
+ address_zip: 12345
76
+ )
77
+
78
+ # send a postcard
79
+ pp lob.postcards.create(
80
+ description: "Beach Postcard",
81
+ to: to_address["id"],
82
+ from: from_address["id"],
83
+ metadata: { campaign: "Summer 2015 Beach" },
84
+ merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
85
+ front: 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf',
86
+ back: 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf'
87
+ )
@@ -0,0 +1,97 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob.rb'
3
+ require 'pp'
4
+ require 'date'
5
+
6
+ # initialize Lob object
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
8
+
9
+ # HTML to send to the server
10
+ html = %{
11
+ <html>
12
+ <head>
13
+ <title>Lob.com Sample 4x6 Postcard Front</title>
14
+ <style>
15
+ *, *:before, *:after {
16
+ -webkit-box-sizing: border-box;
17
+ -moz-box-sizing: border-box;
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ @font-face {
22
+ font-family: 'Loved by the King';
23
+ font-style: normal;
24
+ font-weight: 400;
25
+ src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
26
+ }
27
+
28
+ body {
29
+ width: 6.25in;
30
+ height: 4.25in;
31
+ margin: 0;
32
+ padding: 0;
33
+ /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
34
+ background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
35
+ background-size: 6.25in 4.25in;
36
+ background-repeat: no-repeat;
37
+ }
38
+
39
+ .text {
40
+ margin: 50px;
41
+ width: 400px;
42
+ font-family: 'Loved by the King';
43
+ font-size: 50px;
44
+ font-weight: 700;
45
+ color: white;
46
+ text-shadow: 3px 3px black;
47
+ }
48
+ </style>
49
+ </head>
50
+
51
+ <body>
52
+ <h1 class="text">Hello {{name}}!</h1>
53
+ <p class="text">Join us for the {{event}}!</p>
54
+ </body>
55
+
56
+ </html>
57
+ }
58
+
59
+ # create a to address
60
+ to_address = lob.addresses.create(
61
+ name: "ToAddress",
62
+ address_line1: "120 6th Ave",
63
+ address_city: "Boston",
64
+ address_state: "MA",
65
+ address_country: "US",
66
+ address_zip: 12345
67
+ )
68
+
69
+ # create a from address
70
+ from_address = lob.addresses.create(
71
+ name: "FromAddress",
72
+ address_line1: "120 6th Ave",
73
+ address_city: "Boston",
74
+ address_state: "MA",
75
+ address_country: "US",
76
+ address_zip: 12345
77
+ )
78
+
79
+ def get_date()
80
+ time = Time.new
81
+ if time.month == 12
82
+ return "#{time.year + 1}-01-#{time.day}"
83
+ else
84
+ return "#{time.year}-#{time.month + 1}-#{time.day}"
85
+ end
86
+ end
87
+
88
+ pp lob.postcards.create(
89
+ description: "Beach Postcard",
90
+ to: to_address["id"],
91
+ from: from_address["id"],
92
+ metadata: { campaign: "Summer 2015 Beach" },
93
+ merge_variables: { name: "Albert", event: "Summer 2015 Beach-athon" },
94
+ front: html,
95
+ back: "<h1>Please RSVP as soon as possible to reserve your lounge chair.</h1>",
96
+ send_date: get_date()
97
+ )
@@ -0,0 +1,98 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob.rb'
3
+ require 'pp'
4
+
5
+ # initialize Lob object
6
+ # this key is publicly available in the legacy docs, so it's hardcoded
7
+ # since the templates are associated with this dummy account
8
+ # you can replace this key with your own, and the IDs below with any
9
+ # saved templates you have
10
+ lob = Lob::Client.new(api_key: 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc')
11
+
12
+ # HTML to send to the server
13
+ html = %{
14
+ <html>
15
+ <head>
16
+ <title>Lob.com Sample 4x6 Postcard Front</title>
17
+ <style>
18
+ *, *:before, *:after {
19
+ -webkit-box-sizing: border-box;
20
+ -moz-box-sizing: border-box;
21
+ box-sizing: border-box;
22
+ }
23
+
24
+ @font-face {
25
+ font-family: 'Loved by the King';
26
+ font-style: normal;
27
+ font-weight: 400;
28
+ src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
29
+ }
30
+
31
+ body {
32
+ width: 6.25in;
33
+ height: 4.25in;
34
+ margin: 0;
35
+ padding: 0;
36
+ /* If using an image, the background image should have dimensions of 1875x1275 pixels. */
37
+ background-image: url('https://s3-us-west-2.amazonaws.com/public.lob.com/assets/beach.jpg');
38
+ background-size: 6.25in 4.25in;
39
+ background-repeat: no-repeat;
40
+ }
41
+
42
+ .text {
43
+ margin: 50px;
44
+ width: 400px;
45
+ font-family: 'Loved by the King';
46
+ font-size: 50px;
47
+ font-weight: 700;
48
+ color: white;
49
+ text-shadow: 3px 3px black;
50
+ }
51
+ </style>
52
+ </head>
53
+
54
+ <body>
55
+ <h1 class="text">Hello {{name}}!</h1>
56
+ <p class="text">Join us for the {{event}}!</p>
57
+ </body>
58
+
59
+ </html>
60
+ }
61
+
62
+ # create a to address
63
+ to_address = lob.addresses.create(
64
+ {
65
+ "name": "ToAddress",
66
+ "address_line1": "120 6th Ave",
67
+ "address_city": "Boston",
68
+ "address_state": "MA",
69
+ "address_country": "US",
70
+ "address_zip": 12345
71
+ }
72
+ )
73
+
74
+ # create a from address
75
+ from_address = lob.addresses.create(
76
+ {
77
+ "name": "FromAddress",
78
+ "address_line1": "120 6th Ave",
79
+ "address_city": "Boston",
80
+ "address_state": "MA",
81
+ "address_country": "US",
82
+ "address_zip": 12345
83
+ }
84
+ )
85
+
86
+ # send a postcard
87
+ pp lob.postcards.create(
88
+ {
89
+ "description": "Beach Postcard",
90
+ "to": to_address["id"],
91
+ "from": from_address["id"],
92
+ "metadata": { campaign: "Summer 2015 Beach" },
93
+ "merge_variables": { name: "Albert", event: "Summer 2015 Beach-athon" },
94
+ # you can replace these template IDs
95
+ "front": 'tmpl_b846a20859ae11a',
96
+ "back": 'tmpl_01b0d396a10c268'
97
+ }
98
+ )
@@ -1,8 +1,9 @@
1
1
  $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
+ require 'pp'
3
4
 
4
5
  # initialize Lob object
5
- lob = Lob::Client.new(api_key: 'YOUR_API_KEY_HERE')
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
6
7
 
7
8
  # create a to address
8
9
  to_address = lob.addresses.create(
@@ -26,7 +27,7 @@ from_address = lob.addresses.create(
26
27
 
27
28
 
28
29
  # send a self mailer
29
- puts lob.self_mailers.create(
30
+ pp lob.self_mailers.create(
30
31
  description: "Beach Postcard",
31
32
  to: to_address["id"],
32
33
  from: from_address["id"],
data/lib/lob/client.rb CHANGED
@@ -10,6 +10,7 @@ require "lob/resources/letter"
10
10
  require "lob/resources/postcard"
11
11
  require "lob/resources/self_mailer"
12
12
  require "lob/resources/us_autocompletions"
13
+ require "lob/resources/us_reverse_geocode_lookups"
13
14
  require "lob/resources/us_verifications"
14
15
  require "lob/resources/us_zip_lookups"
15
16
 
@@ -74,6 +75,10 @@ module Lob
74
75
  Lob::Resources::USAutocompletions.new(config)
75
76
  end
76
77
 
78
+ def us_reverse_geocode_lookups
79
+ Lob::Resources::USReverseGeocodeLookups.new(config)
80
+ end
81
+
77
82
  def us_verifications
78
83
  Lob::Resources::USVerifications.new(config)
79
84
  end
@@ -0,0 +1,26 @@
1
+ require "lob/resources/resource_base"
2
+
3
+ module Lob
4
+ module Resources
5
+ class USReverseGeocodeLookups < Lob::Resources::ResourceBase
6
+
7
+ undef_method :list, :find, :create, :destroy
8
+
9
+ def initialize(config)
10
+ super(config)
11
+ @endpoint = "us_reverse_geocode_lookups"
12
+ end
13
+
14
+ def lookup(body={})
15
+ request = {
16
+ method: :post,
17
+ url: endpoint_url,
18
+ body: body
19
+ }
20
+
21
+ submit request
22
+ end
23
+
24
+ end
25
+ end
26
+ end
data/lib/lob/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lob
2
- VERSION = "5.3.0"
2
+ VERSION = "5.4.0"
3
3
  end
data/lob.gemspec CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~> 12.3.3"
24
24
  spec.add_development_dependency "minitest", "~> 5.6.1"
25
25
  spec.add_development_dependency "webmock", "~> 1.2"
26
- spec.add_development_dependency "coveralls", "~> 0.8.13"
27
- spec.add_development_dependency "simplecov", "~> 0.11.0"
26
+ spec.add_development_dependency "coveralls", "~> 0.8.23"
27
+ spec.add_development_dependency "simplecov", "~> 0.16.1"
28
+ spec.add_development_dependency "json", "~> 2.3.1"
29
+ spec.add_development_dependency "uri", "~> 0.10.1"
28
30
  end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Lob::Resources::USReverseGeocodeLookups do
4
+
5
+ before :each do
6
+ @sample_params = {
7
+ latitude: 37.777456,
8
+ longitude: -122.393039
9
+ }
10
+ end
11
+
12
+ subject { Lob::Client.new(api_key: API_KEY) }
13
+
14
+ describe "lookup" do
15
+ it "should reverse geocode a valid US location" do
16
+ result = subject.us_reverse_geocode_lookups.lookup @sample_params
17
+ puts result["addresses"][0]["components"]["zip_code"].class
18
+ result["addresses"].length.must_equal(5)
19
+ end
20
+ end
21
+
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lob
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-25 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -78,28 +78,56 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.8.13
81
+ version: 0.8.23
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 0.8.13
88
+ version: 0.8.23
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: simplecov
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 0.11.0
95
+ version: 0.16.1
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.11.0
102
+ version: 0.16.1
103
+ - !ruby/object:Gem::Dependency
104
+ name: json
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 2.3.1
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 2.3.1
117
+ - !ruby/object:Gem::Dependency
118
+ name: uri
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 0.10.1
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.10.1
103
131
  description: Lob API Ruby wrapper
104
132
  email:
105
133
  - support@lob.com
@@ -129,7 +157,13 @@ files:
129
157
  - examples/csv_verify/input.csv
130
158
  - examples/csv_verify/verify.rb
131
159
  - examples/letters.rb
160
+ - examples/list_postcards_metadata.rb
132
161
  - examples/postcards.rb
162
+ - examples/postcards_idempotent.rb
163
+ - examples/postcards_intl.rb
164
+ - examples/postcards_remote.rb
165
+ - examples/postcards_send_date.rb
166
+ - examples/postcards_template.rb
133
167
  - examples/self_mailers.rb
134
168
  - lib/lob.rb
135
169
  - lib/lob/client.rb
@@ -148,6 +182,7 @@ files:
148
182
  - lib/lob/resources/resource_base.rb
149
183
  - lib/lob/resources/self_mailer.rb
150
184
  - lib/lob/resources/us_autocompletions.rb
185
+ - lib/lob/resources/us_reverse_geocode_lookups.rb
151
186
  - lib/lob/resources/us_verifications.rb
152
187
  - lib/lob/resources/us_zip_lookups.rb
153
188
  - lib/lob/version.rb
@@ -166,6 +201,7 @@ files:
166
201
  - spec/lob/resources/resource_base_spec.rb
167
202
  - spec/lob/resources/self_mailer_spec.rb
168
203
  - spec/lob/resources/us_autocompletions_spec.rb
204
+ - spec/lob/resources/us_reverse_geocode_lookups_spec.rb
169
205
  - spec/lob/resources/us_verifications_spec.rb
170
206
  - spec/lob/resources/us_zip_lookups_spec.rb
171
207
  - spec/lob_spec.rb
@@ -215,6 +251,7 @@ test_files:
215
251
  - spec/lob/resources/resource_base_spec.rb
216
252
  - spec/lob/resources/self_mailer_spec.rb
217
253
  - spec/lob/resources/us_autocompletions_spec.rb
254
+ - spec/lob/resources/us_reverse_geocode_lookups_spec.rb
218
255
  - spec/lob/resources/us_verifications_spec.rb
219
256
  - spec/lob/resources/us_zip_lookups_spec.rb
220
257
  - spec/lob_spec.rb