lob 4.3.0 → 5.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/forked_tests_job.yml +36 -0
  3. data/.github/workflows/run_tests_job.yml +32 -0
  4. data/.github/workflows/update_gem.yml +27 -0
  5. data/.gitignore +1 -0
  6. data/CHANGELOG.md +47 -0
  7. data/README.md +16 -85
  8. data/examples/README.md +95 -9
  9. data/examples/cards.rb +51 -0
  10. data/examples/checks.rb +4 -3
  11. data/examples/csv_checks/create_checks.rb +3 -2
  12. data/examples/csv_letters/create_letters.rb +3 -2
  13. data/examples/csv_letters/letter_template.html +1 -1
  14. data/examples/csv_postcards/create_postcards.rb +3 -2
  15. data/examples/csv_postcards/input.csv +7 -7
  16. data/examples/csv_postcards/postcard_back.html +1 -1
  17. data/examples/csv_verify/verify.rb +3 -2
  18. data/examples/letters.rb +4 -3
  19. data/examples/list_postcards_metadata.rb +94 -0
  20. data/examples/postcards.rb +6 -5
  21. data/examples/postcards_idempotent.rb +92 -0
  22. data/examples/postcards_intl.rb +87 -0
  23. data/examples/postcards_remote.rb +87 -0
  24. data/examples/postcards_send_date.rb +97 -0
  25. data/examples/postcards_template.rb +98 -0
  26. data/examples/self_mailers.rb +38 -0
  27. data/lib/lob/client.rb +33 -8
  28. data/lib/lob/resources/bulk_intl_verifications.rb +27 -0
  29. data/lib/lob/resources/bulk_us_verifications.rb +28 -0
  30. data/lib/lob/resources/card.rb +46 -0
  31. data/lib/lob/resources/{area.rb → group.rb} +2 -4
  32. data/lib/lob/resources/groups_member.rb +66 -0
  33. data/lib/lob/resources/resource_base.rb +20 -9
  34. data/lib/lob/resources/self_mailer.rb +14 -0
  35. data/lib/lob/resources/us_reverse_geocode_lookups.rb +26 -0
  36. data/lib/lob/version.rb +1 -1
  37. data/lob.gemspec +7 -7
  38. data/spec/lob/resources/bulk_intl_verifications_spec.rb +39 -0
  39. data/spec/lob/resources/bulk_us_verifications_spec.rb +51 -0
  40. data/spec/lob/resources/card_spec.rb +145 -0
  41. data/spec/lob/resources/check_spec.rb +21 -0
  42. data/spec/lob/resources/group_spec.rb +50 -0
  43. data/spec/lob/resources/intl_verifications_spec.rb +4 -7
  44. data/spec/lob/resources/letter_spec.rb +24 -4
  45. data/spec/lob/resources/member_spec.rb +65 -0
  46. data/spec/lob/resources/postcard_spec.rb +30 -5
  47. data/spec/lob/resources/resource_base_spec.rb +4 -16
  48. data/spec/lob/resources/self_mailer_spec.rb +177 -0
  49. data/spec/lob/resources/us_reverse_geocode_lookups_spec.rb +22 -0
  50. data/spec/samples/card.pdf +744 -0
  51. data/spec/samples/sfm-12x9-inside.pdf +0 -0
  52. data/spec/samples/sfm-12x9-outside.pdf +0 -0
  53. data/spec/samples/sfm-6x18-inside.pdf +0 -0
  54. data/spec/samples/sfm-6x18-outside.pdf +0 -0
  55. data/spec/spec_helper.rb +7 -5
  56. metadata +73 -39
  57. data/.travis.yml +0 -19
  58. data/lib/lob/resources/route.rb +0 -33
  59. data/spec/lob/resources/area_spec.rb +0 -59
  60. data/spec/lob/resources/route_spec.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8225f20dd05a0f5b903f986a88f5e93254dec38e28361076a9724cfef0c50661
4
- data.tar.gz: d0e4ccd13e9bd6f5b9b4010f48a7b6e9f2926c57de5a6a914d4f6153ecfd43a0
3
+ metadata.gz: ba5df9cb717ab1c37b9ee4741304e8d5afa77d2e78c323d25f6d81e541f463ae
4
+ data.tar.gz: f0b0e80db2cfafa53427676ff2ff66edf02f85f1e7b1c98acaeb7f5e5426de84
5
5
  SHA512:
