apruve 1.1.6 → 1.1.7

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
  SHA1:
3
- metadata.gz: 3449dd7a3bad2866ae16341961c0828db953c1da
4
- data.tar.gz: 6c96fbc69b72f0813cedc07185ffbe15b4a1d4bc
3
+ metadata.gz: c4906c25ab5dd9bc57bd845ebf10600e090d3d1d
4
+ data.tar.gz: 317335e6592dca30ad63ef08792a29b5a155bfee
5
5
  SHA512:
6
- metadata.gz: d31d3a8253728eb9291b9332e1473b888f320ed8cb6f81957eabb5265dc1b2c08536617e70ed8d804183b623f97363199cd89022b3c41dc6de49946d0fdb2b3f
7
- data.tar.gz: 5bca60005975499e441dfe79483eab5c2f3deba2a9be833d26b112cc7f0befc98ca6f15f7ec1222ca9a0b42c83bdc03c5adc53bbbd0575ebb10ed6c54726976e
6
+ metadata.gz: 429f35de4d1c7ec5a0b9e3981fa92037f2ebf37e5d0fbe8b2eb7f89941a8cf5077ab5af1a00a375ced3f090eb0d2eea2dec8b5dfb6607f61beebd6d4fe6b075e
7
+ data.tar.gz: 7470ba178ce9f27264125f51e36a1299cf3845cae3cc104212ed7cfb44b8ea2995289f20eb0089a7997fd8656f26be37642f3f1f886158550efd31abea95915c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apruve (1.1.6)
4
+ apruve (1.1.7)
5
5
  addressable (~> 2.3)
6
6
  faraday (>= 0.8.6, <= 0.9.0)
7
7
  faraday_middleware (~> 0.9)
@@ -1,7 +1,8 @@
1
1
  module Apruve
2
2
  class Invoice < Apruve::ApruveObject
3
- attr_accessor :id, :order_id, :status, :amount_cents, :currency, :merchant_notes, :merchant_invoice_id, :shipping_cents,
4
- :tax_cents, :invoice_items, :payments, :created_at, :opened_at, :due_at, :final_state_at, :issue_on_create, :links
3
+ attr_accessor :id, :order_id, :status, :amount_cents, :currency, :merchant_notes, :merchant_invoice_id,
4
+ :shipping_cents, :tax_cents, :invoice_items, :payments, :created_at, :opened_at, :due_at,
5
+ :final_state_at, :issue_on_create, :links, :issued_at, :amount_due
5
6
 
6
7
  def self.find(id)
7
8
  response = Apruve.get("invoices/#{id}")
@@ -66,4 +67,4 @@ module Apruve
66
67
  self.status
67
68
  end
68
69
  end
69
- end
70
+ end
@@ -9,6 +9,12 @@ module Apruve
9
9
  Shipment.new(response.body)
10
10
  end
11
11
 
12
+ def self.find_all(invoice_id)
13
+ response = Apruve.get("invoices/#{invoice_id}/shipments")
14
+ logger.debug response.body
15
+ response.body.map { |shipment| Shipment.new(shipment) }
16
+ end
17
+
12
18
  def initialize(params)
13
19
  super
14
20
  # hydrate payment items if appropriate
@@ -1,3 +1,3 @@
1
1
  module Apruve
2
- VERSION = '1.1.6'
2
+ VERSION = '1.1.7'
3
3
  end
@@ -31,6 +31,8 @@ describe Apruve::Invoice do
31
31
  it { should respond_to(:due_at) }
32
32
  it { should respond_to(:final_state_at) }
33
33
  it { should respond_to(:links) }
34
+ it { should respond_to(:issued_at) }
35
+ it { should respond_to(:amount_due) }
34
36
 
35
37
  describe '#to_json' do
36
38
  let(:expected) do
@@ -103,6 +103,35 @@ describe Apruve::Shipment do
103
103
  end
104
104
  end
105
105
 
106
+ describe '#find_all' do
107
+ context 'successful response' do
108
+ let (:invoice_id) { '91ac96c0ffc9577ecb634ad726b1874e' }
109
+ let! (:stubs) do
110
+ faraday_stubs do |stub|
111
+ stub.get("/api/v4/invoices/#{invoice_id}/shipments") { [200, {}, '[]'] }
112
+ end
113
+ end
114
+ it 'should get all shipments associated with an invoice' do
115
+ Apruve::Shipment.find_all(invoice_id)
116
+ stubs.verify_stubbed_calls
117
+ end
118
+ end
119
+
120
+ context 'with invalid invoice id' do
121
+ let (:invoice_id) { 'not-a-valid-apruve-invoice-id' }
122
+
123
+ let! (:stubs) do
124
+ faraday_stubs do |stub|
125
+ stub.get("/api/v4/invoices/#{invoice_id}/shipments") { [404, {}, 'Not Found'] }
126
+ end
127
+ end
128
+ it 'should return a not found response' do
129
+ expect { Apruve::Shipment.find_all(invoice_id) }.to raise_error(Apruve::NotFound)
130
+ stubs.verify_stubbed_calls
131
+ end
132
+ end
133
+ end
134
+
106
135
  describe '#save' do
107
136
  let (:id) { '89ea2488fe0a5c7bb38aa7f9b088874a' }
108
137
  let (:invoice_id) { '91ac96c0ffc9577ecb634ad726b1874e' }
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: 1.1.6
4
+ version: 1.1.7
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-07-24 00:00:00.000000000 Z
12
+ date: 2017-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler