lob 5.4.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14de59724a258146efda8e6e01416f8c783c5f63e92989dd017ca1ec17c7c43a
4
- data.tar.gz: 49c06775670f7101fec498ea258ad2c415d086ea16c15cee163d34379ebacbae
3
+ metadata.gz: ba5df9cb717ab1c37b9ee4741304e8d5afa77d2e78c323d25f6d81e541f463ae
4
+ data.tar.gz: f0b0e80db2cfafa53427676ff2ff66edf02f85f1e7b1c98acaeb7f5e5426de84
5
5
  SHA512:
6
- metadata.gz: ad126ff6eef5e894245b99842ada43132454074dbad8d43093828f3069b173c1ff97940769cb55febe079d6bb48de8152d42ac28ed904e7f93df011252528084
7
- data.tar.gz: d8f04a69fca64ef67ddfd2ed109f851917ac269f6996ae74009939f8601cd8060eeed56868c40303b9fad56857f5c6df3ff374f19a8a315e6c9ac6bbe39eb60c
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
+
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
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
1
3
  ## [**5.4.5**](https://github.com/lob/lob-ruby/releases/tag/v5.4.5) (2022-01-11)
2
4
  - [**203**](https://github.com/lob/lob-ruby/pull/203) Pass through proxy to rest-client if supplied
3
5
  ## [**5.4.4**](https://github.com/lob/lob-ruby/releases/tag/v5.4.4) (2021-12-16)
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
@@ -12,6 +12,7 @@ module Lob
12
12
  end
13
13
 
14
14
  def verify(body={})
15
+ body[:addresses] = body[:addresses].to_json
15
16
  request = {
16
17
  method: :post,
17
18
  url: endpoint_url,
@@ -12,6 +12,7 @@ module Lob
12
12
  end
13
13
 
14
14
  def verify(body={}, query={})
15
+ body[:addresses] = body[:addresses].to_json
15
16
  request = {
16
17
  method: :post,
17
18
  url: endpoint_url,
@@ -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
data/lib/lob/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lob
2
- VERSION = "5.4.5"
2
+ VERSION = "5.4.6"
3
3
  end
@@ -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