6
- metadata.gz: 7f21d43ad6e066f4c94d00365d92bc155947bd4c56c2b0794aebfcecd75cd9f5189dab7583a39585eedc8060a788d0fa20ee6111097291ddefb06ef7f38ae37e
7
- data.tar.gz: c8df84c18215df4af65573cd1109b80d6bb053160a5958a867cfc5ab0bfcf3b09f9bb568c2235e4830a1c270f69512ae9727ea2704312316043e1d6073fdf581
6
+ metadata.gz: 40ad0b305524f54b28a1a08c83108aed912e6c23c096fb55be0d8f713bb6a2a1108f334c0d8949e88aa0139ab0e0fed71077b4e9af140829ab41643c9d0cc235
7
+ data.tar.gz: 7e9cbf18e676c609a09ff2bc32c60931c69c5fd5334ef82b905d2f7bc62c36086121ccd48e67e4b3a3f1cf5b64e87c5237f6ccd5bbcaaa36ef0d680bbccbd070
@@ -0,0 +1,36 @@
1
+ name: Run tests from Forked Repo
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [labeled]
6
+ jobs:
7
+ ruby_tests:
8
+ runs-on: ubuntu-latest
9
+ if: contains(github.event.pull_request.labels.*.name, 'Approved')
10
+
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
+ path-to-lcov: ./coverage/lcov/lcov.info
32
+
33
+
34
+
35
+
36
+
@@ -0,0 +1,32 @@
1
+ name: Run tests
2
+
3
+ on: [pull_request]
4
+ jobs:
5
+ ruby_tests:
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ ruby-version: ['jruby-9.2.9.0', '2.6', '2.7', '3.0']
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Setup
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: ${{ matrix.ruby-version }}
16
+ - name: Install Dependencies
17
+ run: bundle install
18
+ - name: Run Tests
19
+ env:
20
+ API_KEY: ${{ secrets.API_KEY }}
21
+ JRUBY_OPT: --2.0
22
+ run: bundle exec rake test
23
+ - name: Send coverage to Coveralls
24
+ uses: coverallsapp/github-action@master
25
+ with:
26
+ github-token: ${{ secrets.GITHUB_TOKEN }}
27
+ path-to-lcov: ./coverage/lcov/lcov.info
28
+
29
+
30
+
31
+
32
+
@@ -0,0 +1,27 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish_gem:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Setup
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.7
16
+ - name: Install Dependencies
17
+ run: bundle install
18
+ - name: Publish Gem
19
+ run: |
20
+ mkdir -p $HOME/.gem
21
+ touch $HOME/.gem/credentials
22
+ chmod 0600 $HOME/.gem/credentials
23
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
24
+ gem build *.gemspec
25
+ gem push *.gem
26
+ env:
27
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  .yardoc
6
6
  .DS_Store
7
+ .idea
7
8
  Gemfile.lock
8
9
  InstalledFiles
9
10
  _yardoc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,50 @@
