lob 1.13.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +0 -4
- data/CHANGELOG.md +10 -0
- data/README.md +2 -7
- data/Rakefile +0 -19
- data/lib/lob.rb +2 -8
- data/lib/lob/v1/address.rb +3 -4
- data/lib/lob/v1/area.rb +1 -1
- data/lib/lob/v1/bank_account.rb +1 -9
- data/lib/lob/v1/check.rb +1 -5
- data/lib/lob/v1/country.rb +1 -1
- data/lib/lob/v1/job.rb +1 -9
- data/lib/lob/v1/letter.rb +1 -11
- data/lib/lob/v1/object.rb +1 -1
- data/lib/lob/v1/postcard.rb +1 -9
- data/lib/lob/v1/resource.rb +0 -16
- data/lib/lob/v1/route.rb +1 -1
- data/lib/lob/v1/service.rb +1 -1
- data/lib/lob/v1/setting.rb +1 -1
- data/lib/lob/v1/state.rb +1 -1
- data/lib/lob/version.rb +1 -1
- data/lob.gemspec +0 -1
- data/spec/lob/v1/address_spec.rb +21 -34
- data/spec/lob/v1/area_spec.rb +15 -31
- data/spec/lob/v1/bank_account_spec.rb +57 -80
- data/spec/lob/v1/check_spec.rb +44 -69
- data/spec/lob/v1/country_spec.rb +1 -4
- data/spec/lob/v1/job_spec.rb +114 -144
- data/spec/lob/v1/letter_spec.rb +39 -58
- data/spec/lob/v1/object_spec.rb +31 -49
- data/spec/lob/v1/postcard_spec.rb +65 -89
- data/spec/lob/v1/resource_spec.rb +1 -6
- data/spec/lob/v1/route_spec.rb +3 -7
- data/spec/lob/v1/service_spec.rb +1 -4
- data/spec/lob/v1/setting_spec.rb +4 -12
- data/spec/lob/v1/state_spec.rb +1 -4
- data/spec/lob_spec.rb +2 -6
- data/spec/samples/8.5x11.pdf +0 -0
- data/spec/samples/postcardback.pdf +2288 -1
- data/spec/samples/postcardfront.pdf +1550 -0
- data/spec/spec_helper.rb +0 -6
- metadata +8 -19
- data/lib/lob/v1/packaging.rb +0 -21
- data/spec/lob/v1/packaging_spec.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ceb1823e07362d2a8fbadfa23749bc78c6e49b8
|
4
|
+
data.tar.gz: 2ac14476bb2ba3c2ab7bd76bb9f0d644ce90dad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca4df9c124eb0ff74fb7c048ff8ae58a3ef7b5caa273cb21c56a461985d856197f34e8f751ee92cee5cccd5d01d00017728cc7009df63acc18a7dbeb2e620b3a
|
7
|
+
data.tar.gz: 080a64c572bed68a9c10ccd4e2a99b3ac93feb952003921fac1094bde74745fdd44594214a45317507aa31cfb1f574d930c079f20d5fd773461195c4457a9cc1
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
|
3
|
+
Version 2.0.0 introduces several breaking changes. It requires a minimum API version of `2015-04-11`.
|
4
|
+
|
5
|
+
* The lob-ruby gem no longer converts `city`, `state`, etc. parameters into `address_city`, `address_state`, etc. This change was made to be more consistent with the API and other Lob wrappers, and to prevent confusion.
|
6
|
+
* The wrapper now returns the raw JSON from the API in all `list` endpoints rather than just the `data` field in the response. This will allow access to additional fields like `count` and `offset`.
|
7
|
+
* The `packagings` endpoint is not longer supporter in the API, and therefore has been taken out of lob-ruby.
|
8
|
+
|
9
|
+
In addition to these breaking changes, the test suite was cleaned up by removing the unnecessary VCR gem and committing sample upload files to the repository rather than downloading them in rake task.
|
10
|
+
|
1
11
|
## [**1.13.0**](https://github.com/lob/lob-ruby/releases/tag/v1.13.0)
|
2
12
|
- [**#112**] (https://github.com/lob/lob-ruby/pull/112) removes Rack dependency
|
3
13
|
|
data/README.md
CHANGED
@@ -180,11 +180,7 @@ Make sure you have Ruby 2.0 installed. Copy and paste the following commands in
|
|
180
180
|
|
181
181
|
## Testing
|
182
182
|
|
183
|
-
|
184
|
-
|
185
|
-
bundle exec rake dev:setup
|
186
|
-
|
187
|
-
Tests are written using MiniTest, a testing library that comes with Ruby stdlib. The remote responses are tested using [vcr](https://github.com/vcr/vcr).
|
183
|
+
Tests are written using MiniTest, a testing library that comes with Ruby stdlib.
|
188
184
|
|
189
185
|
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.
|
190
186
|
|
@@ -192,8 +188,6 @@ Here's how you can run the tests:
|
|
192
188
|
|
193
189
|
LOB_API_KEY=your_test_api_key bundle exec rake test
|
194
190
|
|
195
|
-
When you make changes to failed tests, then clear out the vcr cassettes to re-record the http requests. You can clear out all the cassettes by running `rm -rf spec/vcr_cassettes`.
|
196
|
-
|
197
191
|
You can also configure, TravisCI for your fork of the repository and it'll run the tests for you, when you push.
|
198
192
|
|
199
193
|
=======================
|
@@ -201,3 +195,4 @@ You can also configure, TravisCI for your fork of the repository and it'll run t
|
|
201
195
|
Copyright © 2013 Lob.com
|
202
196
|
|
203
197
|
Released under the MIT License, which can be found in the repository in `LICENSE.txt`.
|
198
|
+
|
data/Rakefile
CHANGED
@@ -1,27 +1,8 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
3
|
|
4
|
-
|
5
4
|
Rake::TestTask.new do |t|
|
6
5
|
t.libs.push "lib", "spec"
|
7
6
|
t.test_files = FileList['spec/**/*_spec.rb']
|
8
7
|
t.verbose = true
|
9
8
|
end
|
10
|
-
|
11
|
-
|
12
|
-
namespace :dev do
|
13
|
-
|
14
|
-
desc "Download sample files to run tests with"
|
15
|
-
task :setup do
|
16
|
-
Dir.mkdir("spec/samples") unless File.exist?("spec/samples")
|
17
|
-
files = [
|
18
|
-
{url: "https://lob.com/postcardfront.pdf", name: "postcardfront.pdf"},
|
19
|
-
{url: "https://lob.com/postcardback.pdf", name: "postcardback.pdf"},
|
20
|
-
{url: "https://s3-us-west-2.amazonaws.com/lob-assets/letter-goblue.pdf", name: "8.5x11.pdf"},
|
21
|
-
]
|
22
|
-
files.each do |f|
|
23
|
-
system "curl #{f[:url]} -o spec/samples/#{f[:name]}"
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
data/lib/lob.rb
CHANGED
@@ -19,12 +19,6 @@ module Lob
|
|
19
19
|
alias :config :configure
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.require_options(options, *keys)
|
23
|
-
keys.each do |key|
|
24
|
-
raise ArgumentError.new(":#{key} is required") unless options.key?(key)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
22
|
def self.submit(method, url, parameters={})
|
29
23
|
clientVersion = Lob::VERSION
|
30
24
|
|
@@ -55,9 +49,9 @@ module Lob
|
|
55
49
|
def self.handle_api_error(error)
|
56
50
|
begin
|
57
51
|
response = JSON.parse(error.http_body)
|
58
|
-
message = response
|
52
|
+
message = response.fetch("error").fetch("message")
|
59
53
|
raise InvalidRequestError.new(message, error.http_code, error.http_body, error.response)
|
60
|
-
rescue JSON::ParserError
|
54
|
+
rescue JSON::ParserError, KeyError
|
61
55
|
raise LobError.new("Invalid response object: #{}", error.http_code, error.http_body)
|
62
56
|
end
|
63
57
|
end
|
data/lib/lob/v1/address.rb
CHANGED
@@ -7,12 +7,11 @@ module Lob
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def verify(options={})
|
10
|
-
|
11
|
-
Lob.submit(:post, address_verify_url, params)
|
10
|
+
Lob.submit(:post, address_verify_url, options)
|
12
11
|
end
|
13
12
|
|
14
13
|
def list(options={})
|
15
|
-
Lob.submit(:get, address_url, options)
|
14
|
+
Lob.submit(:get, address_url, options)
|
16
15
|
end
|
17
16
|
|
18
17
|
def find(address_id)
|
@@ -20,7 +19,7 @@ module Lob
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def create(options = {})
|
23
|
-
Lob.submit :post, address_url,
|
22
|
+
Lob.submit :post, address_url, options
|
24
23
|
end
|
25
24
|
|
26
25
|
def destroy(address_id)
|
data/lib/lob/v1/area.rb
CHANGED
data/lib/lob/v1/bank_account.rb
CHANGED
@@ -7,7 +7,7 @@ module Lob
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def list(options={})
|
10
|
-
Lob.submit(:get, bank_account_url, options)
|
10
|
+
Lob.submit(:get, bank_account_url, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def find(bank_account_id)
|
@@ -15,14 +15,6 @@ module Lob
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def create(options = {})
|
18
|
-
if !options[:bank_address].is_a?(String)
|
19
|
-
options[:bank_address] = @resource.format_address_params(options[:bank_address])
|
20
|
-
end
|
21
|
-
|
22
|
-
if !options[:account_address].is_a?(String)
|
23
|
-
options[:account_address] = @resource.format_address_params(options[:account_address])
|
24
|
-
end
|
25
|
-
|
26
18
|
Lob.submit :post, bank_account_url, options
|
27
19
|
end
|
28
20
|
|
data/lib/lob/v1/check.rb
CHANGED
@@ -7,7 +7,7 @@ module Lob
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def list(options={})
|
10
|
-
Lob.submit(:get, check_url, options)
|
10
|
+
Lob.submit(:get, check_url, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def find(check_id)
|
@@ -15,10 +15,6 @@ module Lob
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def create(options = {})
|
18
|
-
if !options[:to].is_a?(String)
|
19
|
-
options[:to] = @resource.format_address_params(options[:to])
|
20
|
-
end
|
21
|
-
|
22
18
|
Lob.submit :post, check_url, options
|
23
19
|
end
|
24
20
|
|
data/lib/lob/v1/country.rb
CHANGED
data/lib/lob/v1/job.rb
CHANGED
@@ -7,7 +7,7 @@ module Lob
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def list(options={})
|
10
|
-
Lob.submit(:get, job_url, options)
|
10
|
+
Lob.submit(:get, job_url, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def find(job_id)
|
@@ -24,14 +24,6 @@ module Lob
|
|
24
24
|
end
|
25
25
|
options.delete(:objects)
|
26
26
|
|
27
|
-
if options[:to] && !options[:to].is_a?(String)
|
28
|
-
options[:to] = @resource.format_address_params(options[:to])
|
29
|
-
end
|
30
|
-
|
31
|
-
if options[:from] && !options[:from].is_a?(String)
|
32
|
-
options[:from] = @resource.format_address_params(options[:from])
|
33
|
-
end
|
34
|
-
|
35
27
|
Lob.submit :post, job_url, options
|
36
28
|
end
|
37
29
|
|
data/lib/lob/v1/letter.rb
CHANGED
@@ -7,7 +7,7 @@ module Lob
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def list(options={})
|
10
|
-
Lob.submit(:get, letter_url, options)
|
10
|
+
Lob.submit(:get, letter_url, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def find(job_id)
|
@@ -15,19 +15,9 @@ module Lob
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def create(options = {})
|
18
|
-
|
19
|
-
if options[:to] && !options[:to].is_a?(String)
|
20
|
-
options[:to] = @resource.format_address_params(options[:to])
|
21
|
-
end
|
22
|
-
|
23
|
-
if options[:from] && !options[:from].is_a?(String)
|
24
|
-
options[:from] = @resource.format_address_params(options[:from])
|
25
|
-
end
|
26
|
-
|
27
18
|
Lob.submit :post, letter_url, options
|
28
19
|
end
|
29
20
|
|
30
|
-
|
31
21
|
private
|
32
22
|
|
33
23
|
def letter_url(job_id = nil)
|
data/lib/lob/v1/object.rb
CHANGED
data/lib/lob/v1/postcard.rb
CHANGED
@@ -7,7 +7,7 @@ module Lob
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def list(options={})
|
10
|
-
Lob.submit(:get, postcard_url, options)
|
10
|
+
Lob.submit(:get, postcard_url, options)
|
11
11
|
end
|
12
12
|
|
13
13
|
def find(postcard_id)
|
@@ -15,14 +15,6 @@ module Lob
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def create(options = {})
|
18
|
-
if options[:to] && !options[:to].is_a?(String)
|
19
|
-
options[:to] = @resource.format_address_params(options[:to])
|
20
|
-
end
|
21
|
-
|
22
|
-
if options[:from] && !options[:from].is_a?(String)
|
23
|
-
options[:from] = @resource.format_address_params(options[:from])
|
24
|
-
end
|
25
|
-
|
26
18
|
Lob.submit :post, postcard_url, options
|
27
19
|
end
|
28
20
|
|
data/lib/lob/v1/resource.rb
CHANGED
@@ -72,22 +72,6 @@ module Lob
|
|
72
72
|
"#{base_url}/#{resource_type}#{'/' + resource_id if resource_id}"
|
73
73
|
end
|
74
74
|
|
75
|
-
#NOTE to format address param names into API-compatible ones
|
76
|
-
def format_address_params(params, check_required_options=true)
|
77
|
-
if check_required_options
|
78
|
-
Lob.require_options(params, :name, :address_line1, :city, :state, :zip, :country)
|
79
|
-
end
|
80
|
-
|
81
|
-
new_params = params.clone
|
82
|
-
|
83
|
-
[:city, :state, :zip, :country].each do |option|
|
84
|
-
new_params["address_#{option}".to_sym] = params[option] if params[option]
|
85
|
-
new_params.delete(option)
|
86
|
-
end
|
87
|
-
|
88
|
-
new_params
|
89
|
-
end
|
90
|
-
|
91
75
|
end
|
92
76
|
end
|
93
77
|
end
|
data/lib/lob/v1/route.rb
CHANGED
data/lib/lob/v1/service.rb
CHANGED
data/lib/lob/v1/setting.rb
CHANGED
data/lib/lob/v1/state.rb
CHANGED
data/lib/lob/version.rb
CHANGED
data/lob.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "minitest", "~> 5.6.1"
|
28
28
|
spec.add_development_dependency "webmock", "~> 1.2"
|
29
29
|
spec.add_development_dependency "travis-lint", "~> 2.0.0"
|
30
|
-
spec.add_development_dependency "vcr", "~> 2.9.2"
|
31
30
|
spec.add_development_dependency "coveralls", "~> 0.8.1"
|
32
31
|
spec.add_development_dependency "simplecov", "~> 0.10.0"
|
33
32
|
spec.add_development_dependency "pry", "~> 0.10.0"
|
data/spec/lob/v1/address_spec.rb
CHANGED
@@ -6,10 +6,10 @@ describe Lob::V1::Address do
|
|
6
6
|
{
|
7
7
|
name: "John Doe",
|
8
8
|
address_line1: "325 Berry Street",
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
address_city: "San Francisco",
|
10
|
+
address_state: "CA",
|
11
|
+
address_country: "US",
|
12
|
+
address_zip: 94158
|
13
13
|
}
|
14
14
|
}
|
15
15
|
|
@@ -18,62 +18,49 @@ describe Lob::V1::Address do
|
|
18
18
|
describe "verify" do
|
19
19
|
|
20
20
|
it "should verify an address" do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
result["address"]["address_country"].must_equal("US")
|
30
|
-
end
|
21
|
+
result = subject.addresses.verify(
|
22
|
+
address_line1: sample_params[:address_line1],
|
23
|
+
address_city: sample_params[:address_city],
|
24
|
+
address_state: sample_params[:address_state],
|
25
|
+
address_zip: sample_params[:address_zip]
|
26
|
+
)
|
27
|
+
|
28
|
+
result["address"]["address_country"].must_equal("US")
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
34
32
|
|
35
33
|
describe "list" do
|
36
34
|
it "should list addresses" do
|
37
|
-
|
38
|
-
new_address = subject.addresses.create sample_params
|
39
|
-
|
40
|
-
list_result = subject.addresses.list
|
41
|
-
assert /#{new_address["name"]}/i =~ list_result.to_s
|
42
|
-
end
|
35
|
+
assert subject.addresses.list["object"] == "list"
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
46
39
|
|
47
40
|
describe "create" do
|
48
41
|
it "should create an address" do
|
49
|
-
|
50
|
-
|
51
|
-
assert /#{result["name"]}/i =~ sample_params[:name]
|
52
|
-
end
|
42
|
+
result = subject.addresses.create sample_params
|
43
|
+
assert /#{result["name"]}/i =~ sample_params[:name]
|
53
44
|
end
|
54
45
|
end
|
55
46
|
|
56
47
|
|
57
48
|
describe "find" do
|
58
49
|
it "should find an address" do
|
59
|
-
|
60
|
-
new_address = subject.addresses.create sample_params
|
50
|
+
new_address = subject.addresses.create sample_params
|
61
51
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
52
|
+
find_result = subject.addresses.find(new_address["id"])
|
53
|
+
assert /#{find_result["name"]}/i =~ sample_params[:name]
|
65
54
|
end
|
66
55
|
end
|
67
56
|
|
68
57
|
|
69
58
|
describe "destroy" do
|
70
59
|
it "should delete an address" do
|
71
|
-
|
72
|
-
new_address = subject.addresses.create sample_params
|
60
|
+
new_address = subject.addresses.create sample_params
|
73
61
|
|
74
|
-
|
75
|
-
|
76
|
-
end
|
62
|
+
delete_result = subject.addresses.destroy(new_address["id"])
|
63
|
+
assert_equal(new_address["id"], delete_result["id"])
|
77
64
|
end
|
78
65
|
end
|
79
66
|
end
|