lob 5.4.2 → 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.
- checksums.yaml +4 -4
- data/.github/workflows/forked_tests_job.yml +36 -0
- data/.github/workflows/run_tests_job.yml +2 -6
- data/.github/workflows/update_gem.yml +1 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +11 -0
- data/README.md +3 -0
- data/examples/README.md +8 -0
- data/examples/cards.rb +51 -0
- data/lib/lob/client.rb +5 -0
- data/lib/lob/resources/bulk_intl_verifications.rb +1 -0
- data/lib/lob/resources/bulk_us_verifications.rb +1 -0
- data/lib/lob/resources/card.rb +46 -0
- data/lib/lob/resources/resource_base.rb +17 -9
- data/lib/lob/version.rb +1 -1
- data/lob.gemspec +1 -0
- data/spec/lob/resources/bulk_intl_verifications_spec.rb +9 -0
- data/spec/lob/resources/bulk_us_verifications_spec.rb +14 -0
- data/spec/lob/resources/card_spec.rb +145 -0
- data/spec/samples/card.pdf +744 -0
- data/spec/spec_helper.rb +6 -4
- metadata +23 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba5df9cb717ab1c37b9ee4741304e8d5afa77d2e78c323d25f6d81e541f463ae
|
|
4
|
+
data.tar.gz: f0b0e80db2cfafa53427676ff2ff66edf02f85f1e7b1c98acaeb7f5e5426de84
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
+
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
name: Run tests
|
|
2
2
|
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [ created, reopened ]
|
|
6
|
-
branches:
|
|
7
|
-
- master
|
|
3
|
+
on: [pull_request]
|
|
8
4
|
jobs:
|
|
9
5
|
ruby_tests:
|
|
10
6
|
runs-on: ubuntu-latest
|
|
@@ -28,7 +24,7 @@ jobs:
|
|
|
28
24
|
uses: coverallsapp/github-action@master
|
|
29
25
|
with:
|
|
30
26
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
-
|
|
27
|
+
path-to-lcov: ./coverage/lcov/lcov.info
|
|
32
28
|
|
|
33
29
|
|
|
34
30
|
|
|
@@ -7,15 +7,12 @@ on:
|
|
|
7
7
|
jobs:
|
|
8
8
|
publish_gem:
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
|
-
strategy:
|
|
11
|
-
matrix:
|
|
12
|
-
ruby-version: ['jruby-9.2.9.0', '2.6', '2.7', '3.0']
|
|
13
10
|
steps:
|
|
14
11
|
- uses: actions/checkout@v2
|
|
15
12
|
- name: Setup
|
|
16
13
|
uses: ruby/setup-ruby@v1
|
|
17
14
|
with:
|
|
18
|
-
ruby-version:
|
|
15
|
+
ruby-version: 2.7
|
|
19
16
|
- name: Install Dependencies
|
|
20
17
|
run: bundle install
|
|
21
18
|
- name: Publish Gem
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
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
|
|
1
12
|
## [**5.4.1**](https://github.com/lob/lob-ruby/releases/tag/v5.4.1) (2021-09-28)
|
|
2
13
|
- [**193**](https://github.com/lob/lob-ruby/pull/193) Minor patches
|
|
3
14
|
## [**5.4.0**](https://github.com/lob/lob-ruby/releases/tag/v5.4.0) (2021-09-21)
|
data/README.md
CHANGED
|
@@ -69,6 +69,9 @@ lob = Lob::Client.new(api_key: "your-api-key")
|
|
|
69
69
|
|
|
70
70
|
# To initialize a Lob object with an older API version
|
|
71
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)
|
|
72
75
|
```
|
|
73
76
|
|
|
74
77
|
#### Caution: Pass zero-prefixed zip codes as strings
|
data/examples/README.md
CHANGED
|
@@ -38,6 +38,14 @@ Please note that if you are running this with a Test API Key, the verification A
|
|
|
38
38
|
bundle exec ruby examples/csv_verify/verify.rb
|
|
39
39
|
```
|
|
40
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
|
+
```
|
|
48
|
+
|
|
41
49
|
## [/checks.rb](./checks.rb)
|
|
42
50
|
|
|
43
51
|
An example showing how to create a check using Lob's [Checks API](https://lob.com/services/checks).
|
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/lib/lob/client.rb
CHANGED
|
@@ -2,6 +2,7 @@ require "lob/resources/address"
|
|
|
2
2
|
require "lob/resources/bank_account"
|
|
3
3
|
require "lob/resources/bulk_intl_verifications"
|
|
4
4
|
require "lob/resources/bulk_us_verifications"
|
|
5
|
+
require "lob/resources/card"
|
|
5
6
|
require "lob/resources/check"
|
|
6
7
|
require "lob/resources/group"
|
|
7
8
|
require "lob/resources/groups_member"
|
|
@@ -43,6 +44,10 @@ module Lob
|
|
|
43
44
|
Lob::Resources::BulkUSVerifications.new(config)
|
|
44
45
|
end
|
|
45
46
|
|
|
47
|
+
def cards
|
|
48
|
+
Lob::Resources::Card.new(config)
|
|
49
|
+
end
|
|
50
|
+
|
|
46
51
|
def checks
|
|
47
52
|
Lob::Resources::Check.new(config)
|
|
48
53
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "lob/resources/resource_base"
|
|
2
|
+
|
|
3
|
+
module Lob
|
|
4
|
+
module Resources
|
|
5
|
+
class Card < Lob::Resources::ResourceBase
|
|
6
|
+
|
|
7
|
+
def initialize(config)
|
|
8
|
+
super(config)
|
|
9
|
+
@endpoint = "cards"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def update(resource_id, body={}, headers={})
|
|
13
|
+
request = {
|
|
14
|
+
method: :post,
|
|
15
|
+
url: resource_url(resource_id),
|
|
16
|
+
body: body,
|
|
17
|
+
headers: headers
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
submit(request)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_order(resource_id, body={}, headers={})
|
|
24
|
+
request = {
|
|
25
|
+
method: :post,
|
|
26
|
+
url: "#{resource_url(resource_id)}/orders",
|
|
27
|
+
body: body,
|
|
28
|
+
headers: headers
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
submit(request)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def list_orders(resource_id, query={})
|
|
35
|
+
request = {
|
|
36
|
+
method: :get,
|
|
37
|
+
url: "#{resource_url(resource_id)}/orders",
|
|
38
|
+
query: query
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
submit(request)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -71,17 +71,25 @@ module Lob
|
|
|
71
71
|
if query != {}
|
|
72
72
|
url = "#{url}?#{build_nested_query(query)}"
|
|
73
73
|
end
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
|
|
75
|
+
client_params = {
|
|
76
|
+
headers: headers,
|
|
77
|
+
method: method,
|
|
78
|
+
url: url,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
client_params[:proxy] = config[:proxy] if config.key?(:proxy)
|
|
82
|
+
|
|
83
|
+
unless method == :delete || method == :get
|
|
84
|
+
if body and body[:merge_variables] and body[:merge_variables].class == Hash
|
|
85
|
+
body[:merge_variables] = body[:merge_variables].to_json
|
|
83
86
|
end
|
|
84
87
|
|
|
88
|
+
client_params[:payload] = body
|
|
89
|
+
end
|
|
90
|
+
begin
|
|
91
|
+
response = RestClient::Request.execute(client_params)
|
|
92
|
+
|
|
85
93
|
body = JSON.parse(response)
|
|
86
94
|
|
|
87
95
|
body.define_singleton_method(:_response) do
|
data/lib/lob/version.rb
CHANGED
data/lob.gemspec
CHANGED
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.add_development_dependency "rake", "~> 12.3.3"
|
|
24
24
|
spec.add_development_dependency "minitest", "~> 5.6.1"
|
|
25
25
|
spec.add_development_dependency "webmock", "~> 1.2"
|
|
26
|
+
spec.add_development_dependency "simplecov-lcov"
|
|
26
27
|
spec.add_development_dependency "coveralls_reborn", "~> 0.23.1"
|
|
27
28
|
spec.add_development_dependency "simplecov", "~> 0.21.0"
|
|
28
29
|
spec.add_development_dependency "json", "~> 2.3.1"
|
|
@@ -5,6 +5,13 @@ describe Lob::Resources::BulkIntlVerifications do
|
|
|
5
5
|
before :each do
|
|
6
6
|
@sample_params = {
|
|
7
7
|
addresses: [
|
|
8
|
+
{
|
|
9
|
+
primary_line: "123 Test St",
|
|
10
|
+
city: "HEARST",
|
|
11
|
+
state: "ONTARIO",
|
|
12
|
+
postal_code: "P0L1N0",
|
|
13
|
+
country: "CA"
|
|
14
|
+
},
|
|
8
15
|
{
|
|
9
16
|
primary_line: "123 Test St",
|
|
10
17
|
city: "HEARST",
|
|
@@ -24,6 +31,8 @@ describe Lob::Resources::BulkIntlVerifications do
|
|
|
24
31
|
addresses = result["addresses"]
|
|
25
32
|
address = addresses.first
|
|
26
33
|
address["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES")
|
|
34
|
+
address = addresses[1]
|
|
35
|
+
address["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES")
|
|
27
36
|
end
|
|
28
37
|
end
|
|
29
38
|
|
|
@@ -11,6 +11,13 @@ describe Lob::Resources::BulkUSVerifications do
|
|
|
11
11
|
city: "SAN FRANCISCO",
|
|
12
12
|
state: "CA",
|
|
13
13
|
zip_code: "94107"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
recipient: "Harry Zhou",
|
|
17
|
+
primary_line: "325 BERRY ST",
|
|
18
|
+
city: "SAN FRANCISCO",
|
|
19
|
+
state: "CA",
|
|
20
|
+
zip_code: "94107"
|
|
14
21
|
}
|
|
15
22
|
]
|
|
16
23
|
}
|
|
@@ -24,6 +31,10 @@ describe Lob::Resources::BulkUSVerifications do
|
|
|
24
31
|
addresses = result["addresses"]
|
|
25
32
|
address = addresses.first
|
|
26
33
|
address["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES")
|
|
34
|
+
address = addresses[1]
|
|
35
|
+
address["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES")
|
|
36
|
+
|
|
37
|
+
|
|
27
38
|
end
|
|
28
39
|
|
|
29
40
|
it "should allow 'case' in query params" do
|
|
@@ -31,6 +42,9 @@ describe Lob::Resources::BulkUSVerifications do
|
|
|
31
42
|
addresses = result["addresses"]
|
|
32
43
|
address = addresses.first
|
|
33
44
|
address["recipient"].must_equal("Test Keys Do Not Verify Addresses")
|
|
45
|
+
address = addresses[1]
|
|
46
|
+
address["recipient"].must_equal("Test Keys Do Not Verify Addresses")
|
|
47
|
+
|
|
34
48
|
end
|
|
35
49
|
end
|
|
36
50
|
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Lob::Resources::Card do
|
|
4
|
+
|
|
5
|
+
before :each do
|
|
6
|
+
@horizontal_card_url = "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/card_horizontal.pdf"
|
|
7
|
+
@horizontal_card_front = File.new(File.expand_path("../../../samples/card.pdf", __FILE__))
|
|
8
|
+
@horizontal_card_back = File.new(File.expand_path("../../../samples/card.pdf", __FILE__))
|
|
9
|
+
|
|
10
|
+
@sample_card_params = {
|
|
11
|
+
description: "Test Card",
|
|
12
|
+
front: @horizontal_card_url
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
subject { Lob::Client.new(api_key: API_KEY) }
|
|
17
|
+
|
|
18
|
+
describe "list" do
|
|
19
|
+
it "should list cards" do
|
|
20
|
+
assert subject.cards.list({ include: ['total_count'] })["object"] == "list"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "create" do
|
|
25
|
+
it "should create a card with a front url" do
|
|
26
|
+
result = subject.cards.create(@sample_card_params)
|
|
27
|
+
|
|
28
|
+
result["description"].must_equal(@sample_card_params[:description])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should create a card with front and back as urls" do
|
|
32
|
+
result = subject.cards.create(
|
|
33
|
+
@sample_card_params.merge(back: @horizontal_card_url)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
result["description"].must_equal(@sample_card_params[:description])
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should create a card with a front PDF" do
|
|
40
|
+
result = subject.cards.create(
|
|
41
|
+
@sample_card_params.merge(front: @horizontal_card_front)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
result["description"].must_equal(@sample_card_params[:description])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should create a card with front and back as PDFs" do
|
|
48
|
+
result = subject.cards.create(
|
|
49
|
+
@sample_card_params.merge({
|
|
50
|
+
front: @horizontal_card_front,
|
|
51
|
+
back: @horizontal_card_back
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
result["description"].must_equal(@sample_card_params[:description])
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should return an error without a front" do
|
|
59
|
+
assert_raises Lob::InvalidRequestError do
|
|
60
|
+
subject.cards.create(
|
|
61
|
+
@sample_card_params.merge({ front: nil })
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
describe "find" do
|
|
69
|
+
it "should find a card" do
|
|
70
|
+
new_card = subject.cards.create(
|
|
71
|
+
@sample_card_params.merge(front: @horizontal_card_front)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
result = subject.cards.find(new_card["id"])
|
|
75
|
+
result["description"].must_equal(@sample_card_params[:description])
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
describe "update" do
|
|
81
|
+
it "should update a card" do
|
|
82
|
+
new_card = subject.cards.create(
|
|
83
|
+
@sample_card_params.merge(front: @horizontal_card_front)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
result = subject.cards.update(
|
|
87
|
+
new_card["id"],
|
|
88
|
+
{ description: "Updated card description" }
|
|
89
|
+
)
|
|
90
|
+
result["description"].must_equal("Updated card description")
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
describe "destroy" do
|
|
96
|
+
it "should destroy a card" do
|
|
97
|
+
new_card = subject.cards.create(
|
|
98
|
+
@sample_card_params.merge(front: @horizontal_card_front)
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
result = subject.cards.destroy(new_card["id"])
|
|
102
|
+
result["id"].must_equal(new_card["id"])
|
|
103
|
+
result["deleted"].must_equal(true)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
describe "create_order" do
|
|
109
|
+
it "should create an order for a card" do
|
|
110
|
+
new_card = subject.cards.create(
|
|
111
|
+
@sample_card_params.merge(front: @horizontal_card_front)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
card_order_params = {
|
|
115
|
+
quantity: 10001
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
result = subject.cards.create_order(new_card["id"], card_order_params)
|
|
119
|
+
result["card_id"].must_equal(new_card["id"])
|
|
120
|
+
result["quantity_ordered"].must_equal(card_order_params[:quantity])
|
|
121
|
+
result["object"].must_equal("card_order")
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
describe "list_orders" do
|
|
127
|
+
it "should list all orders for a card" do
|
|
128
|
+
new_card = subject.cards.create(
|
|
129
|
+
@sample_card_params.merge(front: @horizontal_card_front)
|
|
130
|
+
)
|
|
131
|
+
card_order_params = {
|
|
132
|
+
quantity: 10001
|
|
133
|
+
}
|
|
134
|
+
new_card_order = subject.cards.create_order(
|
|
135
|
+
new_card["id"],
|
|
136
|
+
card_order_params
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
result = subject.cards.list_orders(new_card["id"])
|
|
140
|
+
result["object"].must_equal("list")
|
|
141
|
+
result["count"].must_equal(1)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
end
|