lob 5.3.0 → 5.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/run_tests_job.yml +36 -0
- data/.github/workflows/update_gem.yml +30 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +5 -74
- 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 +5 -0
- data/lib/lob/resources/resource_base.rb +15 -9
- 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/us_reverse_geocode_lookups_spec.rb +22 -0
- metadata +46 -8
- 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: d19b8b1eb88e0bc6131dae90d56a11e91957234bebdf9f94dfe63bfcb7547925
|
4
|
+
data.tar.gz: '05677558cc8a02072ff404c99b231ddc3ede4e7b0aa4f1113e726254b5cbb952'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d02f0fdd4cff4e426ee3e80f08bbf55b154b7c830932e4e6e8cad774f46b30a8341db06404dde082861515f0f665898ff8b276a7d902847ff325ac7edca41d0
|
7
|
+
data.tar.gz: 99ea7fc83cc66a646a7b58d6a752ca7f537a8a710500fe81befa64431b1ef5183d3efe6de207818f445c2ee201f0a3cd6b51fc948c2666ba6224522858ad3440
|
@@ -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/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [**5.4.3**](https://github.com/lob/lob-ruby/releases/tag/v5.4.3) (2021-12-15)
|
2
|
+
- [**199**](https://github.com/lob/lob-ruby/pull/199) Refactor ResourceBase to make the options sent to rest-client more configurable
|
3
|
+
## [**5.4.1**](https://github.com/lob/lob-ruby/releases/tag/v5.4.1) (2021-09-28)
|
4
|
+
- [**193**](https://github.com/lob/lob-ruby/pull/193) Minor patches
|
5
|
+
## [**5.4.0**](https://github.com/lob/lob-ruby/releases/tag/v5.4.0) (2021-09-21)
|
6
|
+
- [**191**](https://github.com/lob/lob-ruby/pull/191) Add support for reverse geocoding endpoint
|
1
7
|
## [**5.3.0**](https://github.com/lob/lob-ruby/releases/tag/v5.3.0) (2021-08-25)
|
2
8
|
- [**190**](https://github.com/lob/lob-ruby/pull/190) Adds support for bulk AV endpoints
|
3
9
|
## [**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)
|
@@ -109,80 +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
|
-
- [Bulk Verify US Addresses](https://lob.com/docs/ruby#bulk_us_verifications_create)
|
134
|
-
- [The US Zip Lookup Object](https://lob.com/docs/ruby#us_zip_lookups_object)
|
135
|
-
- [Lookup a US Zip Code](https://lob.com/docs/ruby#us_zip_lookups_create)
|
136
|
-
- [US Autocompletion API](https://lob.com/docs/ruby#us_autocompletions)
|
137
|
-
- [The US Autocompletion Object](https://lob.com/docs/ruby#us_autocompletions_object)
|
138
|
-
- [Autocomplete a US Address](https://lob.com/docs/ruby#us_autocompletions_create)
|
139
|
-
- [The US Autocompletion Test Environment](https://lob.com/docs/ruby#us-autocompletions-test-environment)
|
140
|
-
- **Int'l Verification API**
|
141
|
-
- [International Verifications](https://lob.com/docs/ruby#intl_verifications)
|
142
|
-
- [Verify an International Address](https://lob.com/docs/ruby#intl_verifications_create)
|
143
|
-
- [Bulk Verify International Addresses](https://lob.com/docs/ruby#bulk_intl_verifications_create)
|
144
|
-
- **Postcards API**
|
145
|
-
- [Postcards](https://lob.com/docs/ruby#postcards)
|
146
|
-
- [The Postcard Object](https://lob.com/docs/ruby#postcards_object)
|
147
|
-
- [Create a Postcard](https://lob.com/docs/ruby#postcards_create)
|
148
|
-
- [Retrieve a Postcard](https://lob.com/docs/ruby#postcards_retrieve)
|
149
|
-
- [Cancel a Postcard](https://lob.com/docs/ruby#postcards_delete)
|
150
|
-
- [List all Postcards](https://lob.com/docs/ruby#postcards_list)
|
151
|
-
- **Self Mailers API**
|
152
|
-
- [Self Mailers](https://lob.com/docs/ruby#self_mailers)
|
153
|
-
- [The Self Mailer Object](https://lob.com/docs/ruby#self_mailers_object)
|
154
|
-
- [Create a Self Mailer](https://lob.com/docs/ruby#self_mailers_create)
|
155
|
-
- [Retrieve a Self Mailer](https://lob.com/docs/ruby#self_mailers_retrieve)
|
156
|
-
- [Cancel a Self Mailer](https://lob.com/docs/ruby#self_mailers_delete)
|
157
|
-
- [List all Self Mailers](https://lob.com/docs/ruby#self_mailers_list)
|
158
|
-
- **Letters API**
|
159
|
-
- [Letters](https://lob.com/docs/ruby#letters)
|
160
|
-
- [The Letter Object](https://lob.com/docs/ruby#letters_object)
|
161
|
-
- [Create a Letter](https://lob.com/docs/ruby#letters_create)
|
162
|
-
- [Retrieve a Letter](https://lob.com/docs/ruby#letters_retrieve)
|
163
|
-
- [Cancel a Letter](https://lob.com/docs/ruby#letters_delete)
|
164
|
-
- [List all Letters](https://lob.com/docs/ruby#letters_list)
|
165
|
-
- **Checks API**
|
166
|
-
- [Checks](https://lob.com/docs/ruby#checks)
|
167
|
-
- [The Check Object](https://lob.com/docs/ruby#checks_object)
|
168
|
-
- [Create a Check](https://lob.com/docs/ruby#checks_create)
|
169
|
-
- [Retrieve a Check](https://lob.com/docs/ruby#checks_retrieve)
|
170
|
-
- [Cancel a Check](https://lob.com/docs/ruby#checks_delete)
|
171
|
-
- [List all Checks](https://lob.com/docs/ruby#checks_list)
|
172
|
-
- [Bank Accounts](https://lob.com/docs/ruby#bank-accounts)
|
173
|
-
- [The Bank Account Object](https://lob.com/docs/ruby#bankaccounts_object)
|
174
|
-
- [Create a Bank Account](https://lob.com/docs/ruby#bankaccounts_create)
|
175
|
-
- [Retrieve a Bank Account](https://lob.com/docs/ruby#bankaccounts_retrieve)
|
176
|
-
- [Delete a Bank Account](https://lob.com/docs/ruby#bankaccounts_delete)
|
177
|
-
- [Verify a Bank Account](https://lob.com/docs/ruby#bankaccounts_verify)
|
178
|
-
- [List all Bank Accounts](https://lob.com/docs/ruby#bankaccounts_list)
|
179
|
-
- **Appendix**
|
180
|
-
- [API Changelog](https://lob.com/docs/ruby#changelog)
|
181
|
-
- [The Tracking Event Object](https://lob.com/docs/ruby#tracking_event_object)
|
182
|
-
- [Events](https://lob.com/docs/ruby#events)
|
183
|
-
- [HTML Examples](https://lob.com/docs/ruby#html-examples)
|
184
|
-
- [Image Prepping](https://lob.com/docs/ruby#prepping)
|
185
|
-
- [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/).
|
186
117
|
|
187
118
|
## Contributing
|
188
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
|
+
)
|
@@ -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
|
+
)
|
data/examples/self_mailers.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 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
|
-
|
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
|
@@ -71,17 +71,23 @@ module Lob
|
|
71
71
|
if query != {}
|
72
72
|
url = "#{url}?#{build_nested_query(query)}"
|
73
73
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
74
|
+
|
75
|
+
client_params = {
|
76
|
+
headers: headers,
|
77
|
+
method: method,
|
78
|
+
url: url,
|
79
|
+
}
|
80
|
+
unless method == :delete || method == :get
|
81
|
+
if body&[:merge_variables]&.class == Hash
|
82
|
+
body[:merge_variables] = body[:merge_variables].to_json
|
83
83
|
end
|
84
84
|
|
85
|
+
client_params[:body] = body
|
86
|
+
end
|
87
|
+
|
88
|
+
begin
|
89
|
+
response = RestClient::Request.execute(client_params)
|
90
|
+
|
85
91
|
body = JSON.parse(response)
|
86
92
|
|
87
93
|
body.define_singleton_method(:_response) do
|
@@ -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
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 "
|
27
|
-
spec.add_development_dependency "simplecov", "~> 0.
|
26
|
+
spec.add_development_dependency "coveralls_reborn", "~> 0.23.1"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0.21.0"
|
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
|
4
|
+
version: 5.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -73,33 +73,61 @@ dependencies:
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '1.2'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: coveralls_reborn
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
81
|
+
version: 0.23.1
|
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.
|
88
|
+
version: 0.23.1
|
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.
|
95
|
+
version: 0.21.0
|
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.
|
102
|
+
version: 0.21.0
|
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
|
@@ -107,8 +135,9 @@ executables: []
|
|
107
135
|
extensions: []
|
108
136
|
extra_rdoc_files: []
|
109
137
|
files:
|
138
|
+
- ".github/workflows/run_tests_job.yml"
|
139
|
+
- ".github/workflows/update_gem.yml"
|
110
140
|
- ".gitignore"
|
111
|
-
- ".travis.yml"
|
112
141
|
- CHANGELOG.md
|
113
142
|
- CONTRIBUTING.md
|
114
143
|
- Gemfile
|
@@ -129,7 +158,13 @@ files:
|
|
129
158
|
- examples/csv_verify/input.csv
|
130
159
|
- examples/csv_verify/verify.rb
|
131
160
|
- examples/letters.rb
|
161
|
+
- examples/list_postcards_metadata.rb
|
132
162
|
- examples/postcards.rb
|
163
|
+
- examples/postcards_idempotent.rb
|
164
|
+
- examples/postcards_intl.rb
|
165
|
+
- examples/postcards_remote.rb
|
166
|
+
- examples/postcards_send_date.rb
|
167
|
+
- examples/postcards_template.rb
|
133
168
|
- examples/self_mailers.rb
|
134
169
|
- lib/lob.rb
|
135
170
|
- lib/lob/client.rb
|
@@ -148,6 +183,7 @@ files:
|
|
148
183
|
- lib/lob/resources/resource_base.rb
|
149
184
|
- lib/lob/resources/self_mailer.rb
|
150
185
|
- lib/lob/resources/us_autocompletions.rb
|
186
|
+
- lib/lob/resources/us_reverse_geocode_lookups.rb
|
151
187
|
- lib/lob/resources/us_verifications.rb
|
152
188
|
- lib/lob/resources/us_zip_lookups.rb
|
153
189
|
- lib/lob/version.rb
|
@@ -166,6 +202,7 @@ files:
|
|
166
202
|
- spec/lob/resources/resource_base_spec.rb
|
167
203
|
- spec/lob/resources/self_mailer_spec.rb
|
168
204
|
- spec/lob/resources/us_autocompletions_spec.rb
|
205
|
+
- spec/lob/resources/us_reverse_geocode_lookups_spec.rb
|
169
206
|
- spec/lob/resources/us_verifications_spec.rb
|
170
207
|
- spec/lob/resources/us_zip_lookups_spec.rb
|
171
208
|
- spec/lob_spec.rb
|
@@ -215,6 +252,7 @@ test_files:
|
|
215
252
|
- spec/lob/resources/resource_base_spec.rb
|
216
253
|
- spec/lob/resources/self_mailer_spec.rb
|
217
254
|
- spec/lob/resources/us_autocompletions_spec.rb
|
255
|
+
- spec/lob/resources/us_reverse_geocode_lookups_spec.rb
|
218
256
|
- spec/lob/resources/us_verifications_spec.rb
|
219
257
|
- spec/lob/resources/us_zip_lookups_spec.rb
|
220
258
|
- spec/lob_spec.rb
|