lob 2.5.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +19 -0
- data/Gemfile +0 -2
- data/README.md +19 -36
- data/examples/README.md +14 -6
- data/examples/checks.rb +6 -7
- data/examples/csv_checks/create_checks.rb +47 -0
- data/examples/csv_checks/input.csv +6 -0
- data/examples/csv_letters/create_letters.rb +40 -0
- data/examples/csv_letters/input.csv +6 -0
- data/examples/csv_letters/letter_template.html +33 -0
- data/examples/csv_postcards/create_postcards.rb +2 -3
- data/examples/letters.rb +4 -5
- data/examples/postcards.rb +4 -5
- data/examples/verify/verify.rb +3 -4
- data/lib/lob.rb +1 -91
- data/lib/lob/client.rb +61 -0
- data/lib/lob/resources/address.rb +24 -0
- data/lib/lob/resources/area.rb +16 -0
- data/lib/lob/resources/bank_account.rb +24 -0
- data/lib/lob/resources/check.rb +14 -0
- data/lib/lob/resources/country.rb +16 -0
- data/lib/lob/resources/letter.rb +14 -0
- data/lib/lob/resources/postcard.rb +14 -0
- data/lib/lob/resources/resource_base.rb +108 -0
- data/lib/lob/resources/route.rb +24 -0
- data/lib/lob/resources/state.rb +16 -0
- data/lib/lob/version.rb +1 -1
- data/spec/lob/{v1 → resources}/address_spec.rb +15 -14
- data/spec/lob/{v1 → resources}/area_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/bank_account_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/check_spec.rb +3 -2
- data/spec/lob/{v1 → resources}/country_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/letter_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/postcard_spec.rb +2 -2
- data/spec/lob/resources/resource_base_spec.rb +53 -0
- data/spec/lob/{v1 → resources}/route_spec.rb +2 -2
- data/spec/lob/{v1 → resources}/state_spec.rb +2 -2
- data/spec/lob_spec.rb +12 -45
- data/spec/spec_helper.rb +2 -0
- metadata +86 -89
- data/examples/jobs.rb +0 -91
- data/lib/lob/v1/address.rb +0 -41
- data/lib/lob/v1/area.rb +0 -27
- data/lib/lob/v1/bank_account.rb +0 -37
- data/lib/lob/v1/check.rb +0 -33
- data/lib/lob/v1/country.rb +0 -21
- data/lib/lob/v1/job.rb +0 -39
- data/lib/lob/v1/letter.rb +0 -33
- data/lib/lob/v1/object.rb +0 -33
- data/lib/lob/v1/postcard.rb +0 -33
- data/lib/lob/v1/resource.rb +0 -69
- data/lib/lob/v1/route.rb +0 -27
- data/lib/lob/v1/setting.rb +0 -25
- data/lib/lob/v1/state.rb +0 -21
- data/spec/lob/v1/job_spec.rb +0 -161
- data/spec/lob/v1/object_spec.rb +0 -72
- data/spec/lob/v1/resource_spec.rb +0 -41
- data/spec/lob/v1/setting_spec.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37c8b30c17f9f1e2bf17d7fb3030e6a5f503ed08
|
4
|
+
data.tar.gz: f3be769fb4eb543072f637e89c5a2a382391872b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83785a95d0f3bed197b7ce4f89269b8c695715f5aafc1591651229ed2ffe47888209097320919befa9a20b25d17ec5a72b77a496b69ca648bb6f543248c85365
|
7
|
+
data.tar.gz: 20bca49d8ab6271f0c4c9b0186aa55e3b4a2dc8277b68bc2795f01477b426185589e465afab92697c809a605cb8b7d016a5876ef8cf078e1592c052be84c0daf
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 3.0.0
|
2
|
+
|
3
|
+
Version 3.0.0 introduces several breaking changes. It requires a minimum API version of `2015-04-11`.
|
4
|
+
|
5
|
+
* Ruby 1.9.3 is no longer supported. lob-ruby now supports Ruby versions at or above 2.0.0.
|
6
|
+
* Jobs and Objects resources have been deprecated from the gem.
|
7
|
+
* Resources have been moved from `Lob::V1` to the `Lob::Resources` namespace and have been refactored to contain the HTTP request/response logic..
|
8
|
+
* Configuration for the Lob Client has been changed. `Lob()`, `Lob.load`, and `Lob.configure` have all been deprecated and replaced with a single method of configuration: `Lob::Client.new(api_key: "your-api-key")`.
|
9
|
+
|
1
10
|
## [**2.5.1**](https://github.com/lob/lob-ruby/releases/tag/v2.5.1)
|
2
11
|
- [**#145**] (https://github.com/lob/lob-ruby/pull/145) More lenient rest-client version restriction
|
3
12
|
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# How to contribute
|
2
|
+
|
3
|
+
We welcome contributions from the community and are pleased to have them. Please follow this guide when logging issues or making code changes.
|
4
|
+
|
5
|
+
Make sure you have Ruby 2.0 installed. Copy and paste the following commands in your projects directory.
|
6
|
+
|
7
|
+
git clone https://github.com/lob/lob-ruby.git
|
8
|
+
cd lob-ruby
|
9
|
+
bundle install
|
10
|
+
|
11
|
+
## Contributing Instructions
|
12
|
+
|
13
|
+
1. Fork it
|
14
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
15
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
16
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
17
|
+
5. Make sure the tests pass
|
18
|
+
6. Open up coverage/index.html in your browser and add tests if required
|
19
|
+
7. Create new Pull Request
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
Ruby wrapper for the [Lob.com](http://lob.com) API. See the full Lob.com [API Documentation](https://lob.com/docs/ruby). For best results, be sure that you're using [the latest version](https://lob.com/docs/ruby#version) of the Lob API and the latest version of the ruby wrapper. This gem gives you an ActiveRecord-style syntax to use the Lob.com API.
|
10
10
|
|
11
|
-
Supports Ruby
|
11
|
+
Supports Ruby 2.0.0 and greater.
|
12
12
|
|
13
13
|
## Table of Contents
|
14
14
|
|
@@ -61,20 +61,10 @@ For optional parameters and other details, refer to the docs [here](https://lob.
|
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
# To initialize a Lob object
|
64
|
-
|
64
|
+
lob = Lob::Client.new(api_key: "your-api-key")
|
65
65
|
|
66
|
-
#
|
67
|
-
Lob.api_key
|
68
|
-
@lob = Lob.load
|
69
|
-
```
|
70
|
-
|
71
|
-
#### Or if you want some detailed configuration
|
72
|
-
|
73
|
-
```ruby
|
74
|
-
Lob.configure do |config|
|
75
|
-
config.api_key = "your-api-key" # get your own at http://lob.com :)
|
76
|
-
config.api_version = "2014-12-18" # override the API version
|
77
|
-
end
|
66
|
+
# To initialize a Lob object with an older API version
|
67
|
+
lob = Lob::Client.new(api_key: "your-api-key", api_version: "2014-12-18")
|
78
68
|
```
|
79
69
|
|
80
70
|
#### Caution: Pass zero-prefixed zip codes as strings
|
@@ -88,7 +78,7 @@ The Ruby interpreter assumes it's not of base-10 and tries to convert it to base
|
|
88
78
|
You can access response headers via a hidden `headers` method on the response hash.
|
89
79
|
|
90
80
|
```ruby
|
91
|
-
addresses =
|
81
|
+
addresses = lob.addresses.list
|
92
82
|
|
93
83
|
addresses._response.headers[:content_type]
|
94
84
|
# => "application/json; charset=utf-8"
|
@@ -104,7 +94,7 @@ You can also access headers from `Lob::InvalidRequestError`s.
|
|
104
94
|
|
105
95
|
```ruby
|
106
96
|
begin
|
107
|
-
|
97
|
+
lob.objects.create(name: "Test", file: "https://lob.com/test.pdf", bad_param: "bad_value")
|
108
98
|
rescue Lob::InvalidRequestError => e
|
109
99
|
e._response.headers[:content_type]
|
110
100
|
# => "application/json; charset=utf-8"
|
@@ -126,8 +116,10 @@ There are simple scripts to demonstrate how to create all the core Lob products
|
|
126
116
|
- [Errors](https://lob.com/docs/ruby#errors)
|
127
117
|
- [Rate Limiting](https://lob.com/docs/ruby#rate-limits)
|
128
118
|
- [Metadata](https://lob.com/docs/ruby#metadata)
|
119
|
+
- [Asset URLs](https://lob.com/docs/ruby#urls)
|
129
120
|
- **Addresses**
|
130
121
|
- [Address Book](https://lob.com/docs/ruby#addresses)
|
122
|
+
- [The Address Object](https://lob.com/docs/ruby#addresses_object)
|
131
123
|
- [Create an Address](https://lob.com/docs/ruby#addresses_create)
|
132
124
|
- [Retrieve an Address](https://lob.com/docs/ruby#addresses_retrieve)
|
133
125
|
- [Delete an Address](https://lob.com/docs/ruby#addresses_delete)
|
@@ -136,20 +128,24 @@ There are simple scripts to demonstrate how to create all the core Lob products
|
|
136
128
|
- [Verify an Address](https://lob.com/docs/ruby#verify_create)
|
137
129
|
- **Postcards API**
|
138
130
|
- [Postcards](https://lob.com/docs/ruby#postcards)
|
131
|
+
- [The Postcard Object](https://lob.com/docs/ruby#postcards_object)
|
139
132
|
- [Create a Postcard](https://lob.com/docs/ruby#postcards_create)
|
140
133
|
- [Retrieve a Postcard](https://lob.com/docs/ruby#postcards_retrieve)
|
141
134
|
- [List all Postcards](https://lob.com/docs/ruby#postcards_list)
|
142
135
|
- **Letters API**
|
143
136
|
- [Letters](https://lob.com/docs/ruby#letters)
|
137
|
+
- [The Letter Object](https://lob.com/docs/ruby#letters_object)
|
144
138
|
- [Create a Letter](https://lob.com/docs/ruby#letters_create)
|
145
139
|
- [Retrieve a Letter](https://lob.com/docs/ruby#letters_retrieve)
|
146
140
|
- [List all Letters](https://lob.com/docs/ruby#letters_list)
|
147
141
|
- **Checks API**
|
148
142
|
- [Checks](https://lob.com/docs/ruby#checks)
|
143
|
+
- [The Check Object](https://lob.com/docs/ruby#checks_object)
|
149
144
|
- [Create a Check](https://lob.com/docs/ruby#checks_create)
|
150
145
|
- [Retrieve a Check](https://lob.com/docs/ruby#checks_retrieve)
|
151
146
|
- [List all Checks](https://lob.com/docs/ruby#checks_list)
|
152
147
|
- [Bank Accounts](https://lob.com/docs/ruby#bank-accounts)
|
148
|
+
- [The Bank Account Object](https://lob.com/docs/ruby#bankaccounts_object)
|
153
149
|
- [Create a Bank Account](https://lob.com/docs/ruby#bankaccounts_create)
|
154
150
|
- [Retrieve a Bank Account](https://lob.com/docs/ruby#bankaccounts_retrieve)
|
155
151
|
- [Delete a Bank Account](https://lob.com/docs/ruby#bankaccounts_delete)
|
@@ -157,12 +153,14 @@ There are simple scripts to demonstrate how to create all the core Lob products
|
|
157
153
|
- [List all Bank Accounts](https://lob.com/docs/ruby#bankaccounts_list)
|
158
154
|
- **Area Mail API**
|
159
155
|
- [Areas](https://lob.com/docs/ruby#areas)
|
156
|
+
- [The Area Object](https://lob.com/docs/ruby#areas_object)
|
160
157
|
- [Create an Area Mailing](https://lob.com/docs/ruby#areas_create)
|
161
158
|
- [Retrieve an Area Mailing](https://lob.com/docs/ruby#areas_retrieve)
|
162
159
|
- [List all Area Mailings](https://lob.com/docs/ruby#areas_list)
|
163
160
|
- [Routes](https://lob.com/docs/ruby#routes)
|
164
|
-
- [
|
165
|
-
- [
|
161
|
+
- [The Routes Object](https://lob.com/docs/ruby#routes_object)
|
162
|
+
- [Retrieve Routes](https://lob.com/docs/ruby#routes_retrieve)
|
163
|
+
- [List all Routes](https://lob.com/docs/ruby#routes_list)
|
166
164
|
- **Resources**
|
167
165
|
- [Countries](https://lob.com/docs/ruby#countries)
|
168
166
|
- [List all Countries](https://lob.com/docs/ruby#countries_list)
|
@@ -170,36 +168,21 @@ There are simple scripts to demonstrate how to create all the core Lob products
|
|
170
168
|
- [List all States](https://lob.com/docs/ruby#states_list)
|
171
169
|
- **Appendix**
|
172
170
|
- [API Changelog](https://lob.com/docs/ruby#changelog)
|
171
|
+
- [The Tracking Event Object](https://lob.com/docs/ruby#tracking_event_object)
|
173
172
|
- [HTML Examples](https://lob.com/docs/ruby#html-examples)
|
174
173
|
- [Image Prepping](https://lob.com/docs/ruby#prepping)
|
175
174
|
|
176
175
|
## Contributing
|
177
176
|
|
178
|
-
|
179
|
-
|
180
|
-
git clone https://github.com/lob/lob-ruby.git
|
181
|
-
cd lob-ruby
|
182
|
-
bundle install
|
183
|
-
|
184
|
-
### Contributing Instructions
|
185
|
-
|
186
|
-
1. Fork it
|
187
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
188
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
189
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
190
|
-
5. Make sure the tests pass
|
191
|
-
6. Open up coverage/index.html in your browser and add tests if required
|
192
|
-
7. Create new Pull Request
|
177
|
+
To contribute, please see the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
193
178
|
|
194
179
|
## Testing
|
195
180
|
|
196
181
|
Tests are written using MiniTest, a testing library that comes with Ruby stdlib.
|
197
182
|
|
198
|
-
You'll need to pass in your Lob.com API as the environment variable `LOB_API_KEY`, to run the tests. Be sure to use your Test API key, and not the Live one.
|
199
|
-
|
200
183
|
Here's how you can run the tests:
|
201
184
|
|
202
|
-
|
185
|
+
bundle exec rake test
|
203
186
|
|
204
187
|
You can also configure, TravisCI for your fork of the repository and it'll run the tests for you, when you push.
|
205
188
|
|
data/examples/README.md
CHANGED
@@ -2,26 +2,34 @@
|
|
2
2
|
|
3
3
|
This directory contains a collection of ruby example to help get you started using the Lob API. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions.
|
4
4
|
|
5
|
+
## /csv_checks/
|
6
|
+
|
7
|
+
An example showing how to dynamically create checks from a CSV using HTML, variable data, and Lob's [Checks API](https://lob.com/services/checks).
|
8
|
+
|
9
|
+
## /csv_letters/
|
10
|
+
|
11
|
+
An example showing how to dynamically create letters from a CSV using HTML, a custom font, variable data, and Lob's [Letters API](https://lob.com/services/letters).
|
12
|
+
|
5
13
|
## /csv_postcards/
|
6
14
|
|
7
|
-
An example showing how to dynamically create postcards from a CSV using HTML, a custom font, variable data, and Lob's [
|
15
|
+
An example showing how to dynamically create postcards from a CSV using HTML, a custom font, variable data, and Lob's [Postcards API](https://lob.com/services/postcards).
|
8
16
|
|
9
17
|
## /checks.rb
|
10
18
|
|
11
|
-
An example showing how to create a check using Lob's [
|
19
|
+
An example showing how to create a check using Lob's [Checks API](https://lob.com/services/checks).
|
12
20
|
|
13
21
|
## /jobs.rb
|
14
22
|
|
15
|
-
An example showing how to create objects and jobs using Lob's [
|
23
|
+
An example showing how to create objects and jobs using Lob's [Jobs API](https://lob.com/services/sps).
|
16
24
|
|
17
25
|
## /letters.rb
|
18
26
|
|
19
|
-
|
27
|
+
An example showing how to create a letter using Lob's [Letters API](https://lob.com/services/letters).
|
20
28
|
|
21
29
|
## /postcards.rb
|
22
30
|
|
23
|
-
An example showing how to create
|
31
|
+
An example showing how to create a postcard using Lob's [Postcards API](https://lob.com/services/postcards).
|
24
32
|
|
25
|
-
## /verify
|
33
|
+
## /verify/
|
26
34
|
|
27
35
|
An example showing how to verify an address using the [StreetAddress gem](https://github.com/derrek/street-address) and Lob's verify endpoint. This example saves verified addresses in a CSV file.
|
data/examples/checks.rb
CHANGED
@@ -2,11 +2,10 @@ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
|
2
2
|
require 'lob'
|
3
3
|
|
4
4
|
# initialize Lob object
|
5
|
-
Lob.api_key
|
6
|
-
@lob = Lob.load
|
5
|
+
lob = Lob::Client.new(api_key: 'test_799ff27291c166d10ba191902ad02fb059c')
|
7
6
|
|
8
7
|
# create an address
|
9
|
-
to_address =
|
8
|
+
to_address = lob.addresses.create(
|
10
9
|
name: "John Doe",
|
11
10
|
address_line1: "104 Printing Boulevard",
|
12
11
|
address_city: "Boston",
|
@@ -16,7 +15,7 @@ to_address = @lob.addresses.create(
|
|
16
15
|
)
|
17
16
|
|
18
17
|
# create a from address
|
19
|
-
from_address =
|
18
|
+
from_address = lob.addresses.create(
|
20
19
|
name: "Jane Doe",
|
21
20
|
address_line1: "123 Hello Ave",
|
22
21
|
address_city: "Providence",
|
@@ -26,7 +25,7 @@ from_address = @lob.addresses.create(
|
|
26
25
|
)
|
27
26
|
|
28
27
|
# create a bank account
|
29
|
-
bank_account =
|
28
|
+
bank_account = lob.bank_accounts.create(
|
30
29
|
routing_number: "322271627",
|
31
30
|
account_number: "123456789",
|
32
31
|
account_type: "company",
|
@@ -34,10 +33,10 @@ bank_account = @lob.bank_accounts.create(
|
|
34
33
|
)
|
35
34
|
|
36
35
|
puts bank_account
|
37
|
-
|
36
|
+
lob.bank_accounts.verify(bank_account['id'], amounts: [23, 12])
|
38
37
|
|
39
38
|
# send a $1000 check using an already created bank and address
|
40
|
-
puts
|
39
|
+
puts lob.checks.create(
|
41
40
|
description: "Test Check",
|
42
41
|
check_number: "10000",
|
43
42
|
bank_account: bank_account["id"],
|
@@ -0,0 +1,47 @@
|
|
1
|
+
$:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob'
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
# Initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'test_799ff27291c166d10ba191902ad02fb059c')
|
7
|
+
|
8
|
+
# Create a bank account
|
9
|
+
bank_account = lob.bank_accounts.create(
|
10
|
+
routing_number: "322271627",
|
11
|
+
account_number: "123456789",
|
12
|
+
account_type: "company",
|
13
|
+
signatory: "John Doe"
|
14
|
+
)
|
15
|
+
|
16
|
+
puts bank_account
|
17
|
+
|
18
|
+
# Verify bank account
|
19
|
+
lob.bank_accounts.verify(bank_account['id'], amounts: [23, 12])
|
20
|
+
|
21
|
+
# Parse the CSV and create the checks
|
22
|
+
CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
|
23
|
+
check = lob.checks.create(
|
24
|
+
description: 'CSV Test',
|
25
|
+
bank_account: bank_account["id"],
|
26
|
+
to: {
|
27
|
+
name: row[0],
|
28
|
+
address_line1: row[1],
|
29
|
+
address_line2: row[2],
|
30
|
+
address_city: row[3],
|
31
|
+
address_state: row[4],
|
32
|
+
address_zip: row[5],
|
33
|
+
address_country: row[6]
|
34
|
+
},
|
35
|
+
from: {
|
36
|
+
name: 'Lob',
|
37
|
+
address_line1: '123 Main Street',
|
38
|
+
address_city: 'San Francisco',
|
39
|
+
address_state: 'CA',
|
40
|
+
address_zip: '94185',
|
41
|
+
address_country: 'US'
|
42
|
+
},
|
43
|
+
amount: row[7],
|
44
|
+
memo: "For travel reimbursement"
|
45
|
+
)
|
46
|
+
puts check['url']
|
47
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Pallavi,353 King Street,Apt. 432,San Francisco,CA,94158,US,600.00
|
2
|
+
Dom,456 Oak Street,Apt. 102,San Francisco,CA,94185,US,500.00
|
3
|
+
Kyle,123 Test Street,Apt. 101,San Francisco,CA,94105,US,400.00
|
4
|
+
Kienan,789 Elm Street,Apt. 101,San Francisco,CA,94107,US,300.00
|
5
|
+
Sid,111 Washington Street,Apt. 101,San Francisco,CA,94112,US,200.00
|
6
|
+
Will,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US,100.00
|
@@ -0,0 +1,40 @@
|
|
1
|
+
$:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
|
2
|
+
require 'lob'
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
# Initialize Lob object
|
6
|
+
lob = Lob::Client.new(api_key: 'test_799ff27291c166d10ba191902ad02fb059c')
|
7
|
+
|
8
|
+
# Load the HTML from letter_template.html
|
9
|
+
letter_html = File.open(File.expand_path('../letter_template.html', __FILE__)).read
|
10
|
+
|
11
|
+
# Parse the CSV and create the letters.
|
12
|
+
CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
|
13
|
+
letter = lob.letters.create(
|
14
|
+
description: 'CSV Test',
|
15
|
+
to: {
|
16
|
+
name: row[0],
|
17
|
+
address_line1: row[1],
|
18
|
+
address_line2: row[2],
|
19
|
+
address_city: row[3],
|
20
|
+
address_state: row[4],
|
21
|
+
address_zip: row[5],
|
22
|
+
address_country: row[6]
|
23
|
+
},
|
24
|
+
from: {
|
25
|
+
name: 'Lob',
|
26
|
+
address_line1: '123 Main Street',
|
27
|
+
address_city: 'San Francisco',
|
28
|
+
address_state: 'CA',
|
29
|
+
address_zip: '94185',
|
30
|
+
address_country: 'US'
|
31
|
+
},
|
32
|
+
file: letter_html,
|
33
|
+
data: {
|
34
|
+
name: row[0],
|
35
|
+
city: row[3]
|
36
|
+
},
|
37
|
+
color: false
|
38
|
+
)
|
39
|
+
puts letter['url']
|
40
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Pallavi,353 King Street,Apt. 432,San Francisco,CA,94158,US
|
2
|
+
Dom,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US
|
3
|
+
Kyle,123 Test Street,Apt. 101,San Francisco,CA,94105,US
|
4
|
+
Kienan,789 Elm Street,Apt. 101,San Francisco,CA,94107,US
|
5
|
+
Sid,111 Washington Street,Apt. 101,San Francisco,CA,94112,US
|
6
|
+
Will,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<style>
|
4
|
+
*, *:before, *:after {
|
5
|
+
-webkit-box-sizing: border-box;
|
6
|
+
-moz-box-sizing: border-box;
|
7
|
+
box-sizing: border-box;
|
8
|
+
}
|
9
|
+
|
10
|
+
@font-face {
|
11
|
+
font-family: 'Loved by the King';
|
12
|
+
font-style: normal;
|
13
|
+
font-weight: 400;
|
14
|
+
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype');
|
15
|
+
}
|
16
|
+
|
17
|
+
.text {
|
18
|
+
margin-left: 75px;
|
19
|
+
padding-top: 250px;
|
20
|
+
width: 400px;
|
21
|
+
font-family: 'Loved by the King';
|
22
|
+
font-size: 50px;
|
23
|
+
font-weight: 700;
|
24
|
+
color: black;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
</head>
|
28
|
+
|
29
|
+
<body>
|
30
|
+
<p class="text">Hello {{name}}!<br/><br/>Join us for this year's summer celebration in {{city}}!</p>
|
31
|
+
</body>
|
32
|
+
|
33
|
+
</html>
|
@@ -3,8 +3,7 @@ require 'lob'
|
|
3
3
|
require 'csv'
|
4
4
|
|
5
5
|
# Initialize Lob object
|
6
|
-
Lob.api_key
|
7
|
-
@lob = Lob.load
|
6
|
+
lob = Lob::Client.new(api_key: 'test_799ff27291c166d10ba191902ad02fb059c')
|
8
7
|
|
9
8
|
# Load the HTML from postcard_front.html and postcard_back.html.
|
10
9
|
front_html = File.open(File.expand_path('../postcard_front.html', __FILE__)).read
|
@@ -12,7 +11,7 @@ back_html = File.open(File.expand_path('../postcard_back.html', __FILE__)).read
|
|
12
11
|
|
13
12
|
# Parse the CSV and create the postcards.
|
14
13
|
CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
|
15
|
-
postcard =
|
14
|
+
postcard = lob.postcards.create(
|
16
15
|
description: 'CSV Test',
|
17
16
|
to: {
|
18
17
|
name: row[5],
|