lob 5.1.1 → 5.4.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 (40) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +2 -3
  3. data/CHANGELOG.md +13 -1
  4. data/README.md +13 -0
  5. data/examples/README.md +80 -2
  6. data/examples/checks.rb +4 -3
  7. data/examples/csv_checks/create_checks.rb +3 -2
  8. data/examples/csv_letters/create_letters.rb +3 -2
  9. data/examples/csv_postcards/create_postcards.rb +3 -2
  10. data/examples/csv_verify/verify.rb +3 -2
  11. data/examples/letters.rb +3 -2
  12. data/examples/list_postcards_metadata.rb +94 -0
  13. data/examples/postcards.rb +5 -4
  14. data/examples/postcards_idempotent.rb +92 -0
  15. data/examples/postcards_intl.rb +87 -0
  16. data/examples/postcards_remote.rb +87 -0
  17. data/examples/postcards_send_date.rb +97 -0
  18. data/examples/postcards_template.rb +98 -0
  19. data/examples/self_mailers.rb +38 -0
  20. data/lib/lob/client.rb +20 -0
  21. data/lib/lob/resources/bulk_intl_verifications.rb +26 -0
  22. data/lib/lob/resources/bulk_us_verifications.rb +27 -0
  23. data/lib/lob/resources/resource_base.rb +5 -5
  24. data/lib/lob/resources/self_mailer.rb +14 -0
  25. data/lib/lob/resources/us_reverse_geocode_lookups.rb +26 -0
  26. data/lib/lob/version.rb +1 -1
  27. data/lob.gemspec +5 -3
  28. data/spec/lob/resources/bulk_intl_verifications_spec.rb +30 -0
  29. data/spec/lob/resources/bulk_us_verifications_spec.rb +37 -0
  30. data/spec/lob/resources/letter_spec.rb +1 -1
  31. data/spec/lob/resources/postcard_spec.rb +6 -6
  32. data/spec/lob/resources/resource_base_spec.rb +2 -2
  33. data/spec/lob/resources/self_mailer_spec.rb +177 -0
  34. data/spec/lob/resources/us_reverse_geocode_lookups_spec.rb +22 -0
  35. data/spec/samples/sfm-12x9-inside.pdf +0 -0
  36. data/spec/samples/sfm-12x9-outside.pdf +0 -0
  37. data/spec/samples/sfm-6x18-inside.pdf +0 -0
  38. data/spec/samples/sfm-6x18-outside.pdf +0 -0
  39. data/spec/spec_helper.rb +2 -2
  40. metadata +64 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 47d2c198be9a0a184ee2dce528a17019598aa1a8
4
- data.tar.gz: 56d0ba7f17dc902a89409c7229c3de2a9f5859b2
2
+ SHA256:
3
+ metadata.gz: 6d920a5ff8b4358b54f44f6812d0e38f976c1b248c5a7b9154c3d6eff9226869
4
+ data.tar.gz: b26009d8e3757fbebb1af09028667288481d7acb5afe79b0b7617c096017d7b3
5
5
  SHA512:
6
- metadata.gz: 4c4acfe6abfa733ed7d417514303433006d3fa9719ca1ff190661e3d9f911e21e044ca536d4da0cb7a5807f629fb34994e31541a6c31bfc3a018b7c748a4bfdd
7
- data.tar.gz: a84371070b0a83fbf9101a12803bc9e300c3aca145d7b432c16d63b5dcc1effb6219e8bdca9e21f454c09ad6b1aeb44bd409d4c17a2e83be374e719923478d33
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,4 +1,16 @@
1
- #### 5.1.1 (2020-05-21)
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
4
+ ## [**5.3.0**](https://github.com/lob/lob-ruby/releases/tag/v5.3.0) (2021-08-25)
5
+ - [**190**](https://github.com/lob/lob-ruby/pull/190) Adds support for bulk AV endpoints
6
+ ## [**5.2.0**](https://github.com/lob/lob-ruby/releases/tag/v5.2.0) (2021-05-03)
7
+ - [**188**](https://github.com/lob/lob-ruby/pull/188) Adds support for Self Mailers
8
+ ## 5.1.2 (2021-02-18)
9
+
10
+ ##### Chores and Bug Fixes
11
+
12
+ - [**185**](https://github.com/lob/lob-ruby/pull/185) Bumps rake to 12.3.3, adds Ruby 2.7, update example asset links, other cleanup.
13
+ ## 5.1.1 (2020-05-21)
2
14
 
3
15
  ##### Chores
4
16
 
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)
@@ -130,6 +134,7 @@ There are simple scripts to demonstrate how to create all the core Lob objects (
130
134
  - [US Verification API](https://lob.com/docs/ruby#us_verifications)
131
135
  - [The US Verification Object](https://lob.com/docs/ruby#us_verifications_object)
132
136
  - [Verify a US Address](https://lob.com/docs/ruby#us_verifications_create)
137
+ - [Bulk Verify US Addresses](https://lob.com/docs/ruby#bulk_us_verifications_create)
133
138
  - [The US Zip Lookup Object](https://lob.com/docs/ruby#us_zip_lookups_object)
134
139
  - [Lookup a US Zip Code](https://lob.com/docs/ruby#us_zip_lookups_create)
135
140
  - [US Autocompletion API](https://lob.com/docs/ruby#us_autocompletions)
@@ -139,6 +144,7 @@ There are simple scripts to demonstrate how to create all the core Lob objects (
139
144
  - **Int'l Verification API**
140
145
  - [International Verifications](https://lob.com/docs/ruby#intl_verifications)
141
146
  - [Verify an International Address](https://lob.com/docs/ruby#intl_verifications_create)
147
+ - [Bulk Verify International Addresses](https://lob.com/docs/ruby#bulk_intl_verifications_create)
142
148
  - **Postcards API**
143
149
  - [Postcards](https://lob.com/docs/ruby#postcards)
144
150
  - [The Postcard Object](https://lob.com/docs/ruby#postcards_object)
@@ -146,6 +152,13 @@ There are simple scripts to demonstrate how to create all the core Lob objects (
146
152
  - [Retrieve a Postcard](https://lob.com/docs/ruby#postcards_retrieve)
147
153
  - [Cancel a Postcard](https://lob.com/docs/ruby#postcards_delete)
148
154
  - [List all Postcards](https://lob.com/docs/ruby#postcards_list)
155
+ - **Self Mailers API**
156
+ - [Self Mailers](https://lob.com/docs/ruby#self_mailers)
157
+ - [The Self Mailer Object](https://lob.com/docs/ruby#self_mailers_object)
158
+ - [Create a Self Mailer](https://lob.com/docs/ruby#self_mailers_create)
159
+ - [Retrieve a Self Mailer](https://lob.com/docs/ruby#self_mailers_retrieve)
160
+ - [Cancel a Self Mailer](https://lob.com/docs/ruby#self_mailers_delete)
161
+ - [List all Self Mailers](https://lob.com/docs/ruby#self_mailers_list)
149
162
  - **Letters API**
150
163
  - [Letters](https://lob.com/docs/ruby#letters)
151
164
  - [The Letter Object](https://lob.com/docs/ruby#letters_object)
data/examples/README.md CHANGED
@@ -1,33 +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).
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
+
105
+ ## /self_mailers.rb
106
+
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
+ )