apruve 1.1.2 → 1.1.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: 47f7ecc818ee0cf07f527efb91970dcecad9ec29
4
- data.tar.gz: 4fce1f67255250ffb15f04f6b2b1fbdd2e811e48
3
+ metadata.gz: 1f77ae16802dececd30e06bdbbd304c22bc9ff54
4
+ data.tar.gz: d85fef623412045ca74e915fea7ed579976e9f01
5
5
  SHA512:
6
- metadata.gz: 618a2b76d3fe548200eb0c5f041fc340f294bd914a270f25df04c2d0c95b4b1f3c119d85ee7c91a9b4eaf2e42de57a1998c2d4ebf4d50d69f18b0a9df936d526
7
- data.tar.gz: 3a29ee9936e59f006df4a007a524fbc7ea1354f9e3f82cc66a2e42171d2b05db74841f736812f915e9fb604db47e94251047354ae9a81a0121a4dc591cebe304
6
+ metadata.gz: 678517ef6ac88dc6c7baab6a2d1db526bac09f0a2b8e57179b17230bee7f99684bf56bd4f9b99523ec8c735cb4d8f6e52996d717b2f900cbb16ac2f962436885
7
+ data.tar.gz: 220c84012bb49de0d07853d3a4ba704530a61421da39e79d8806d7a10c74ad6dfe0ebf550b231c999507a09de0032f8bf130237bdbde65cf7741233a280d904a
@@ -47,22 +47,32 @@ module Apruve
47
47
 
48
48
  def get(*args, &block)
49
49
  self.client.get *args
50
+ rescue URI::InvalidURIError
51
+ handle_invalid_url(args[0])
50
52
  end
51
53
 
52
54
  def post(*args, &block)
53
55
  self.client.post *args
56
+ rescue URI::InvalidURIError
57
+ handle_invalid_url(args[0])
54
58
  end
55
59
 
56
60
  def put(*args, &block)
57
61
  self.client.put *args
62
+ rescue URI::InvalidURIError
63
+ handle_invalid_url(args[0])
58
64
  end
59
65
 
60
66
  def patch(*args, &block)
61
67
  self.client.patch *args
68
+ rescue URI::InvalidURIError
69
+ handle_invalid_url(args[0])
62
70
  end
63
71
 
64
72
  def unstore(*args, &block)
65
73
  self.client.delete *args
74
+ rescue URI::InvalidURIError
75
+ handle_invalid_url(args[0])
66
76
  end
67
77
 
68
78
  alias_method :delete, :unstore
@@ -72,6 +82,11 @@ module Apruve
72
82
 
73
83
  private
74
84
 
85
+ def handle_invalid_url(url)
86
+ client.config[:logger].warn 'Invalid URL'
87
+ raise Apruve::NotFound.new(body: {}, status: 404, headers: {}, url: url)
88
+ end
89
+
75
90
  def configure_environment(env)
76
91
  if env == PROD
77
92
  @config[:scheme] = 'https'
@@ -7,6 +7,7 @@ require_relative 'resources/order_item'
7
7
  require_relative 'resources/invoice'
8
8
  require_relative 'resources/invoice_item'
9
9
  require_relative 'resources/shipment'
10
+ require_relative 'resources/shipment_item'
10
11
  require_relative 'resources/merchant'
11
12
  require_relative 'resources/subscription'
12
13
  require_relative 'resources/subscription_adjustment'
@@ -1,7 +1,7 @@
1
1
  module Apruve
2
2
  class Shipment < Apruve::ApruveObject
3
3
  attr_accessor :id, :invoice_id, :amount_cents, :currency, :shipper, :shipped_at,
4
- :tracking_number, :delivered_at, :merchant_notes, :invoice_items,
4
+ :tracking_number, :delivered_at, :merchant_notes, :shipment_items,
5
5
  :tax_cents, :shipping_cents, :status, :merchant_shipment_id
6
6
 
7
7
  def self.find(invoice_id, id)
@@ -12,14 +12,14 @@ module Apruve
12
12
  def initialize(params)
13
13
  super
14
14
  # hydrate payment items if appropriate
