lob 5.1.2 → 5.4.1

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: 13cf985be48a2293b60d39581618b3ec1d6dd55627060e4276e0219839707dda
4
- data.tar.gz: 0d157d5f90ab10bfae3a58959be1478adcac54606e37dbecaf8c8b8fabf6dacb
3
+ metadata.gz: cba07a0c8f145a8df9e935499f91a0dd6d1554f97b9ba8479b2fcd4ccaa5d3b9
4
+ data.tar.gz: 8d48e11c13ba9a5d611a161ad6c9d78a315464f610910ec71f553cd365ccf0b9
5
5
  SHA512:
6
- metadata.gz: 910a721a953d8bf7a714b71e8ab47dfecd7ab294055cd57b1736f2f84aa3d71ed8b54693a9f09112c0b991f6489b23437005dc4ae146a0aff9ecb38cd2121ffc
7
- data.tar.gz: 922c3a7b56174b13a390e7294dd3421ec9eb1305eadbdeccddf007e544ac000e8844b82d5183c5f7c9832dd8c8a4b72b735b0b141f831a95ff0280af81b3bffa
6
+ metadata.gz: 010dd2a65e955352fec5e191c306e980a29ab40cb45b41b557c47e27edf9dad1f0e63067fc2758a9366163ed36f16d426f2ca1bebe8088be2bbc86deeee334bc
7
+ data.tar.gz: 49d65f5c597defa7a3989c6888869e12870736724970598c44c4e6460775f48ab0340d32e41dbf87c8c0a4f32d0fac2a7bc4feef45eee591ed0a21c295c7d31b
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,9 +1,17 @@
1
- #### 5.1.2 (2021-02-18)
1
+ ## [**5.4.1**](https://github.com/lob/lob-ruby/releases/tag/v5.4.1) (2021-09-28)
2
+ - [**193**](https://github.com/lob/lob-ruby/pull/193) Minor patches
3
+ ## [**5.4.0**](https://github.com/lob/lob-ruby/releases/tag/v5.4.0) (2021-09-21)
4
+ - [**191**](https://github.com/lob/lob-ruby/pull/191) Add support for reverse geocoding endpoint
5
+ ## [**5.3.0**](https://github.com/lob/lob-ruby/releases/tag/v5.3.0) (2021-08-25)
6
+ - [**190**](https://github.com/lob/lob-ruby/pull/190) Adds support for bulk AV endpoints
7
+ ## [**5.2.0**](https://github.com/lob/lob-ruby/releases/tag/v5.2.0) (2021-05-03)
8
+ - [**188**](https://github.com/lob/lob-ruby/pull/188) Adds support for Self Mailers
9
+ ## 5.1.2 (2021-02-18)
2
10
 
3
11
  ##### Chores and Bug Fixes
4
12
 
5
- -[**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.
6
- #### 5.1.1 (2020-05-21)
13
+ - [**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.
14
+ ## 5.1.1 (2020-05-21)
7
15
 
8
16
  ##### Chores
9
17
 
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)
@@ -109,71 +113,7 @@ There are simple scripts to demonstrate how to create all the core Lob objects (
109
113
 
110
114
  ## API Documentation
111
115
 
112
- - [Introduction](https://lob.com/docs/ruby#introduction)
113
- - [Versioning](https://lob.com/docs/ruby#version)
114
- - [Errors](https://lob.com/docs/ruby#errors)
115
- - [Rate Limiting](https://lob.com/docs/ruby#rate-limits)
116
- - [Webhooks](https://lob.com/docs/ruby#webhooks)
117
- - [Cancellation Windows](https://lob.com/docs/ruby#cancellation)
118
- - [Scheduled Mailings](https://lob.com/docs/ruby#scheduled)
119
- - [Metadata](https://lob.com/docs/ruby#metadata)
120
- - [HTML Templates](https://lob.com/docs/ruby#templates)
121
- - [Asset URLs](https://lob.com/docs/ruby#urls)
122
- - **Addresses**
123
- - [Address Book](https://lob.com/docs/ruby#addresses)
124
- - [The Address Object](https://lob.com/docs/ruby#addresses_object)
125
- - [Create an Address](https://lob.com/docs/ruby#addresses_create)
126
- - [Retrieve an Address](https://lob.com/docs/ruby#addresses_retrieve)
127
- - [Delete an Address](https://lob.com/docs/ruby#addresses_delete)
128
- - [List all Addresses](https://lob.com/docs/ruby#addresses_list)
129
- - **US Verification API**
130
- - [US Verification API](https://lob.com/docs/ruby#us_verifications)
131
- - [The US Verification Object](https://lob.com/docs/ruby#us_verifications_object)
132
- - [Verify a US Address](https://lob.com/docs/ruby#us_verifications_create)
133
- - [The US Zip Lookup Object](https://lob.com/docs/ruby#us_zip_lookups_object)
134
- - [Lookup a US Zip Code](https://lob.com/docs/ruby#us_zip_lookups_create)
135
- - [US Autocompletion API](https://lob.com/docs/ruby#us_autocompletions)
136
- - [The US Autocompletion Object](https://lob.com/docs/ruby#us_autocompletions_object)
137
- - [Autocomplete a US Address](https://lob.com/docs/ruby#us_autocompletions_create)
138
- - [The US Autocompletion Test Environment](https://lob.com/docs/ruby#us-autocompletions-test-environment)
139
- - **Int'l Verification API**
140
- - [International Verifications](https://lob.com/docs/ruby#intl_verifications)
141
- - [Verify an International Address](https://lob.com/docs/ruby#intl_verifications_create)
142
- - **Postcards API**
143
- - [Postcards](https://lob.com/docs/ruby#postcards)
144
- - [The Postcard Object](https://lob.com/docs/ruby#postcards_object)
145
- - [Create a Postcard](https://lob.com/docs/ruby#postcards_create)
146
- - [Retrieve a Postcard](https://lob.com/docs/ruby#postcards_retrieve)
147
- - [Cancel a Postcard](https://lob.com/docs/ruby#postcards_delete)
148
- - [List all Postcards](https://lob.com/docs/ruby#postcards_list)
149
- - **Letters API**
150
- - [Letters](https://lob.com/docs/ruby#letters)
151
- - [The Letter Object](https://lob.com/docs/ruby#letters_object)
152
- - [Create a Letter](https://lob.com/docs/ruby#letters_create)
153
- - [Retrieve a Letter](https://lob.com/docs/ruby#letters_retrieve)
154
- - [Cancel a Letter](https://lob.com/docs/ruby#letters_delete)
155
- - [List all Letters](https://lob.com/docs/ruby#letters_list)
156
- - **Checks API**
157
- - [Checks](https://lob.com/docs/ruby#checks)
158
- - [The Check Object](https://lob.com/docs/ruby#checks_object)
159
- - [Create a Check](https://lob.com/docs/ruby#checks_create)
160
- - [Retrieve a Check](https://lob.com/docs/ruby#checks_retrieve)
161
- - [Cancel a Check](https://lob.com/docs/ruby#checks_delete)
162
- - [List all Checks](https://lob.com/docs/ruby#checks_list)
163
- - [Bank Accounts](https://lob.com/docs/ruby#bank-accounts)
164
- - [The Bank Account Object](https://lob.com/docs/ruby#bankaccounts_object)
165
- - [Create a Bank Account](https://lob.com/docs/ruby#bankaccounts_create)
166
- - [Retrieve a Bank Account](https://lob.com/docs/ruby#bankaccounts_retrieve)
167
- - [Delete a Bank Account](https://lob.com/docs/ruby#bankaccounts_delete)
168
- - [Verify a Bank Account](https://lob.com/docs/ruby#bankaccounts_verify)
169
- - [List all Bank Accounts](https://lob.com/docs/ruby#bankaccounts_list)
170
- - **Appendix**
171
- - [API Changelog](https://lob.com/docs/ruby#changelog)
172
- - [The Tracking Event Object](https://lob.com/docs/ruby#tracking_event_object)
173
- - [Events](https://lob.com/docs/ruby#events)
174
- - [HTML Examples](https://lob.com/docs/ruby#html-examples)
175
- - [Image Prepping](https://lob.com/docs/ruby#prepping)
176
- - [US Verification Details](https://lob.com/docs/ruby#us_verification_details)
116
+ The full and comprehensive documentation of Lob's APIs is available [here](https://docs.lob.com/).
177
117
 
178
118
  ## Contributing
179
119
 
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: 'YOUR_API_KEY')
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
+ )