lob 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +67 -5
- data/lib/lob.rb +13 -3
- data/lib/lob/v1/bank_account.rb +45 -0
- data/lib/lob/v1/check.rb +36 -0
- data/lib/lob/v1/country.rb +21 -0
- data/lib/lob/v1/job.rb +10 -2
- data/lib/lob/v1/resource.rb +22 -3
- data/lob.gemspec +1 -1
- data/spec/lob/v1/address_spec.rb +40 -14
- data/spec/lob/v1/bank_account_spec.rb +94 -0
- data/spec/lob/v1/check_spec.rb +93 -0
- data/spec/lob/v1/country_spec.rb +16 -0
- data/spec/lob/v1/job_spec.rb +51 -4
- metadata +11 -3
- data/lib/lob/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3b68ba605652bb33bfc8268a5206535c789e782
|
4
|
+
data.tar.gz: 021b89f967b4068c187dda6e28ba0596f60b8eed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31aa41cf8e88f3539f9b55a79b94e263531dcade74e788a93aa13f691e9319f48c6a29a3ae1802ee34f9b5fb2f56d8c06af5ba15731dbb09467a25eff2516b62
|
7
|
+
data.tar.gz: 9b7c0e47589e6967f3fda9f11b5012045d48da12c8c59cc5ee5aa387f3520885c9dc3b5f8928b0dbd5c769fc02f0f4c9d6d708f8816eb8bc966c05d0c44c9a1a
|
data/README.md
CHANGED
@@ -119,11 +119,12 @@ end
|
|
119
119
|
```ruby
|
120
120
|
# name, to-address and object are the arguments
|
121
121
|
# to-address can be specified as an address-id
|
122
|
-
@lob.jobs.create("New Cool Posters", "to-address-id", "object-id")
|
122
|
+
@lob.jobs.create("New Cool Posters", "from-address-id", "to-address-id", "object-id")
|
123
123
|
|
124
124
|
# to-address can also be specified as address params to create new address
|
125
125
|
@lob.jobs.create(
|
126
126
|
"New Cool Posters",
|
127
|
+
{name: "FromAddress", address_line1: "120, 6th Ave", city: "Boston", country: "USA", zip: 12345},
|
127
128
|
{name: "ToAddress", address_line1: "120, 6th Ave", city: "Boston", country: "USA", zip: 12345},
|
128
129
|
"object-id"
|
129
130
|
)
|
@@ -132,6 +133,7 @@ end
|
|
132
133
|
# and other options like packaging_id an setting_id
|
133
134
|
@lob.jobs.create(
|
134
135
|
"New Cool Posters",
|
136
|
+
"from-address-id",
|
135
137
|
"to-address-id",
|
136
138
|
"object-id",
|
137
139
|
{
|
@@ -140,6 +142,16 @@ end
|
|
140
142
|
setting_id: "some-setting-id"
|
141
143
|
}
|
142
144
|
)
|
145
|
+
|
146
|
+
# Or add a job with multiple objects
|
147
|
+
|
148
|
+
@lob.jobs.create(
|
149
|
+
"New Cool Posters",
|
150
|
+
"from-address-id",
|
151
|
+
{name: "ToAddress", address_line1: "120, 6th Ave", city: "Boston", country: "USA", zip: 12345},
|
152
|
+
["object-id", "another-object-id"]
|
153
|
+
)
|
154
|
+
|
143
155
|
```
|
144
156
|
|
145
157
|
#### List jobs
|
@@ -263,13 +275,63 @@ You'll have to specify either the `message` option or the `back` option.
|
|
263
275
|
@lob.services.list
|
264
276
|
```
|
265
277
|
|
266
|
-
###
|
278
|
+
### Bank accounts
|
279
|
+
|
280
|
+
#### List bank accounts
|
281
|
+
|
282
|
+
```ruby
|
283
|
+
# returns a list of accounts
|
284
|
+
@lob.bank_accounts.list
|
285
|
+
```
|
286
|
+
|
287
|
+
#### Add a bank account
|
288
|
+
|
289
|
+
```ruby
|
290
|
+
bank_address = {name: "ToAddress", address_line1: "120, 6th Ave", city: "Boston", country: "USA", zip: 12345}
|
291
|
+
account_address = {name: "ToAddress", address_line1: "120, 6th Ave", city: "Boston", country: "USA", zip: 12345}
|
292
|
+
|
293
|
+
# Pass address params or address IDs
|
294
|
+
# The 5th argument is the options argument and is optional
|
295
|
+
@lob.bank_accounts.create("routing_number", bank_address, "account_number", account_address)
|
296
|
+
```
|
297
|
+
|
298
|
+
#### Find a bank account
|
299
|
+
|
300
|
+
```ruby
|
301
|
+
@lob.bank_accounts.find "bank-account-id"
|
302
|
+
```
|
303
|
+
|
304
|
+
### Checks
|
305
|
+
|
306
|
+
#### Create a check
|
307
|
+
|
308
|
+
```ruby
|
309
|
+
# Transfer $5000 to a bank account.
|
310
|
+
@lob.checks.create("bank-account-id", "to-address-ID", 5000)
|
311
|
+
|
312
|
+
# For the "to" address, you can pass params or an address ID
|
313
|
+
# You can also specify an optional 4th argument, with other options.
|
314
|
+
```
|
315
|
+
|
316
|
+
#### List checks
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
@lob.checks.list
|
320
|
+
```
|
321
|
+
|
322
|
+
#### Find a check
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
@lob.checks.find("check-id")
|
326
|
+
```
|
327
|
+
|
328
|
+
### Supported countries
|
267
329
|
|
268
|
-
#### List
|
330
|
+
#### List supported countries
|
269
331
|
|
270
332
|
```ruby
|
271
|
-
# returns a list of
|
272
|
-
@lob.
|
333
|
+
# returns a list of countries
|
334
|
+
@lob.countries.list
|
273
335
|
```
|
274
336
|
|
275
337
|
## Developing
|
data/lib/lob.rb
CHANGED
@@ -10,7 +10,9 @@ require "lob/v1/packaging"
|
|
10
10
|
require "lob/v1/postcard"
|
11
11
|
require "lob/v1/service"
|
12
12
|
require "lob/v1/setting"
|
13
|
-
|
13
|
+
require "lob/v1/country"
|
14
|
+
require "lob/v1/check"
|
15
|
+
require "lob/v1/bank_account"
|
14
16
|
|
15
17
|
module Lob
|
16
18
|
|
@@ -43,8 +45,16 @@ module Lob
|
|
43
45
|
error_message = nil
|
44
46
|
raise e unless e.respond_to? :http_body
|
45
47
|
begin
|
46
|
-
|
47
|
-
|
48
|
+
json = JSON(e.http_body)
|
49
|
+
|
50
|
+
if json.has_key? 'errors'
|
51
|
+
error_message = json["errors"].first.values.first
|
52
|
+
elsif json.has_key? 'message'
|
53
|
+
error_message = json["message"]
|
54
|
+
else
|
55
|
+
error_message = "Unknown error: #{json}"
|
56
|
+
end
|
57
|
+
rescue => e
|
48
58
|
raise e
|
49
59
|
end
|
50
60
|
raise Lob::Error.new(error_message)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Lob
|
2
|
+
module V1
|
3
|
+
class BankAccount
|
4
|
+
|
5
|
+
def initialize(resource)
|
6
|
+
@resource = resource
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(options={})
|
10
|
+
Lob.submit(:get, bank_account_url, options)["data"] || []
|
11
|
+
end
|
12
|
+
|
13
|
+
def find(bank_account_id)
|
14
|
+
Lob.submit :get, bank_account_url(bank_account_id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(routing_number, bank_address, account_number, account_address, options = {})
|
18
|
+
options = {
|
19
|
+
routing_number: routing_number,
|
20
|
+
bank_address: bank_address,
|
21
|
+
account_number: account_number,
|
22
|
+
account_address: account_address
|
23
|
+
}.merge(options)
|
24
|
+
|
25
|
+
if !options[:bank_address].is_a?(String)
|
26
|
+
options[:bank_address] = @resource.format_address_params(options[:bank_address])
|
27
|
+
end
|
28
|
+
|
29
|
+
if !options[:account_address].is_a?(String)
|
30
|
+
options[:account_address] = @resource.format_address_params(options[:account_address])
|
31
|
+
end
|
32
|
+
|
33
|
+
Lob.submit :post, bank_account_url, options
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def bank_account_url(bank_account_id = nil)
|
40
|
+
@resource.construct_url("bank_accounts", bank_account_id)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/lob/v1/check.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Lob
|
2
|
+
module V1
|
3
|
+
class Check
|
4
|
+
|
5
|
+
def initialize(resource)
|
6
|
+
@resource = resource
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(options={})
|
10
|
+
Lob.submit(:get, check_url, options)["data"] || []
|
11
|
+
end
|
12
|
+
|
13
|
+
def find(check_id)
|
14
|
+
Lob.submit :get, check_url(check_id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(bank_account, to, amount, options = {})
|
18
|
+
params = { bank_account: bank_account, to: to, amount: amount }.merge(options)
|
19
|
+
|
20
|
+
if !params[:to].is_a?(String)
|
21
|
+
params[:to] = @resource.format_address_params(params[:to])
|
22
|
+
end
|
23
|
+
|
24
|
+
Lob.submit :post, check_url, params
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def check_url(check_id = nil)
|
31
|
+
@resource.construct_url("checks", check_id)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Lob
|
2
|
+
module V1
|
3
|
+
class Country
|
4
|
+
|
5
|
+
def initialize(resource)
|
6
|
+
@resource = resource
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(options={})
|
10
|
+
Lob.submit(:get, country_url, options)["data"] || []
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def country_url
|
16
|
+
@resource.construct_url("countries")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/lob/v1/job.rb
CHANGED
@@ -14,8 +14,16 @@ module Lob
|
|
14
14
|
Lob.submit :get, job_url(job_id)
|
15
15
|
end
|
16
16
|
|
17
|
-
def create(name, to,
|
18
|
-
options = { name: name, to: to,
|
17
|
+
def create(name, from, to, objects, options = {})
|
18
|
+
options = { name: name, to: to, from: from}.merge(options)
|
19
|
+
|
20
|
+
if objects.is_a?(Array)
|
21
|
+
objects.each_with_index do |object, index|
|
22
|
+
options["object#{index}"] = object
|
23
|
+
end
|
24
|
+
else
|
25
|
+
options["object1"] = objects
|
26
|
+
end
|
19
27
|
|
20
28
|
if options[:to] && !options[:to].is_a?(String)
|
21
29
|
options[:to] = @resource.format_address_params(options[:to])
|
data/lib/lob/v1/resource.rb
CHANGED
@@ -36,6 +36,23 @@ module Lob
|
|
36
36
|
Lob::V1::Setting.new(self)
|
37
37
|
end
|
38
38
|
|
39
|
+
def countries
|
40
|
+
Lob::V1::Country.new(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def checks
|
44
|
+
Lob::V1::Check.new(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def cheques
|
48
|
+
Lob::V1::Check.new(self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def bank_accounts
|
52
|
+
Lob::V1::BankAccount.new(self)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
39
56
|
def base_url
|
40
57
|
"#{@options[:protocol]}://#{@options[:api_key]}:@#{@options[:api_host]}/v1"
|
41
58
|
end
|
@@ -50,12 +67,14 @@ module Lob
|
|
50
67
|
Lob.require_options(params, :name, :address_line1, :city, :state, :zip, :country)
|
51
68
|
end
|
52
69
|
|
70
|
+
new_params = params.clone
|
71
|
+
|
53
72
|
[:city, :state, :zip, :country].each do |option|
|
54
|
-
|
55
|
-
|
73
|
+
new_params["address_#{option}".to_sym] = params[option] if params[option]
|
74
|
+
new_params.delete(option)
|
56
75
|
end
|
57
76
|
|
58
|
-
|
77
|
+
new_params
|
59
78
|
end
|
60
79
|
|
61
80
|
end
|
data/lob.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "lob"
|
8
|
-
spec.version = "1.0.
|
8
|
+
spec.version = "1.0.5"
|
9
9
|
spec.authors = ["Akash Manohar J"]
|
10
10
|
spec.email = ["akash@akash.im"]
|
11
11
|
spec.description = %q{Lob API Ruby wrapper}
|
data/spec/lob/v1/address_spec.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Lob::V1::Address do
|
4
|
+
let(:sample_params2) {
|
5
|
+
{
|
6
|
+
name: "Russell Smith",
|
7
|
+
email: "test@test.com",
|
8
|
+
address_line1: "673 Brannan",
|
9
|
+
city: "San Francisco",
|
10
|
+
state: "CA",
|
11
|
+
country: "US",
|
12
|
+
zip: 94107
|
13
|
+
}
|
14
|
+
}
|
4
15
|
|
5
|
-
|
6
|
-
|
16
|
+
let(:sample_params) {
|
17
|
+
{
|
7
18
|
name: "Test",
|
8
19
|
email: "test@test.com",
|
9
20
|
address_line1: "220 WILLIAM T MORRISSEY BLVD",
|
@@ -12,18 +23,33 @@ describe Lob::V1::Address do
|
|
12
23
|
country: "US",
|
13
24
|
zip: 02125
|
14
25
|
}
|
15
|
-
|
26
|
+
}
|
16
27
|
|
17
28
|
subject { Lob(api_key: ENV["LOB_API_KEY"], api_version: "v1") }
|
18
29
|
|
19
30
|
describe "verify" do
|
31
|
+
it "should verify an address" do
|
32
|
+
assert_raises(Lob::Error) do
|
33
|
+
VCR.use_cassette('verify_address2') do
|
34
|
+
result = subject.addresses.verify(
|
35
|
+
address_line1: sample_params2[:address_line1],
|
36
|
+
city: sample_params2[:city],
|
37
|
+
state: sample_params2[:state],
|
38
|
+
zip: sample_params2[:zip]
|
39
|
+
)
|
40
|
+
|
41
|
+
result["address"]["address_country"].must_equal("US")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
20
46
|
it "should verify an address" do
|
21
47
|
VCR.use_cassette('verify_address') do
|
22
48
|
result = subject.addresses.verify(
|
23
|
-
address_line1:
|
24
|
-
city:
|
25
|
-
state:
|
26
|
-
zip:
|
49
|
+
address_line1: sample_params[:address_line1],
|
50
|
+
city: sample_params[:city],
|
51
|
+
state: sample_params[:state],
|
52
|
+
zip: sample_params[:zip]
|
27
53
|
)
|
28
54
|
|
29
55
|
result["address"]["address_country"].must_equal("US")
|
@@ -35,10 +61,10 @@ describe Lob::V1::Address do
|
|
35
61
|
describe "list" do
|
36
62
|
it "should list addresses" do
|
37
63
|
VCR.use_cassette('list_addresses') do
|
38
|
-
new_address = subject.addresses.create
|
64
|
+
new_address = subject.addresses.create sample_params
|
39
65
|
|
40
66
|
list_result = subject.addresses.list
|
41
|
-
assert /#{new_address["name"]}/ =~ list_result.to_s
|
67
|
+
assert /#{new_address["name"]}/i =~ list_result.to_s
|
42
68
|
end
|
43
69
|
end
|
44
70
|
end
|
@@ -47,8 +73,8 @@ describe Lob::V1::Address do
|
|
47
73
|
describe "create" do
|
48
74
|
it "should create an address" do
|
49
75
|
VCR.use_cassette('create_address') do
|
50
|
-
result = subject.addresses.create
|
51
|
-
result["name"]
|
76
|
+
result = subject.addresses.create sample_params
|
77
|
+
assert /#{result["name"]}/i =~ sample_params[:name]
|
52
78
|
end
|
53
79
|
end
|
54
80
|
end
|
@@ -57,10 +83,10 @@ describe Lob::V1::Address do
|
|
57
83
|
describe "find" do
|
58
84
|
it "should find an address" do
|
59
85
|
VCR.use_cassette('find_address') do
|
60
|
-
new_address = subject.addresses.create
|
86
|
+
new_address = subject.addresses.create sample_params
|
61
87
|
|
62
88
|
find_result = subject.addresses.find(new_address["id"])
|
63
|
-
find_result["name"]
|
89
|
+
assert /#{find_result["name"]}/i =~ sample_params[:name]
|
64
90
|
end
|
65
91
|
end
|
66
92
|
end
|
@@ -69,7 +95,7 @@ describe Lob::V1::Address do
|
|
69
95
|
describe "destroy" do
|
70
96
|
it "should delete an address" do
|
71
97
|
VCR.use_cassette('delete_address') do
|
72
|
-
new_address = subject.addresses.create
|
98
|
+
new_address = subject.addresses.create sample_params
|
73
99
|
|
74
100
|
delete_result = subject.addresses.destroy(new_address["id"])
|
75
101
|
assert /has been deleted/ =~ delete_result["message"]
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::V1::BankAccount do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@sample_address_params = {
|
7
|
+
name: "TestAddress",
|
8
|
+
email: "test@test.com",
|
9
|
+
address_line1: "123 Test Street",
|
10
|
+
address_line2: "Unit 199",
|
11
|
+
city: "Mountain View",
|
12
|
+
state: "CA",
|
13
|
+
country: "US",
|
14
|
+
zip: 94085
|
15
|
+
}
|
16
|
+
|
17
|
+
@sample_bank_account_params = {
|
18
|
+
routing_number: "123456789",
|
19
|
+
account_number: "123456789"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
subject { Lob(api_key: ENV["LOB_API_KEY"], api_version: "v1") }
|
24
|
+
|
25
|
+
describe "list" do
|
26
|
+
it "should list bank accounts" do
|
27
|
+
VCR.use_cassette('list_bank_accounts') do
|
28
|
+
|
29
|
+
new_bank_account = subject.bank_accounts.create(
|
30
|
+
@sample_bank_account_params[:routing_number],
|
31
|
+
@sample_address_params.clone,
|
32
|
+
@sample_bank_account_params[:account_number],
|
33
|
+
@sample_address_params.clone
|
34
|
+
)
|
35
|
+
|
36
|
+
list_result = subject.bank_accounts.list
|
37
|
+
assert /#{new_bank_account["id"]}/i =~ list_result.to_s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
describe "create" do
|
44
|
+
it "should create a bank account with address_id" do
|
45
|
+
VCR.use_cassette('create_bank_account_with_address_id') do
|
46
|
+
new_address = subject.addresses.create @sample_address_params
|
47
|
+
|
48
|
+
result = subject.bank_accounts.create(
|
49
|
+
@sample_bank_account_params[:routing_number],
|
50
|
+
new_address["id"],
|
51
|
+
@sample_bank_account_params[:account_number],
|
52
|
+
new_address["id"]
|
53
|
+
)
|
54
|
+
|
55
|
+
result["account_number"].must_equal(@sample_bank_account_params[:account_number])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
it "should create a bank account with address params" do
|
61
|
+
VCR.use_cassette('create_bank_account_with_address_params') do
|
62
|
+
|
63
|
+
result = subject.bank_accounts.create(
|
64
|
+
@sample_bank_account_params[:routing_number],
|
65
|
+
@sample_address_params.clone,
|
66
|
+
@sample_bank_account_params[:account_number],
|
67
|
+
@sample_address_params.clone
|
68
|
+
)
|
69
|
+
|
70
|
+
result["account_number"].must_equal(@sample_bank_account_params[:account_number])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
describe "find" do
|
77
|
+
it "should find a bank account" do
|
78
|
+
VCR.use_cassette('find_bank_account') do
|
79
|
+
new_address = subject.addresses.create @sample_address_params
|
80
|
+
|
81
|
+
new_bank_account = subject.bank_accounts.create(
|
82
|
+
@sample_bank_account_params[:routing_number],
|
83
|
+
new_address["id"],
|
84
|
+
@sample_bank_account_params[:account_number],
|
85
|
+
new_address["id"]
|
86
|
+
)
|
87
|
+
|
88
|
+
result = subject.bank_accounts.find(new_bank_account["id"])
|
89
|
+
result["id"].must_equal(new_bank_account["id"])
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::V1::Check do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@sample_address_params = {
|
7
|
+
name: "TestAddress",
|
8
|
+
email: "test@test.com",
|
9
|
+
address_line1: "123 Test Street",
|
10
|
+
address_line2: "Unit 199",
|
11
|
+
city: "Mountain View",
|
12
|
+
state: "CA",
|
13
|
+
country: "US",
|
14
|
+
zip: 94085
|
15
|
+
}
|
16
|
+
|
17
|
+
@sample_bank_account_params = {
|
18
|
+
routing_number: "123456789",
|
19
|
+
account_number: "123456789"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
subject { Lob(api_key: ENV["LOB_API_KEY"], api_version: "v1") }
|
24
|
+
|
25
|
+
describe "list" do
|
26
|
+
it "should list checks" do
|
27
|
+
VCR.use_cassette('list_checks') do
|
28
|
+
new_address = subject.addresses.create @sample_address_params
|
29
|
+
|
30
|
+
new_bank_account = subject.bank_accounts.create(
|
31
|
+
@sample_bank_account_params[:routing_number],
|
32
|
+
@sample_address_params,
|
33
|
+
@sample_bank_account_params[:account_number],
|
34
|
+
@sample_address_params
|
35
|
+
)
|
36
|
+
|
37
|
+
|
38
|
+
new_check = subject.checks.create(
|
39
|
+
new_bank_account["id"], @sample_address_params, 2000
|
40
|
+
)
|
41
|
+
|
42
|
+
list_result = subject.checks.list
|
43
|
+
assert /#{new_check["id"]}/i =~ list_result.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
describe "create" do
|
50
|
+
it "should create a check with bank account id" do
|
51
|
+
VCR.use_cassette('create_check_with_bank_account_id') do
|
52
|
+
new_address = subject.addresses.create @sample_address_params
|
53
|
+
|
54
|
+
new_bank_account = subject.bank_accounts.create(
|
55
|
+
@sample_bank_account_params[:routing_number],
|
56
|
+
@sample_address_params,
|
57
|
+
@sample_bank_account_params[:account_number],
|
58
|
+
@sample_address_params
|
59
|
+
)
|
60
|
+
|
61
|
+
result = subject.checks.create(
|
62
|
+
new_bank_account["id"], new_address["id"], "2000"
|
63
|
+
)
|
64
|
+
|
65
|
+
result["amount"].to_s.must_equal("2000.00")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
describe "find" do
|
72
|
+
it "should find a check" do
|
73
|
+
VCR.use_cassette('find_check') do
|
74
|
+
new_address = subject.addresses.create @sample_address_params
|
75
|
+
|
76
|
+
new_bank_account = subject.bank_accounts.create(
|
77
|
+
@sample_bank_account_params[:routing_number],
|
78
|
+
@sample_address_params,
|
79
|
+
@sample_bank_account_params[:account_number],
|
80
|
+
@sample_address_params
|
81
|
+
)
|
82
|
+
|
83
|
+
new_check = subject.checks.create(
|
84
|
+
new_bank_account["id"], new_address["id"], 2000
|
85
|
+
)
|
86
|
+
|
87
|
+
result = subject.checks.find(new_check["id"])
|
88
|
+
result["id"].must_equal(new_check["id"])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lob::V1::Country do
|
4
|
+
|
5
|
+
subject { Lob(api_key: ENV["LOB_API_KEY"], api_version: "v1") }
|
6
|
+
|
7
|
+
describe "list" do
|
8
|
+
it "should list countries" do
|
9
|
+
VCR.use_cassette('list_countries') do
|
10
|
+
result = subject.countries.list
|
11
|
+
result.length.must_be :>, 0
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/spec/lob/v1/job_spec.rb
CHANGED
@@ -36,6 +36,7 @@ describe Lob::V1::Job do
|
|
36
36
|
new_job = subject.jobs.create(
|
37
37
|
@sample_job_params[:name],
|
38
38
|
new_address["id"],
|
39
|
+
new_address["id"],
|
39
40
|
new_object["id"]
|
40
41
|
)
|
41
42
|
|
@@ -58,11 +59,42 @@ describe Lob::V1::Job do
|
|
58
59
|
@test_setting_id
|
59
60
|
)
|
60
61
|
|
61
|
-
result = subject.jobs.create(@sample_job_params[:name], new_address["id"], new_object["id"])
|
62
|
+
result = subject.jobs.create(@sample_job_params[:name], new_address["id"], new_address["id"], new_object["id"])
|
62
63
|
result["name"].must_equal(@sample_job_params[:name])
|
63
64
|
end
|
64
65
|
end
|
65
66
|
|
67
|
+
|
68
|
+
it "should be able to create multiple jobs" do
|
69
|
+
VCR.use_cassette('create_multiple_jobs') do
|
70
|
+
new_address = subject.addresses.create @sample_address_params
|
71
|
+
|
72
|
+
settings_list = subject.settings.list
|
73
|
+
|
74
|
+
new_object_params = {
|
75
|
+
name: @sample_object_params[:name],
|
76
|
+
file: "https://www.lob.com/test.pdf",
|
77
|
+
setting_id: @test_setting_id
|
78
|
+
}
|
79
|
+
|
80
|
+
another_object_params = {
|
81
|
+
name: "Another #{@sample_object_params[:name]}",
|
82
|
+
file: "https://www.lob.com/test.pdf",
|
83
|
+
setting_id: @test_setting_id
|
84
|
+
}
|
85
|
+
|
86
|
+
result = subject.jobs.create(
|
87
|
+
@sample_job_params[:name],
|
88
|
+
new_address["id"],
|
89
|
+
new_address["id"],
|
90
|
+
[new_object_params, another_object_params]
|
91
|
+
)
|
92
|
+
|
93
|
+
result["name"].must_equal(@sample_job_params[:name])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
66
98
|
it "should create a job with address params" do
|
67
99
|
VCR.use_cassette('create_job_with_address_params') do
|
68
100
|
settings_list = subject.settings.list
|
@@ -72,7 +104,12 @@ describe Lob::V1::Job do
|
|
72
104
|
@test_setting_id
|
73
105
|
)
|
74
106
|
|
75
|
-
result = subject.jobs.create(
|
107
|
+
result = subject.jobs.create(
|
108
|
+
@sample_job_params[:name],
|
109
|
+
@sample_address_params,
|
110
|
+
@sample_address_params,
|
111
|
+
new_object["id"]
|
112
|
+
)
|
76
113
|
result["name"].must_equal(@sample_job_params[:name])
|
77
114
|
end
|
78
115
|
end
|
@@ -88,7 +125,12 @@ describe Lob::V1::Job do
|
|
88
125
|
setting_id: @test_setting_id
|
89
126
|
}
|
90
127
|
|
91
|
-
result = subject.jobs.create(
|
128
|
+
result = subject.jobs.create(
|
129
|
+
@sample_job_params[:name],
|
130
|
+
new_address["id"],
|
131
|
+
new_address["id"],
|
132
|
+
new_object_params
|
133
|
+
)
|
92
134
|
result["name"].must_equal(@sample_job_params[:name])
|
93
135
|
end
|
94
136
|
end
|
@@ -107,7 +149,12 @@ describe Lob::V1::Job do
|
|
107
149
|
@test_setting_id
|
108
150
|
)
|
109
151
|
|
110
|
-
new_job = subject.jobs.create(
|
152
|
+
new_job = subject.jobs.create(
|
153
|
+
@sample_job_params[:name],
|
154
|
+
new_address["id"],
|
155
|
+
new_address["id"],
|
156
|
+
new_object["id"]
|
157
|
+
)
|
111
158
|
|
112
159
|
result = subject.jobs.find(new_job["id"])
|
113
160
|
result["name"].must_equal(@sample_job_params[:name])
|
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: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akash Manohar J
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -95,6 +95,9 @@ files:
|
|
95
95
|
- lib/lob.rb
|
96
96
|
- lib/lob/lob_error.rb
|
97
97
|
- lib/lob/v1/address.rb
|
98
|
+
- lib/lob/v1/bank_account.rb
|
99
|
+
- lib/lob/v1/check.rb
|
100
|
+
- lib/lob/v1/country.rb
|
98
101
|
- lib/lob/v1/job.rb
|
99
102
|
- lib/lob/v1/object.rb
|
100
103
|
- lib/lob/v1/packaging.rb
|
@@ -102,9 +105,11 @@ files:
|
|
102
105
|
- lib/lob/v1/resource.rb
|
103
106
|
- lib/lob/v1/service.rb
|
104
107
|
- lib/lob/v1/setting.rb
|
105
|
-
- lib/lob/version.rb
|
106
108
|
- lob.gemspec
|
107
109
|
- spec/lob/v1/address_spec.rb
|
110
|
+
- spec/lob/v1/bank_account_spec.rb
|
111
|
+
- spec/lob/v1/check_spec.rb
|
112
|
+
- spec/lob/v1/country_spec.rb
|
108
113
|
- spec/lob/v1/job_spec.rb
|
109
114
|
- spec/lob/v1/object_spec.rb
|
110
115
|
- spec/lob/v1/packaging_spec.rb
|
@@ -140,6 +145,9 @@ specification_version: 4
|
|
140
145
|
summary: Ruby wrapper for Lob.com API with ActiveRecord-style syntax
|
141
146
|
test_files:
|
142
147
|
- spec/lob/v1/address_spec.rb
|
148
|
+
- spec/lob/v1/bank_account_spec.rb
|
149
|
+
- spec/lob/v1/check_spec.rb
|
150
|
+
- spec/lob/v1/country_spec.rb
|
143
151
|
- spec/lob/v1/job_spec.rb
|
144
152
|
- spec/lob/v1/object_spec.rb
|
145
153
|
- spec/lob/v1/packaging_spec.rb
|
data/lib/lob/version.rb
DELETED