15
- if @invoice_items.nil?
16
- @invoice_items = []
17
- elsif @invoice_items.is_a?(Array) && @invoice_items.first.is_a?(Hash)
15
+ if @shipment_items.nil?
16
+ @shipment_items = []
17
+ elsif @shipment_items.is_a?(Array) && @shipment_items.first.is_a?(Hash)
18
18
  hydrated_items = []
19
- @invoice_items.each do |item|
20
- hydrated_items << Apruve::OrderItem.new(item)
19
+ @shipment_items.each do |item|
20
+ hydrated_items << Apruve::ShipmentItem.new(item)
21
21
  end
22
- @invoice_items = hydrated_items
22
+ @shipment_items = hydrated_items
23
23
  end
24
24
  @currency = Apruve.default_currency if currency.nil?
25
25
  end
@@ -0,0 +1,22 @@
1
+ module Apruve
2
+ class ShipmentItem < Apruve::ApruveObject
3
+ attr_accessor :title,
4
+ :amount_cents,
5
+ :price_ea_cents,
6
+ :price_total_cents,
7
+ :shipping_cents,
8
+ :tax_cents,
9
+ :quantity,
10
+ :description,
11
+ :variant_info,
12
+ :sku,
13
+ :vendor,
14
+ :currency,
15
+ :view_product_url,
16
+ :price_ea_cents,
17
+ :taxable,
18
+ :shipment_id,
19
+ :uuid
20
+
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Apruve
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
@@ -61,7 +61,7 @@ describe 'Apruve' do
61
61
  end
62
62
  end
63
63
 
64
- describe '#get' do
64
+ describe 'URL actions' do
65
65
  let (:api_key) { 'an-api-key' }
66
66
  let (:url) { 'example.com' }
67
67
  before :each do
@@ -71,7 +71,46 @@ describe 'Apruve' do
71
71
  it 'should raise' do
72
72
  expect { Apruve.get('gibberish') }.to raise_error(Apruve::ServiceUnreachable)
73
73
  end
74
+ end
75
+
76
+ describe '#get' do
77
+ describe 'invalid URL' do
78
+ it 'should raise a Faraday error' do
79
+ expect { Apruve.get('#asldkjfsldfj#Asdlofjasod##') }.to raise_error(Apruve::NotFound)
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#post' do
85
+ describe 'invalid URL' do
86
+ it 'should raise a Faraday error' do
87
+ expect { Apruve.get('#asldkjfsldfj#Asdlofjasod##') }.to raise_error(Apruve::NotFound)
88
+ end
89
+ end
90
+ end
74
91
 
92
+ describe '#patch' do
93
+ describe 'invalid URL' do
94
+ it 'should raise a Faraday error' do
95
+ expect { Apruve.get('#asldkjfsldfj#Asdlofjasod##') }.to raise_error(Apruve::NotFound)
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '#unstore' do
101
+ describe 'invalid URL' do
102
+ it 'should raise a Faraday error' do
103
+ expect { Apruve.get('#asldkjfsldfj#Asdlofjasod##') }.to raise_error(Apruve::NotFound)
104
+ end
105
+ end
106
+ end
107
+
108
+ describe '#put' do
109
+ describe 'invalid URL' do
110
+ it 'should raise a Faraday error' do
111
+ expect { Apruve.get('#asldkjfsldfj#Asdlofjasod##') }.to raise_error(Apruve::NotFound)
112
+ end
113
+ end
75
114
  end
76
115
  end
77
116
 
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Apruve::ShipmentItem do
4
+ let (:shipment_item) {Apruve::ShipmentItem.new}
5
+ subject { shipment_item }
6
+
7
+ it { should respond_to(:title) }
8
+ it { should respond_to(:price_ea_cents) }
9
+ it { should respond_to(:price_total_cents) }
10
+ it { should respond_to(:shipping_cents) }
11
+ it { should respond_to(:tax_cents) }
12
+ it { should respond_to(:quantity) }
13
+ it { should respond_to(:description) }
14
+ it { should respond_to(:variant_info) }
15
+ it { should respond_to(:sku) }
16
+ it { should respond_to(:vendor) }
17
+ it { should respond_to(:currency) }
18
+ it { should respond_to(:view_product_url) }
19
+ it { should respond_to(:price_ea_cents) }
20
+ it { should respond_to(:taxable) }
21
+ it { should respond_to(:shipment_id) }
22
+ it { should respond_to(:uuid) }
23
+
24
+ end
@@ -46,7 +46,7 @@ describe Apruve::Shipment do
46
46
  it { should respond_to(:shipped_at) }
