apruve 0.9.2 → 0.10.0
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/lib/apruve.rb +1 -1
- data/lib/apruve/resources/subscription_adjustment.rb +15 -5
- data/lib/apruve/version.rb +1 -1
- data/spec/apruve/resources/subscription_adjustment_spec.rb +202 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8266aa74e71fb99da6044ae2881c00e1f2a9734d
|
4
|
+
data.tar.gz: 62850292f7e9f94e50af2a324988db825ea63b73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f5038c42e98e319c337a83e9d3c252ef584654953223afa275780ce28400ae70645fe15ce9bf3ec23d2674f5d34bf003badccc5661c42ad2fd87e26edcfc00
|
7
|
+
data.tar.gz: 188a2304a63a8040846efdd8ceb0bd8a451da4dd6b4a4fe79b192fc6fa8c8265568a0eb2466b278d51d703d70bfb22accb1e9bf318d89d01fea5f00e8fd40c35
|
data/lib/apruve.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
module Apruve
|
2
2
|
class SubscriptionAdjustment < Apruve::ApruveObject
|
3
3
|
attr_accessor :id, :subscription_id, :status, :title, :amount_cents, :price_ea_cents, :quantity, :description,
|
4
|
-
:variant_info, :sku, :vendor, :view_product_url, :api_url
|
4
|
+
:variant_info, :sku, :vendor, :view_product_url, :api_url, :merchant_notes
|
5
5
|
|
6
6
|
def self.find(subscription_id, id)
|
7
7
|
response = Apruve.get("subscriptions/#{subscription_id}/adjustments/#{id}")
|
8
8
|
logger.debug response.body
|
9
|
-
SubscriptionAdjustment.new(response.body)
|
9
|
+
found = SubscriptionAdjustment.new(response.body)
|
10
|
+
found.subscription_id = subscription_id
|
11
|
+
found
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.delete(subscription_id, id)
|
15
|
+
response = Apruve.delete("subscriptions/#{subscription_id}/adjustments/#{id}")
|
16
|
+
logger.debug response.body
|
17
|
+
nil
|
10
18
|
end
|
11
19
|
|
12
20
|
def self.find_all(subscription_id)
|
@@ -25,9 +33,11 @@ module Apruve
|
|
25
33
|
end
|
26
34
|
|
27
35
|
def delete!
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
if self.id == nil
|
37
|
+
raise 'SubscriptionAdjustment has not been saved'
|
38
|
+
else
|
39
|
+
SubscriptionAdjustment.delete self.subscription_id, self.id
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
data/lib/apruve/version.rb
CHANGED
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apruve::SubscriptionAdjustment do
|
4
|
+
before :each do
|
5
|
+
Apruve.configure('e5fbe71d68772d1f562ed6f598b995b3', 'local')
|
6
|
+
end
|
7
|
+
|
8
|
+
let (:id) { '99ea2488fe0a5c7bb38aa7f9b088874a' }
|
9
|
+
let (:subscription_id) { 'e5fbe71d68772d1f562ed6f598b995b3'}
|
10
|
+
let (:title) { 'A test title' }
|
11
|
+
let (:status) { 'approved' }
|
12
|
+
let (:amount_cents) { 123456 }
|
13
|
+
let (:price_ea_cents) { 12345 }
|
14
|
+
let (:quantity) { 100 }
|
15
|
+
let (:description) { 'description from merchant' }
|
16
|
+
let (:variant_info) { 'variant 1000' }
|
17
|
+
let (:sku) { 'PAPER123' }
|
18
|
+
let (:vendor) { 'vendor9000' }
|
19
|
+
let (:view_product_url) { Faker::Internet.url }
|
20
|
+
let (:api_url) { Faker::Internet.url }
|
21
|
+
let (:merchant_notes) { 'merchant notes' }
|
22
|
+
let (:adjustment) do
|
23
|
+
Apruve::SubscriptionAdjustment.new(
|
24
|
+
id: id,
|
25
|
+
subscription_id: subscription_id,
|
26
|
+
title: title,
|
27
|
+
amount_cents: amount_cents,
|
28
|
+
price_ea_cents: price_ea_cents,
|
29
|
+
quantity: quantity,
|
30
|
+
description: description,
|
31
|
+
variant_info: variant_info,
|
32
|
+
sku: sku,
|
33
|
+
vendor: vendor,
|
34
|
+
view_product_url: view_product_url,
|
35
|
+
merchant_notes: merchant_notes
|
36
|
+
)
|
37
|
+
end
|
38
|
+
subject { adjustment }
|
39
|
+
|
40
|
+
# from line_item
|
41
|
+
it { should respond_to(:title) }
|
42
|
+
it { should respond_to(:amount_cents) }
|
43
|
+
it { should respond_to(:quantity) }
|
44
|
+
it { should respond_to(:price_ea_cents) }
|
45
|
+
it { should respond_to(:merchant_notes) }
|
46
|
+
it { should respond_to(:description) }
|
47
|
+
it { should respond_to(:variant_info) }
|
48
|
+
it { should respond_to(:sku) }
|
49
|
+
it { should respond_to(:vendor) }
|
50
|
+
it { should respond_to(:view_product_url) }
|
51
|
+
|
52
|
+
describe '#find' do
|
53
|
+
describe 'success' do
|
54
|
+
let! (:stubs) do
|
55
|
+
faraday_stubs do |stub|
|
56
|
+
stub.get("/api/v3/subscriptions/#{subscription_id}/adjustments/#{id}") { [200, {}, '{}'] }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
it 'should do a get' do
|
60
|
+
Apruve::SubscriptionAdjustment.find(subscription_id, id)
|
61
|
+
stubs.verify_stubbed_calls
|
62
|
+
end
|
63
|
+
end
|
64
|
+
describe 'not found' do
|
65
|
+
let! (:stubs) do
|
66
|
+
faraday_stubs do |stub|
|
67
|
+
stub.get("/api/v3/subscriptions/#{subscription_id}/adjustments/#{id}") { [404, {}, 'Not Found'] }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
it 'should raise' do
|
71
|
+
expect { Apruve::SubscriptionAdjustment.find(subscription_id, id) }.to raise_error(Apruve::NotFound)
|
72
|
+
stubs.verify_stubbed_calls
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#delete' do
|
78
|
+
describe 'success' do
|
79
|
+
let! (:stubs) do
|
80
|
+
faraday_stubs do |stub|
|
81
|
+
stub.delete("/api/v3/subscriptions/#{subscription_id}/adjustments/#{id}") { [200, {}, '{}'] }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
it 'should do a delete' do
|
85
|
+
Apruve::SubscriptionAdjustment.delete(subscription_id, id)
|
86
|
+
stubs.verify_stubbed_calls
|
87
|
+
end
|
88
|
+
end
|
89
|
+
describe 'not found' do
|
90
|
+
let! (:stubs) do
|
91
|
+
faraday_stubs do |stub|
|
92
|
+
stub.delete("/api/v3/subscriptions/#{subscription_id}/adjustments/#{id}") { [404, {}, 'Not Found'] }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
it 'should raise' do
|
96
|
+
expect { Apruve::SubscriptionAdjustment.delete(subscription_id, id) }.to raise_error(Apruve::NotFound)
|
97
|
+
stubs.verify_stubbed_calls
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#delete!' do
|
103
|
+
describe 'success' do
|
104
|
+
let! (:stubs) do
|
105
|
+
faraday_stubs do |stub|
|
106
|
+
stub.delete("/api/v3/subscriptions/#{adjustment.subscription_id}/adjustments/#{adjustment.id}") { [200, {}, '{}'] }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
it 'should do a delete' do
|
110
|
+
adjustment.delete!
|
111
|
+
stubs.verify_stubbed_calls
|
112
|
+
end
|
113
|
+
end
|
114
|
+
describe 'not found' do
|
115
|
+
let! (:stubs) do
|
116
|
+
faraday_stubs do |stub|
|
117
|
+
stub.delete("/api/v3/subscriptions/#{adjustment.subscription_id}/adjustments/#{adjustment.id}") { [404, {}, 'Not Found'] }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
it 'should raise' do
|
121
|
+
expect {adjustment.delete!}.to raise_error(Apruve::NotFound)
|
122
|
+
stubs.verify_stubbed_calls
|
123
|
+
end
|
124
|
+
end
|
125
|
+
describe 'not saved' do
|
126
|
+
it 'should raise' do
|
127
|
+
adjustment.id = nil
|
128
|
+
expect {adjustment.delete!}.to raise_error('SubscriptionAdjustment has not been saved')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#find_all' do
|
134
|
+
describe 'success' do
|
135
|
+
let! (:stubs) do
|
136
|
+
faraday_stubs do |stub|
|
137
|
+
stub.get("/api/v3/subscriptions/#{subscription_id}/adjustments") { [200, {}, '{}'] }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
it 'should do a get' do
|
141
|
+
Apruve::SubscriptionAdjustment.find_all(subscription_id)
|
142
|
+
stubs.verify_stubbed_calls
|
143
|
+
end
|
144
|
+
end
|
145
|
+
describe 'not found' do
|
146
|
+
let! (:stubs) do
|
147
|
+
faraday_stubs do |stub|
|
148
|
+
stub.get("/api/v3/subscriptions/#{subscription_id}/adjustments") { [404, {}, 'Not Found'] }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
it 'should raise' do
|
152
|
+
expect { Apruve::SubscriptionAdjustment.find_all(subscription_id) }.to raise_error(Apruve::NotFound)
|
153
|
+
stubs.verify_stubbed_calls
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#save!' do
|
159
|
+
let (:response) do
|
160
|
+
{
|
161
|
+
subscription_id: subscription_id,
|
162
|
+
title: title,
|
163
|
+
amount_cents: amount_cents,
|
164
|
+
price_ea_cents: price_ea_cents,
|
165
|
+
quantity: quantity,
|
166
|
+
description: description,
|
167
|
+
variant_info: variant_info,
|
168
|
+
sku: sku,
|
169
|
+
vendor: vendor,
|
170
|
+
view_product_url: view_product_url,
|
171
|
+
merchant_notes: merchant_notes
|
172
|
+
}
|
173
|
+
end
|
174
|
+
describe 'success' do
|
175
|
+
let! (:stubs) do
|
176
|
+
faraday_stubs do |stub|
|
177
|
+
stub.post(
|
178
|
+
"/api/v3/subscriptions/#{subscription_id}/adjustments", adjustment.to_json) { [200, {}, response.to_json] }
|
179
|
+
end
|
180
|
+
end
|
181
|
+
it 'should do a post' do
|
182
|
+
adjustment.save!
|
183
|
+
stubs.verify_stubbed_calls
|
184
|
+
end
|
185
|
+
end
|
186
|
+
describe 'payment request not found' do
|
187
|
+
let! (:stubs) do
|
188
|
+
faraday_stubs do |stub|
|
189
|
+
stub.post(
|
190
|
+
"/api/v3/subscriptions/#{subscription_id}/adjustments", adjustment.to_json) { [404, {}, 'Not Found'] }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
it 'should raise' do
|
194
|
+
expect { adjustment.save! }.to raise_error(Apruve::NotFound)
|
195
|
+
stubs.verify_stubbed_calls
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
|
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: 0.
|
4
|
+
version: 0.10.0
|
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: 2014-
|
12
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- spec/apruve/resources/payment_item_spec.rb
|
128
128
|
- spec/apruve/resources/payment_request_spec.rb
|
129
129
|
- spec/apruve/resources/payment_spec.rb
|
130
|
+
- spec/apruve/resources/subscription_adjustment_spec.rb
|
130
131
|
- spec/apruve/resources/subscription_spec.rb
|
131
132
|
- spec/apruve/response/apruve_exception_middleware_spec.rb
|
132
133
|
- spec/spec_helper.rb
|
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: '0'
|
151
152
|
requirements: []
|
152
153
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.2.
|
154
|
+
rubygems_version: 2.2.1
|
154
155
|
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: Helper library for integrating Apruve into a ruby app.
|
@@ -162,7 +163,7 @@ test_files:
|
|
162
163
|
- spec/apruve/resources/payment_item_spec.rb
|
163
164
|
- spec/apruve/resources/payment_request_spec.rb
|
164
165
|
- spec/apruve/resources/payment_spec.rb
|
166
|
+
- spec/apruve/resources/subscription_adjustment_spec.rb
|
165
167
|
- spec/apruve/resources/subscription_spec.rb
|
166
168
|
- spec/apruve/response/apruve_exception_middleware_spec.rb
|
167
169
|
- spec/spec_helper.rb
|
168
|
-
has_rdoc:
|