1
+ ## [**5.4.6**](https://github.com/lob/lob-ruby/releases/tag/v5.4.6) (2022-01-25)
2
+ - [**206**](https://github/com/lob/lob-ruby/pull/206) added additional parsing to make sure we can pass hashes into bulk verify methods
3
+ ## [**5.4.5**](https://github.com/lob/lob-ruby/releases/tag/v5.4.5) (2022-01-11)
4
+ - [**203**](https://github.com/lob/lob-ruby/pull/203) Pass through proxy to rest-client if supplied
5
+ ## [**5.4.4**](https://github.com/lob/lob-ruby/releases/tag/v5.4.4) (2021-12-16)
6
+ - [**202**](https://github.com/lob/lob-ruby/pull/202) Fix for coveralls API for GH actions and fix for error in resource_base.rb
7
+ ## [**5.4.3**](https://github.com/lob/lob-ruby/releases/tag/v5.4.3) (2021-12-15)
8
+ - [**199**](https://github.com/lob/lob-ruby/pull/199) Refactor ResourceBase to make the options sent to rest-client more configurable
9
+ ## [**5.4.2**](https://github.com/lob/lob-ruby/releases/tag/v5.4.2) (2021-12-08)
10
+ - [**198**](https://github.com/lob/lob-ruby/pull/198) specified ruby version in publish action
11
+ - [**195**](https://github.com/lob/lob-ruby/pull/195) added links to example scripts in README file & gh actions to release
12
+ ## [**5.4.1**](https://github.com/lob/lob-ruby/releases/tag/v5.4.1) (2021-09-28)
13
+ - [**193**](https://github.com/lob/lob-ruby/pull/193) Minor patches
14
+ ## [**5.4.0**](https://github.com/lob/lob-ruby/releases/tag/v5.4.0) (2021-09-21)
15
+ - [**191**](https://github.com/lob/lob-ruby/pull/191) Add support for reverse geocoding endpoint
16
+ ## [**5.3.0**](https://github.com/lob/lob-ruby/releases/tag/v5.3.0) (2021-08-25)
17
+ - [**190**](https://github.com/lob/lob-ruby/pull/190) Adds support for bulk AV endpoints
18
+ ## [**5.2.0**](https://github.com/lob/lob-ruby/releases/tag/v5.2.0) (2021-05-03)
19
+ - [**188**](https://github.com/lob/lob-ruby/pull/188) Adds support for Self Mailers
20
+ ## 5.1.2 (2021-02-18)
21
+
22
+ ##### Chores and Bug Fixes
23
+
24
+ - [**185**](https://github.com/lob/lob-ruby/pull/185) Bumps rake to 12.3.3, adds Ruby 2.7, update example asset links, other cleanup.
25
+ ## 5.1.1 (2020-05-21)
26
+
27
+ ##### Chores
28
+
29
+ * **intl-verification:** update international verifications test mode fix ([#179](https://github.com/lob/lob-ruby/pull/179)) ([4ab7e7e2](https://github.com/lob/lob-ruby/commit/4ab7e7e2852706c37b00bd8f2df58207897bc0a3))
30
+
31
+ ##### Bug Fixes
32
+
33
+ * **merge-variables:** convert to json ([fa93885f](https://github.com/lob/lob-ruby/commit/fa93885f2aab4537e100b82d8a9f53cdec042f2e))
34
+
35
+ ## [**5.1.0**](https://github.com/lob/lob-ruby/releases/tag/v5.1.0)
36
+ - [**176**](https://github.com/lob/lob-ruby/pull/176) Adds support for Group Members (beta feature)
37
+ - [**175**](https://github.com/lob/lob-ruby/pull/175) Adds support for Groups (beta feature)
38
+ - [**174**](https://github.com/lob/lob-ruby/pull/174) Add Ruby 2.5-6, remove API keys, other cleanup
39
+ - [**173**](https://github.com/lob/lob-ruby/pull/173) Update example asset links
40
+
41
+ ## 5.0.0
42
+
43
+ Version 5.0.0 introduces a breaking change. It removes support for the area mail resources (`Areas` and `Routes`).
44
+
45
+ * Removes `Lob.areas`.
46
+ * Removes `Lob.routes`.
47
+
1
48
  ## [**4.3.0**](https://github.com/lob/lob-ruby/releases/tag/v4.3.0)
2
49
  - [**171**](https://github.com/lob/lob-ruby/pull/171) add USAutocompletions
3
50
  - [**170**](https://github.com/lob/lob-ruby/pull/170) Fix test name
data/README.md CHANGED
@@ -1,21 +1,24 @@
1
1
  # lob-ruby
2
2
 
3
3
  [![Build Status](https://travis-ci.org/lob/lob-ruby.svg?branch=master)](https://travis-ci.org/lob/lob-ruby)
4
- [![Gem Version](https://badge.fury.io/rb/lob.svg)](http://badge.fury.io/rb/lob)
5
- [![Dependency Status](https://gemnasium.com/lob/lob-ruby.svg)](https://gemnasium.com/lob/lob-ruby)
4
+ [![Gem Version](https://badge.fury.io/rb/lob.svg)](https://badge.fury.io/rb/lob)
6
5
  [![Coverage Status](https://coveralls.io/repos/lob/lob-ruby/badge.svg?branch=master)](https://coveralls.io/r/lob/lob-ruby?branch=master)
7
- [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/lob?color=green&type=total)](https://rubygems.org/gems/lob)
6
+ [![Downloads](https://ruby-gem-downloads-badge.herokuapp.com/lob?color=green&type=total)](https://rubygems.org/gems/lob)
8
7
 
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.
8
+ Ruby wrapper for the [Lob.com](https://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
9
 
11
10
  Supports Ruby 2.0.0 and greater.
12
11
 
13
12
  ## Table of Contents
14
13
 
14
+ - [Table of Contents](#table-of-contents)
15
15
  - [Getting Started](#getting-started)
16
16
  - [Registration](#registration)
17
17
  - [Installation](#installation)
18
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)
19
22
  - [Examples](#examples)
20
23
  - [API Documentation](#api-documentation)
21
24
  - [Contributing](#contributing)
@@ -25,11 +28,10 @@ Supports Ruby 2.0.0 and greater.
25
28
 
26
29
  Here's a general overview of the Lob services available, click through to read more.
27
30
 
28
- - [Postcards API](https://lob.com/services/postcards)
29
- - [Letters API](https://lob.com/services/letters)
30
- - [Checks API](https://lob.com/services/checks)
31
- - [Area Mail API](https://lob.com/services/area)
32
- - [Address Verification API](https://lob.com/services/verifications)
31
+ - [Postcards API](https://lob.com/products/print-mail/postcards)
32
+ - [Letters API](https://lob.com/products/print-mail/letters)
33
+ - [Checks API](https://lob.com/products/print-mail/checks)
34
+ - [Address Verification API](https://lob.com/products/address-verification)
33
35
 
34
36
  Please read through the official [API Documentation](#api-documentation) to get a complete sense of what to expect from each endpoint.
35
37
 
@@ -67,6 +69,9 @@ lob = Lob::Client.new(api_key: "your-api-key")
67
69
 
68
70
  # To initialize a Lob object with an older API version
69
71
  lob = Lob::Client.new(api_key: "your-api-key", api_version: "2014-12-18")
72
+
73
+ # To initialize a Lob object that needs to communicate via a proxy
74
+ lob = Lob::Client.new(api_key: "your-api-key", proxy: "http://proxy.example.com)
70
75
  ```
71
76
 
72
77
  #### Caution: Pass zero-prefixed zip codes as strings
@@ -96,7 +101,7 @@ You can also access headers from `Lob::InvalidRequestError`s.
96
101
 
97
102
  ```ruby
98
103
  begin
99
- lob.objects.create(name: "Test", file: "https://lob.com/test.pdf", bad_param: "bad_value")
104
+ lob.objects.create(name: "Test", file: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/incorrect_size.pdf", bad_param: "bad_value")
100
105
  rescue Lob::InvalidRequestError => e
101
106
  e._response.headers[:content_type]
102
107
  # => "application/json; charset=utf-8"
@@ -111,81 +116,7 @@ There are simple scripts to demonstrate how to create all the core Lob objects (
111
116
 
112
117
  ## API Documentation
113
118
 
114
- - [Introduction](https://lob.com/docs/ruby#introduction)
115
- - [Versioning](https://lob.com/docs/ruby#version)
116
- - [Errors](https://lob.com/docs/ruby#errors)
117
- - [Rate Limiting](https://lob.com/docs/ruby#rate-limits)
118
- - [Webhooks](https://lob.com/docs/ruby#webhooks)
119
- - [Cancellation Windows](https://lob.com/docs/ruby#cancellation)
120
- - [Scheduled Mailings](https://lob.com/docs/ruby#scheduled)
121
- - [Metadata](https://lob.com/docs/ruby#metadata)
122
- - [HTML Templates](https://lob.com/docs/ruby#templates)
123
- - [Asset URLs](https://lob.com/docs/ruby#urls)
124
- - **Addresses**
125
- - [Address Book](https://lob.com/docs/ruby#addresses)
126
- - [The Address Object](https://lob.com/docs/ruby#addresses_object)
127
- - [Create an Address](https://lob.com/docs/ruby#addresses_create)
128
- - [Retrieve an Address](https://lob.com/docs/ruby#addresses_retrieve)
129
- - [Delete an Address](https://lob.com/docs/ruby#addresses_delete)
130
- - [List all Addresses](https://lob.com/docs/ruby#addresses_list)
131
- - **US Verification API**
132
- - [US Verification API](https://lob.com/docs/ruby#us_verifications)
133
- - [The US Verification Object](https://lob.com/docs/ruby#us_verifications_object)
134
- - [Verify a US Address](https://lob.com/docs/ruby#us_verifications_create)
135
- - [The US Zip Lookup Object](https://lob.com/docs/ruby#us_zip_lookups_object)
136
- - [Lookup a US Zip Code](https://lob.com/docs/ruby#us_zip_lookups_create)
137
- - [US Autocompletion API](https://lob.com/docs/ruby#us_autocompletions)
138
- - [The US Autocompletion Object](https://lob.com/docs/ruby#us_autocompletions_object)
139
- - [Autocomplete a US Address](https://lob.com/docs/ruby#us_autocompletions_create)
140
- - [The US Autocompletion Test Environment](https://lob.com/docs/ruby#us-autocompletions-test-environment)
141
- - **Int'l Verification API**
142
- - [International Verifications](https://lob.com/docs/ruby#intl_verifications)
143
- - [Verify an International Address](https://lob.com/docs/ruby#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
- - **Letters API**
152
- - [Letters](https://lob.com/docs/ruby#letters)
153
- - [The Letter Object](https://lob.com/docs/ruby#letters_object)
154
- - [Create a Letter](https://lob.com/docs/ruby#letters_create)
155
- - [Retrieve a Letter](https://lob.com/docs/ruby#letters_retrieve)
156
- - [Cancel a Letter](https://lob.com/docs/ruby#letters_delete)
157
- - [List all Letters](https://lob.com/docs/ruby#letters_list)
158
- - **Checks API**
159
- - [Checks](https://lob.com/docs/ruby#checks)
160
- - [The Check Object](https://lob.com/docs/ruby#checks_object)
161
- - [Create a Check](https://lob.com/docs/ruby#checks_create)
162
- - [Retrieve a Check](https://lob.com/docs/ruby#checks_retrieve)
163
- - [Cancel a Check](https://lob.com/docs/ruby#checks_delete)
164
- - [List all Checks](https://lob.com/docs/ruby#checks_list)
165
- - [Bank Accounts](https://lob.com/docs/ruby#bank-accounts)
166
- - [The Bank Account Object](https://lob.com/docs/ruby#bankaccounts_object)
167
- - [Create a Bank Account](https://lob.com/docs/ruby#bankaccounts_create)
168
- - [Retrieve a Bank Account](https://lob.com/docs/ruby#bankaccounts_retrieve)
169
- - [Delete a Bank Account](https://lob.com/docs/ruby#bankaccounts_delete)
170
- - [Verify a Bank Account](https://lob.com/docs/ruby#bankaccounts_verify)
171
- - [List all Bank Accounts](https://lob.com/docs/ruby#bankaccounts_list)
172
- - **Area Mail API**
173
- - [Areas](https://lob.com/docs/ruby#areas)
174
- - [The Area Object](https://lob.com/docs/ruby#areas_object)
175
- - [Create an Area Mailing](https://lob.com/docs/ruby#areas_create)
176
- - [Retrieve an Area Mailing](https://lob.com/docs/ruby#areas_retrieve)
177
- - [List all Area Mailings](https://lob.com/docs/ruby#areas_list)
178
- - [Routes](https://lob.com/docs/ruby#routes)
179
- - [The Routes Object](https://lob.com/docs/ruby#routes_object)
180
- - [Retrieve Routes](https://lob.com/docs/ruby#routes_retrieve)
181
- - [List all Routes](https://lob.com/docs/ruby#routes_list)
182
- - **Appendix**
183
- - [API Changelog](https://lob.com/docs/ruby#changelog)
184
- - [The Tracking Event Object](https://lob.com/docs/ruby#tracking_event_object)
185
- - [Events](https://lob.com/docs/ruby#events)
186
- - [HTML Examples](https://lob.com/docs/ruby#html-examples)
187
- - [Image Prepping](https://lob.com/docs/ruby#prepping)
188
- - [US Verification Details](https://lob.com/docs/ruby#us_verification_details)
119
+ The full and comprehensive documentation of Lob's APIs is available [here](https://docs.lob.com/).
189
120
 
190
121
  ## Contributing
191
122
 
data/examples/README.md CHANGED
@@ -1,33 +1,119 @@
1
1
  # Ruby Examples
2
2
 
3
- Here we have put together a hand full of ruby examples to help get you started. Please read through the official [API Documentation](../README.md#api-documentation) to get a complete sense of what to expect from each endpoint. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions on implementation.
3
+ Here we have put together a handful of ruby examples to help get you started. Please read through the official [API Documentation](https://docs.lob.com) to get a complete sense of what to expect from each endpoint. As always, feel free to [contact us](https://lob.com/support) directly if you have any questions on implementation. Thank you for using Lob!
4
4
 
5
- ## /csv_checks/
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
- ## /csv_letters/
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
- ## /csv_postcards/
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
- ## /csv_verify/
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/docs#us_verifications_create).
35
+ Please note that if you are running this with a Test API Key, the verification API will always return [a dummy address](https://docs.lob.com/#section/US-Verifications-Test-Env).
36
+
37
+ ```
38
+ bundle exec ruby examples/csv_verify/verify.rb
39
+ ```
40
+
41
+ ## [/cards.rb](./cards.rb)
42
+
43
+ An example showing how to create a card using Lob's [Cards API](https://docs.lob.com/#tag/Cards).
44
+
45
+ ```
46
+ bundle exec ruby examples/cards.rb
47
+ ```
22
48
 
23
- ## /checks.rb
49
+ ## [/checks.rb](./checks.rb)
24
50
 
25
51
  An example showing how to create a check using Lob's [Checks API](https://lob.com/services/checks).
26
52
 
27
- ## /letters.rb
53
+ ```
54
+ bundle exec ruby examples/checks.rb
55
+ ```
56
+
57
+ ## [/letters.rb](./letters.rb)
28
58
 
29
59
  An example showing how to create a letter using Lob's [Letters API](https://lob.com/services/letters).
30
60
 
31
- ## /postcards.rb
61
+ ```
62
+ bundle exec ruby examples/letters.rb
63
+ ```
64
+
65
+ ## [/postcards.rb](./postcards.rb)
32
66
 
33
67
  An example showing how to create a postcard using Lob's [Postcards API](https://lob.com/services/postcards).
68
+
69
+ ```
70
+ bundle exec ruby examples/postcards.rb
71
+ ```
72
+
73
+ ## [/postcards_idempotent.rb](./postcards_idempotent.rb)
74
+
75
+ An example showing how to create an idempotent postcard request using Lob's [Postcards API](https://lob.com/services/postcards).
76
+
77
+ ```
78
+ bundle exec ruby examples/postcards_idempotent.rb
79
+ ```
80
+
81
+ ## [/postcards_intl.rb](./postcards_intl.rb)
82
+
83
+ An example showing how to create an international postcard using Lob's [Postcards API](https://lob.com/services/postcards).
84
+
85
+ ```
86
+ bundle exec ruby examples/postcards_intl.rb
87
+ ```
88
+
89
+ ## [/postcards_remote.rb](./postcards_remote.rb)
90
+
91
+ An example showing how to create a postcard with remote files, using Lob's [Postcards API](https://lob.com/services/postcards).
92
+
93
+ ```
94
+ bundle exec ruby examples/postcards_remote.rb
95
+ ```
96
+
97
+ ## [/postcards_send_date.rb](./postcards_send_date.rb)
98
+
99
+ An example showing how to create a postcard with a specified send date, using Lob's [Postcards API](https://lob.com/services/postcards).
100
+
101
+ ```
102
+ bundle exec ruby examples/postcards_send_date.rb
103
+ ```
104
+
105
+ ## [/postcards_template.rb](./postcards_template.rb)
106
+
107
+ An example showing how to create a postcard with a saved template, using Lob's [Postcards API](https://lob.com/services/postcards).
108
+
109
+ ```
110
+ bundle exec ruby examples/postcards_template.rb
111
+ ```
112
+
113
+ ## [/self_mailers.rb](./self_mailers.rb)
114
+
115
+ An example showing how to create a self mailer using Lob's Self Mailers API.
116
+
117
+ ```
118
+ bundle exec ruby examples/self_mailers.rb
119
+ ```
data/examples/cards.rb ADDED
@@ -0,0 +1,51 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+ require 'lob.rb'
3
+ require 'pp'
4
+
5
+ # initialize Lob object
6
+ LOB_LIVE_API_KEY = ENV['LOB_LIVE_API_KEY']
7
+ lob = Lob::Client.new(api_key: LOB_LIVE_API_KEY)
8
+
9
+ front_template = 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/card_horizontal.pdf'
10
+ back_template = 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/card_horizontal.pdf'
11
+
12
+ # create a card
13
+ pp lob.cards.create(
14
+ front: front_template, # required
15
+ back: back_template, # optional; default: 'https://s3.us-west-2.amazonaws.com/public.lob.com/assets/card_blank_horizontal.pdf'
16
+ description: 'Test Card', # optional
17
+ size: '2.125x3.375' # optional, default: '2.125x3.375'
18
+ )
19
+
20
+ # find a card
21
+ card_id = 'YOUR_CARD_ID'
22
+ pp lob.cards.find(
23
+ card_id # required
24
+ )
25
+
26
+ # update a card
27
+ card_id = 'YOUR_CARD_ID'
28
+ pp lob.cards.update(
29
+ card_id, # required
30
+ { description: 'Updated Test Card Desc' }
31
+ )
32
+
33
+ # delete a card
34
+ card_id = 'YOUR_CARD_ID'
35
+ pp lob.cards.destroy(
36
+ card_id # required
37
+ )
38
+
39
+ # create a card order
40
+ card_id = 'YOUR_CARD_ID'
41
+ pp lob.cards.create_order(
42
+ card_id, # required
43
+ { quantity: 10000 } # required
44
+ )
45
+
46
+ # List orders for a given card a card order
47
+ card_id = 'YOUR_CARD_ID'
48
+ pp lob.cards.list_orders(
49
+ card_id # required
50
+ )
51
+
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: 'test_799ff27291c166d10ba191902ad02fb059c')
6
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
6
7
 
7
8
  # create an address
8
9
  to_address = lob.addresses.create(
@@ -32,11 +33,11 @@ bank_account = lob.bank_accounts.create(
32
33
  signatory: "John Doe"
33
34
  )
34
35
 
35
- puts bank_account
36
+ pp bank_account
36
37
  lob.bank_accounts.verify(bank_account['id'], amounts: [23, 12])
37
38
 
38
39
  # send a $100 check using an already created bank and address
39
- puts lob.checks.create(
40
+ pp lob.checks.create(
40
41
  description: "Test Check",
41
42
  check_number: "10000",
42
43
  bank_account: bank_account["id"],
@@ -1,9 +1,10 @@
1
1
  $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
  require 'csv'
4
+ require 'pp'
4
5
 
5
6
  # Initialize Lob object
6
- lob = Lob::Client.new(api_key: 'test_799ff27291c166d10ba191902ad02fb059c')
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
7
8
 
8
9
  # Create a bank account
9
10
  bank_account = lob.bank_accounts.create(
@@ -43,5 +44,5 @@ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
43
44
  amount: row[7],
44
45
  memo: "For travel reimbursement"
45
46
  )
46
- puts check['url']
47
+ pp check['url']
47
48
  end
@@ -1,9 +1,10 @@
1
1
  $:.unshift File.expand_path("../../lib", File.dirname(__FILE__))
2
2
  require 'lob'
3
3
  require 'csv'
4
+ require 'pp'
4
5
 
5
6
  # Initialize Lob object
6
- lob = Lob::Client.new(api_key: 'test_799ff27291c166d10ba191902ad02fb059c')
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
7
8
 
8
9
  # Load the HTML from letter_template.html
9
10
  letter_html = File.open(File.expand_path('../letter_template.html', __FILE__)).read
@@ -36,5 +37,5 @@ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
36
37
  },
37
38
  color: false
38
39
  )
39
- puts letter['url']
40
+ pp letter['url']
40
41
  end
@@ -11,7 +11,7 @@
11
11
  font-family: 'Loved by the King';
12
12
  font-style: normal;
13
13
  font-weight: 400;
14
- src: url('https://s3-us-west-2.amazonaws.com/lob-assets/LovedbytheKing.ttf') format('truetype');
14
+ src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/lovedByTheKing/LovedbytheKing.ttf') format('truetype');
15
15
  }
16
16
 
17
17
  .text {
@@ -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: 'test_799ff27291c166d10ba191902ad02fb059c')
7
+ lob = Lob::Client.new(api_key: 'YOUR_API_KEY')
7
8
 
8
9
  # Load the HTML from postcard_front.html and postcard_back.html.
9
10
  front_html = File.open(File.expand_path('../postcard_front.html', __FILE__)).read
@@ -41,5 +42,5 @@ CSV.foreach(File.expand_path('../input.csv', __FILE__)) do |row|
41
42
  mileage: row[4]
42
43
  }
43
44
  )
44
- puts postcard['url']
45
+ pp postcard['url']
45
46
  end
@@ -1,7 +1,7 @@
1
- Peter,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,LightBlue,Jeep Wrangler,65000,Peter,123 Main Street,Apt. 101,San Francisco,CA,94107,US
2
- Marcus,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Bisque,Honda Pilot,65000,Marcus,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US
3
- Leore,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleGreen,Jeep Wrangler,50000,Leore,123 Test Street,Apt. 101,San Francisco,CA,94105,US
4
- Harry,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Thistle,Jeep Wrangler,50000,Harry,789 Elm Street,Apt. 101,San Francisco,CA,94107,US
5
- Elnaz,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleTurqoise,Jeep Wrangler,35000,Elnaz,111 Washington Street,Apt. 101,San Francisco,CA,94112,US
6
- Robin,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Wheat,Jeep Wrangler,35000,Robin,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US
7
- Russell,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,WhiteSmoke,Jeep Wrangler,15000,Russell,1212 Fourth Street,Apt. 101,San Francisco,CA,94166,US
1
+ Peter,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car2.jpg,LightBlue,Jeep Wrangler,65000,Peter,123 Main Street,Apt. 101,San Francisco,CA,94107,US
2
+ Marcus,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car.jpg,Bisque,Honda Pilot,65000,Marcus,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US
3
+ Leore,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car2.jpg,PaleGreen,Jeep Wrangler,50000,Leore,123 Test Street,Apt. 101,San Francisco,CA,94105,US
4
+ Harry,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car.jpg,Thistle,Jeep Wrangler,50000,Harry,789 Elm Street,Apt. 101,San Francisco,CA,94107,US
5
+ Elnaz,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car2.jpg,PaleTurqoise,Jeep Wrangler,35000,Elnaz,111 Washington Street,Apt. 101,San Francisco,CA,94112,US
6
+ Robin,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car.jpg,Wheat,Jeep Wrangler,35000,Robin,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US
7
+ Russell,https://s3-us-west-2.amazonaws.com/public.lob.com/assets/example_companies/df-car2.jpg,WhiteSmoke,Jeep Wrangler,15000,Russell,1212 Fourth Street,Apt. 101,San Francisco,CA,94166,US
@@ -6,7 +6,7 @@
6
6
  font-family: 'Arimo';
7
7
  font-style: normal;
8
8
  font-weight: 400;
9
- src: url('https://s3-us-west-2.amazonaws.com/lob-assets/Arimo-Regular.ttf') format('truetype');
9
+ src: url('https://s3-us-west-2.amazonaws.com/public.lob.com/fonts/arimo/Arimo-Regular.ttf') format('truetype');
10
10
  }
11
11
  body {
12
12
  width:11.25in;
@@ -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: 'test_799ff27291c166d10ba191902ad02fb059c')
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'],