47
47
  it { should respond_to(:delivered_at) }
48
48
  it { should respond_to(:merchant_notes) }
49
- it { should respond_to(:invoice_items) }
49
+ it { should respond_to(:shipment_items) }
50
50
  it { should respond_to(:tax_cents) }
51
51
  it { should respond_to(:shipping_cents) }
52
52
  it { should respond_to(:status) }
@@ -54,7 +54,7 @@ describe Apruve::Shipment do
54
54
 
55
55
  describe '#to_json' do
56
56
  let(:expected) do
57
- '{"amount_cents":1234578,"merchant_notes":"foo","id":"91ac96c0ffc9577ecb634ad726b1874e","invoice_id":"2d1bd4f93a1b9ed034e36783adb29bed","shipper":"shipper name","shipped_at":"2016-11-11T00:00:00-06:00","delivered_at":"2016-11-11T00:00:00-06:00","tracking_number":"1234abcd","currency":"USD","tax_cents":1234,"shipping_cents":12345,"status":"fulfilled","merchant_shipment_id":"ZZ1234567","invoice_items":[]}'
57
+ '{"amount_cents":1234578,"merchant_notes":"foo","id":"91ac96c0ffc9577ecb634ad726b1874e","invoice_id":"2d1bd4f93a1b9ed034e36783adb29bed","shipper":"shipper name","shipped_at":"2016-11-11T00:00:00-06:00","delivered_at":"2016-11-11T00:00:00-06:00","tracking_number":"1234abcd","currency":"USD","tax_cents":1234,"shipping_cents":12345,"status":"fulfilled","merchant_shipment_id":"ZZ1234567","shipment_items":[]}'
58
58
  end
59
59
  its(:to_json) { should eq expected }
60
60
  end
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.2
4
+ version: 1.1.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: 2016-12-30 00:00:00.000000000 Z
12
+ date: 2017-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -115,6 +115,7 @@ files:
115
115
  - lib/apruve/resources/order.rb
116
116
  - lib/apruve/resources/order_item.rb
117
117
  - lib/apruve/resources/shipment.rb
118
+ - lib/apruve/resources/shipment_item.rb
118
119
  - lib/apruve/resources/subscription.rb
119
120
  - lib/apruve/resources/subscription_adjustment.rb
120
121
  - lib/apruve/resources/validation_error.rb
@@ -131,6 +132,7 @@ files:
131
132
  - spec/apruve/resources/merchant_spec.rb
132
133
  - spec/apruve/resources/order_item_spec.rb
133
134
  - spec/apruve/resources/order_spec.rb
135
+ - spec/apruve/resources/shipment_item_spec.rb
134
136
  - spec/apruve/resources/shipment_spec.rb
135
137
  - spec/apruve/resources/subscription_adjustment_spec.rb
136
138
  - spec/apruve/resources/subscription_spec.rb
@@ -170,9 +172,11 @@ test_files:
170
172
  - spec/apruve/resources/merchant_spec.rb
171
173
  - spec/apruve/resources/order_item_spec.rb
172
174
  - spec/apruve/resources/order_spec.rb
175
+ - spec/apruve/resources/shipment_item_spec.rb
173
176
  - spec/apruve/resources/shipment_spec.rb
174
177
  - spec/apruve/resources/subscription_adjustment_spec.rb
175
178
  - spec/apruve/resources/subscription_spec.rb
176
179
  - spec/apruve/resources/webhook_endpoint_spec.rb
177
180
  - spec/apruve/response/apruve_exception_middleware_spec.rb
178
181
  - spec/spec_helper.rb
182
+ has_rdoc: