apruve 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8627da221432f47423e865161c9b050322b001b9
4
- data.tar.gz: 7d543ca989f8ffc2830efe38c114c464982fb2e5
3
+ metadata.gz: b6cdf4762a15960790e781185e8ea4e32e729036
4
+ data.tar.gz: 7f9bbadd71012d3b42022bcfc8f0f1ec6070fc3e
5
5
  SHA512:
6
- metadata.gz: 0377537b00e7b2d2a1379d5d8078a568df6e676ca7b65f2615d64f230779e0a7f85ea835370fb91748f7745593a03e230f1f6eb64c102c854a4c90aff8f1b8e8
7
- data.tar.gz: a10c9c3120f2e3382ecb0e312c7a89249789c82cd148c8edef64b97a553ddee7a5fb836a1215695423c3348ac4c5124ef927b394dd337f1d62fdacbc969cbfc4
6
+ metadata.gz: 82937e89725c75a11670c6abb74812ccb8265628f7f01d45c8280caedb6d0b2a3607d0d538e24dd08c730a69fdf9ad38ce442bea9e2118434c359fe0551b6277
7
+ data.tar.gz: b4fe0faf6f505ea3e6418e27fb56491e40ec9b199bab2494cfa6f5551ed2f761980c08384f88d1270321216a9387c2e6910b136f4b64068402d934d41217d5ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apruve (2.0.2)
4
+ apruve (2.0.3)
5
5
  addressable (~> 2.3)
6
6
  faraday (>= 0.8.6, <= 0.9.0)
7
7
  faraday_middleware (~> 0.9)
@@ -43,8 +43,9 @@ GEM
43
43
  method_source (0.8.2)
44
44
  multipart-post (2.0.0)
45
45
  net-http-persistent (2.9.4)
46
- parser (2.3.1.2)
47
- ast (~> 2.2)
46
+ parallel (1.12.0)
47
+ parser (2.4.0.2)
48
+ ast (~> 2.3)
48
49
  powerpack (0.1.1)
49
50
  pry (0.10.0)
50
51
  coderay (~> 1.1.0)
@@ -55,7 +56,7 @@ GEM
55
56
  method_source (~> 0.8.1)
56
57
  slop (~> 3.4)
57
58
  win32console (~> 1.3)
58
- rainbow (2.1.0)
59
+ rainbow (3.0.0)
59
60
  rake (10.3.2)
60
61
  rb-fsevent (0.9.4)
61
62
  rb-inotify (0.9.5)
@@ -73,13 +74,14 @@ GEM
73
74
  rspec-core (>= 2.99.0.beta1)
74
75
  rspec-expectations (>= 2.99.0.beta1)
75
76
  rspec-mocks (2.99.1)
76
- rubocop (0.40.0)
77
- parser (>= 2.3.1.0, < 3.0)
77
+ rubocop (0.52.0)
78
+ parallel (~> 1.10)
79
+ parser (>= 2.4.0.2, < 3.0)
78
80
  powerpack (~> 0.1)
79
- rainbow (>= 1.99.1, < 3.0)
81
+ rainbow (>= 2.2.2, < 4.0)
80
82
  ruby-progressbar (~> 1.7)
81
83
  unicode-display_width (~> 1.0, >= 1.0.1)
82
- ruby-progressbar (1.8.1)
84
+ ruby-progressbar (1.9.0)
83
85
  safe_yaml (1.0.3)
84
86
  simplecov (0.11.2)
85
87
  docile (~> 1.1.0)
@@ -89,7 +91,7 @@ GEM
89
91
  slop (3.5.0)
90
92
  terminal-table (1.4.5)
91
93
  thor (0.19.1)
92
- unicode-display_width (1.0.5)
94
+ unicode-display_width (1.3.0)
93
95
  vcr (2.9.2)
94
96
  webmock (1.18.0)
95
97
  addressable (>= 2.3.6)
data/README.md CHANGED
@@ -26,7 +26,7 @@ integrate Apruve.
26
26
 
27
27
  ### Create an account on Apruve.
28
28
 
29
- Have a look though our [Getting Started documentation](https://docs.apruve.com/guides/getting-started-f09a17ef-053e-4eba-9141-6fe8ce3b774d) and be sure to use
29
+ Have a look though our [Getting Started documentation](https://docs.apruve.com/docs/getting-started) and be sure to use
30
30
  test.apruve.com for test accounts.
31
31
 
32
32
  ### Initialize the library
@@ -2,7 +2,8 @@ module Apruve
2
2
  class Order < Apruve::ApruveObject
3
3
  attr_accessor :id, :merchant_id, :shopper_id, :merchant_order_id, :status, :amount_cents, :currency, :tax_cents,
4
4
  :shipping_cents, :expire_at, :order_items, :accepts_payments_via, :accepts_payment_terms, :payment_term,
5
- :created_at, :updated_at, :final_state_at, :default_payment_method, :links, :finalize_on_create, :invoice_on_create
5
+ :created_at, :updated_at, :final_state_at, :default_payment_method, :links, :finalize_on_create, :invoice_on_create,
6
+ :secure_hash
6
7
 
7
8
  def self.find(id)
8
9
  response = Apruve.get("orders/#{id}")
@@ -20,6 +21,13 @@ module Apruve
20
21
  response.body.map { |order| Order.new(order) }
21
22
  end
22
23
 
24
+ def self.find_by_hash(hash)
25
+ response = Apruve.get("orders?secure_hash=#{hash}")
26
+ logger.debug response.body
27
+ orders = response.body.map { |order| Order.new(order) }
28
+ orders.max_by { |order| order[:created_at] }
29
+ end
30
+
23
31
  def self.finalize!(id)
24
32
  response = Apruve.post("orders/#{id}/finalize")
25
33
  logger.debug response.body
@@ -1,3 +1,3 @@
1
1
  module Apruve
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
@@ -41,7 +41,8 @@ describe Apruve::Order do
41
41
  order_items: order_items,
42
42
  finalize_on_create: false,
43
43
  invoice_on_create: false,
44
- payment_term: payment_term
44
+ payment_term: payment_term,
45
+ secure_hash: 'fffd123'
45
46
  )
46
47
  end
47
48
  subject { payment_request }
@@ -58,13 +59,14 @@ describe Apruve::Order do
58
59
  it { should respond_to(:accepts_payment_terms) }
59
60
  it { should respond_to(:finalize_on_create) }
60
61
  it { should respond_to(:invoice_on_create) }
62
+ it { should respond_to(:secure_hash) }
61
63
 
62
64
  describe '#to_json' do
63
65
  let(:expected) do
64
66
  "{\"merchant_id\":\"9a9c3389fdc281b5c6c8d542a7e91ff6\",\"shopper_id\":\"9bc388fd08ce2835cfeb2e630316f7f1\",\"merchant_order_id\":\"ABC\","\
65
67
  "\"amount_cents\":12340,\"tax_cents\":0,\"shipping_cents\":0,\"order_items\":[{\"title\":\"line 1\",\"price_ea_cents\":\"123\",\"quantity\":10,"\
66
68
  "\"description\":\"A line item\",\"variant_info\":\"small\",\"sku\":\"LINE1SKU\",\"vendor\":\"acme, inc.\",\"view_product_url\":\"http://www.apruve.com/doc\""\
67
- "},{\"title\":\"line 2\",\"price_ea_cents\":\"40\"}],\"finalize_on_create\":false,\"invoice_on_create\":false,\"payment_term\":{\"corporate_account_id\":\"612e5383e4acc6c2213f3cae6208e868\"}}"
69
+ "},{\"title\":\"line 2\",\"price_ea_cents\":\"40\"}],\"finalize_on_create\":false,\"invoice_on_create\":false,\"payment_term\":{\"corporate_account_id\":\"612e5383e4acc6c2213f3cae6208e868\"},\"secure_hash\":\"fffd123\"}"
68
70
  end
69
71
  its(:to_json) { should eq expected }
70
72
  end
@@ -168,6 +170,21 @@ describe Apruve::Order do
168
170
  end
169
171
  end
170
172
 
173
+ describe '#find_by_hash' do
174
+ context 'with invalid hash query param' do
175
+ let(:invalid_hash) { 'fffd123' }
176
+ let!(:stubs) do
177
+ faraday_stubs do |stub|
178
+ stub.get("api/v4/orders?secure_hash=#{invalid_hash}") { [200, {}, '[]']}
179
+ end
180
+ end
181
+ it 'should return an empty array' do
182
+ Apruve::Order.find_by_hash(invalid_hash)
183
+ stubs.verify_stubbed_calls
184
+ end
185
+ end
186
+ end
187
+
171
188
  describe '#save' do
172
189
  let (:id) { '89ea2488fe0a5c7bb38aa7f9b088874a' }
173
190
  let (:status) { 'pending' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apruve
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apruve, Inc.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-04 00:00:00.000000000 Z
12
+ date: 2017-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler