lob 5.2.0 → 5.4.2
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.
- checksums.yaml +4 -4
- data/.github/workflows/run_tests_job.yml +36 -0
- data/.github/workflows/update_gem.yml +30 -0
- data/CHANGELOG.md +6 -0
- data/README.md +5 -72
- data/examples/README.md +84 -10
- data/examples/checks.rb +4 -3
- data/examples/csv_checks/create_checks.rb +3 -2
- data/examples/csv_letters/create_letters.rb +3 -2
- data/examples/csv_postcards/create_postcards.rb +3 -2
- data/examples/csv_verify/verify.rb +3 -2
- data/examples/letters.rb +3 -2
- data/examples/list_postcards_metadata.rb +94 -0
- data/examples/postcards.rb +5 -4
- data/examples/postcards_idempotent.rb +92 -0
- data/examples/postcards_intl.rb +87 -0
- data/examples/postcards_remote.rb +87 -0
- data/examples/postcards_send_date.rb +97 -0
- data/examples/postcards_template.rb +98 -0
- data/examples/self_mailers.rb +3 -2
- data/lib/lob/client.rb +15 -0
- data/lib/lob/resources/bulk_intl_verifications.rb +26 -0
- data/lib/lob/resources/bulk_us_verifications.rb +27 -0
- data/lib/lob/resources/us_reverse_geocode_lookups.rb +26 -0
- data/lib/lob/version.rb +1 -1
- data/lob.gemspec +4 -2
- data/spec/lob/resources/bulk_intl_verifications_spec.rb +30 -0
- data/spec/lob/resources/bulk_us_verifications_spec.rb +37 -0
- data/spec/lob/resources/us_reverse_geocode_lookups_spec.rb +22 -0
- metadata +53 -9
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b69d606dfce94ccad4b1bb4cb584a7e3d0ac341e4a117775aba88f31123d0de5
|
4
|
+
data.tar.gz: 8c82f0edfbadfaeb5aac1f922107c138349581ca8f7590ec294dd1141a7c7f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5f1f78dedb730277f86ce1d4f74105121d72927e1843de558bfbe89546f5cad7e838d0517348619aef0d62e9d1693058efbd57662cd10a24930385f6d11cdd9
|
7
|
+
data.tar.gz: b5475fe1716dda1aaebe194f2f1c8af7fe4f7a9b4a3e55e8124e057c1d76c6d2434631754dcf7bc801c5129e9598b137acda021e5b796ca4a8442eeb77f7704d
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Run tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [ created, reopened ]
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
jobs:
|
9
|
+
ruby_tests:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby-version: ['jruby-9.2.9.0', '2.6', '2.7', '3.0']
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Setup
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
20
|
+
- name: Install Dependencies
|
21
|
+
run: bundle install
|
22
|
+
- name: Run Tests
|
23
|
+
env:
|
24
|
+
API_KEY: ${{ secrets.API_KEY }}
|
25
|
+
JRUBY_OPT: --2.0
|
26
|
+
run: bundle exec rake test
|
27
|
+
- name: Send coverage to Coveralls
|
28
|
+
uses: coverallsapp/github-action@master
|
29
|
+
with:
|
30
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
publish_gem:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: ['jruby-9.2.9.0', '2.6', '2.7', '3.0']
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Setup
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby-version }}
|
19
|
+
- name: Install Dependencies
|
20
|
+
run: bundle install
|
21
|
+
- name: Publish Gem
|
22
|
+
run: |
|
23
|
+
mkdir -p $HOME/.gem
|
24
|
+
touch $HOME/.gem/credentials
|
25
|
+
chmod 0600 $HOME/.gem/credentials
|
26
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
27
|
+
gem build *.gemspec
|
28
|
+
gem push *.gem
|
29
|
+
env:
|
30
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
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
|
1
7
|
## [**5.2.0**](https://github.com/lob/lob-ruby/releases/tag/v5.2.0) (2021-05-03)
|
2
8
|
- [**188**](https://github.com/lob/lob-ruby/pull/188) Adds support for Self Mailers
|
3
9
|
## 5.1.2 (2021-02-18)
|
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,78 +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
|
-
|
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
|
-
- **Self Mailers API**
|
150
|
-
- [Self Mailers](https://lob.com/docs/ruby#self_mailers)
|
151
|
-
- [The Self Mailer Object](https://lob.com/docs/ruby#self_mailers_object)
|
152
|
-
- [Create a Self Mailer](https://lob.com/docs/ruby#self_mailers_create)
|
153
|
-
- [Retrieve a Self Mailer](https://lob.com/docs/ruby#self_mailers_retrieve)
|
154
|
-
- [Cancel a Self Mailer](https://lob.com/docs/ruby#self_mailers_delete)
|
155
|
-
- [List all Self Mailers](https://lob.com/docs/ruby#self_mailers_list)
|
156
|
-
- **Letters API**
|
157
|
-
- [Letters](https://lob.com/docs/ruby#letters)
|
158
|
-
- [The Letter Object](https://lob.com/docs/ruby#letters_object)
|
159
|
-
- [Create a Letter](https://lob.com/docs/ruby#letters_create)
|
160
|
-
- [Retrieve a Letter](https://lob.com/docs/ruby#letters_retrieve)
|
161
|
-
- [Cancel a Letter](https://lob.com/docs/ruby#letters_delete)
|
162
|
-
- [List all Letters](https://lob.com/docs/ruby#letters_list)
|
163
|
-
- **Checks API**
|
164
|
-
- [Checks](https://lob.com/docs/ruby#checks)
|
165
|
-
- [The Check Object](https://lob.com/docs/ruby#checks_object)
|
166
|
-
- [Create a Check](https://lob.com/docs/ruby#checks_create)
|
167
|
-
- [Retrieve a Check](https://lob.com/docs/ruby#checks_retrieve)
|
168
|
-
- [Cancel a Check](https://lob.com/docs/ruby#checks_delete)
|
169
|
-
- [List all Checks](https://lob.com/docs/ruby#checks_list)
|
170
|
-
- [Bank Accounts](https://lob.com/docs/ruby#bank-accounts)
|
171
|
-
- [The Bank Account Object](https://lob.com/docs/ruby#bankaccounts_object)
|
172
|
-
- [Create a Bank Account](https://lob.com/docs/ruby#bankaccounts_create)
|
173
|
-
- [Retrieve a Bank Account](https://lob.com/docs/ruby#bankaccounts_retrieve)
|
174
|
-
- [Delete a Bank Account](https://lob.com/docs/ruby#bankaccounts_delete)
|
175
|
-
- [Verify a Bank Account](https://lob.com/docs/ruby#bankaccounts_verify)
|
176
|
-
- [List all Bank Accounts](https://lob.com/docs/ruby#bankaccounts_list)
|
177
|
-
- **Appendix**
|
178
|
-
- [API Changelog](https://lob.com/docs/ruby#changelog)
|
179
|
-
- [The Tracking Event Object](https://lob.com/docs/ruby#tracking_event_object)
|
180
|
-
- [Events](https://lob.com/docs/ruby#events)
|
181
|
-
- [HTML Examples](https://lob.com/docs/ruby#html-examples)
|
182
|
-
- [Image Prepping](https://lob.com/docs/ruby#prepping)
|
183
|
-
- [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/).
|
184
117
|
|
185
118
|
## Contributing
|
186
119
|
|
data/examples/README.md
CHANGED
@@ -1,37 +1,111 @@
|
|
1
1
|
# Ruby Examples
|
2
2
|
|
3
|
-
Here we have put together a
|
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. Thank you for using Lob!
|
4
4
|
|
5
|
-
|
5
|
+
To run these example commands, make sure you have a supported version of Ruby installed, including all the necessary gems.
|
6
|
+
|
7
|
+
## [/csv_checks/](./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
|
|
9
|
-
|
11
|
+
```
|
12
|
+
bundle exec ruby examples/csv_checks/create_checks.rb
|
13
|
+
```
|
14
|
+
|
15
|
+
## [/csv_letters/](./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
|
|
13
|
-
|
19
|
+
```
|
20
|
+
bundle exec ruby examples/csv_letters/create_letters.rb
|
21
|
+
```
|
22
|
+
|
23
|
+
## [/csv_postcards/](./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
|
|
17
|
-
|
27
|
+
```
|
28
|
+
bundle exec ruby examples/csv_postcards/create_postcards.rb
|
29
|
+
```
|
30
|
+
|
31
|
+
## [/csv_verify/](./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/
|
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
|
-
## /checks.rb
|
41
|
+
## [/checks.rb](./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
|
|
27
|
-
|
45
|
+
```
|
46
|
+
bundle exec ruby examples/checks.rb
|
47
|
+
```
|
48
|
+
|
49
|
+
## [/letters.rb](./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
|
|
31
|
-
|
53
|
+
```
|
54
|
+
bundle exec ruby examples/letters.rb
|
55
|
+
```
|
56
|
+
|
57
|
+
## [/postcards.rb](./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
|
|
35
|
-
|
61
|
+
```
|
62
|
+
bundle exec ruby examples/postcards.rb
|
63
|
+
```
|
64
|
+
|
65
|
+
## [/postcards_idempotent.rb](./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](./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](./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](./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](./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](./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: '
|
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
|
-
|
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
|
-
|
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: '
|
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
|
-
|
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: '
|
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
|
-
|
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: '
|
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
|
-
|
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: '
|
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: '
|
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
|
-
|
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
|
+
)
|
data/examples/postcards.rb
CHANGED
@@ -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: '
|
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
|
-
|
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
|
+
)
|