bill_forward 1.2016.117 → 2.2016.209
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/Gemfile +1 -7
- data/README.md +4 -0
- data/bill_forward.gemspec +1 -0
- data/lib/bill_forward/billing_entity.rb +11 -9
- data/lib/bill_forward/version.rb +1 -1
- data/spec/component/subscription_spec.rb +28 -59
- data/spec/functional/bad_citizen/situational/subscription_chargeable_spec.rb +14 -14
- metadata +108 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6bac0a04b2fe610fe54fba1c0775c9616b414c6c
|
4
|
+
data.tar.gz: a9e266b50f608de09cfa3920a51c9c5d4c5e10a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 489036e8af35a96690eeb0482743d171c0efff0d135bdd29c21470f57b74e55aa60f3141a0828200e0daee3c5217a08d3fe40d31a25963e55f52f770ac169f0e
|
7
|
+
data.tar.gz: 230fde068d38e85c86239501eae443d7262132d436487e877b25d9b46e9d1f729833530441480ed916a6391396511cd674d9994ec004b7ffea2f4d3bac0fca63
|
data/Gemfile
CHANGED
@@ -4,10 +4,4 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
gem 'json', '~> 1.8.1'
|
7
|
-
gem 'require_all'
|
8
|
-
|
9
|
-
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.3')
|
10
|
-
gem 'i18n', '< 0.7'
|
11
|
-
gem 'rest-client', '~> 1.6.8'
|
12
|
-
gem 'activesupport', '~> 3.2'
|
13
|
-
end
|
7
|
+
gem 'require_all'
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This client library provides (via Ruby) easy access to the BillForward API.
|
4
4
|
|
5
|
+
## Support
|
6
|
+
|
7
|
+
Until [commit 1ca55](https://github.com/billforward/bf-ruby/tree/1ca55ca8d361130c935df68e3b6496611221938a), [version 1.2016.117](https://rubygems.org/gems/bill_forward/versions/1.2016.117), the SDK targeted Ruby 1.8.7.
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
### From Git
|
7
11
|
|
data/bill_forward.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'rest-client', '~> 1.4'
|
22
22
|
spec.add_dependency 'json', '~> 1.8.1'
|
23
23
|
spec.add_dependency 'require_all'
|
24
|
+
spec.add_dependency 'activesupport'
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
26
27
|
spec.add_development_dependency "rspec"
|
@@ -6,7 +6,7 @@ module BillForward
|
|
6
6
|
|
7
7
|
def initialize(state_params = nil, client = nil)
|
8
8
|
raise AbstractInstantiateError.new('This abstract class cannot be instantiated!') if self.class == MutableEntity
|
9
|
-
|
9
|
+
|
10
10
|
client = self.class.singleton_client if client.nil?
|
11
11
|
state_params = {} if state_params.nil?
|
12
12
|
|
@@ -20,7 +20,7 @@ module BillForward
|
|
20
20
|
# initiate with empty state params
|
21
21
|
# use indifferent hash so 'id' and :id are the same
|
22
22
|
@_state_params = HashWithIndifferentAccess.new
|
23
|
-
# legacy Ruby gives us this 'id' chuff. we kinda need it back.
|
23
|
+
# legacy Ruby gives us this 'id' chuff. we kinda need it back.
|
24
24
|
@_state_params.instance_eval { undef id if defined? id }
|
25
25
|
# populate state params now
|
26
26
|
unserialize_all state_params
|
@@ -143,14 +143,16 @@ module BillForward
|
|
143
143
|
|
144
144
|
def method_missing(method_id, *arguments, &block)
|
145
145
|
def camel_case_lower(operand)
|
146
|
-
operand.split('_')
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
146
|
+
elements = operand.split('_')
|
147
|
+
camel_cased = elements.join('_').camelize(:lower)
|
148
|
+
|
149
|
+
camel_cased.gsub!(/Id/, 'ID') if elements.size > 1 && elements.last =~ /id=?\Z/
|
150
|
+
|
151
|
+
camel_cased
|
151
152
|
end
|
152
153
|
|
153
154
|
qualified = camel_case_lower method_id.to_s
|
155
|
+
|
154
156
|
if qualified != method_id.to_s
|
155
157
|
return self.send(qualified.intern, *arguments)
|
156
158
|
end
|
@@ -196,7 +198,7 @@ module BillForward
|
|
196
198
|
field
|
197
199
|
end
|
198
200
|
end
|
199
|
-
|
201
|
+
|
200
202
|
def to_ordered_hash
|
201
203
|
serialize_field self
|
202
204
|
end
|
@@ -329,4 +331,4 @@ module BillForward
|
|
329
331
|
end
|
330
332
|
end
|
331
333
|
end
|
332
|
-
end
|
334
|
+
end
|
data/lib/bill_forward/version.rb
CHANGED
@@ -9,27 +9,28 @@ describe BillForward::Subscription do
|
|
9
9
|
# skip OAuth request
|
10
10
|
allow_any_instance_of(BillForward::Client).to receive(:get_token).and_return('fake token')
|
11
11
|
end
|
12
|
+
|
12
13
|
describe '::get_by_id' do
|
13
14
|
context 'where subscription exists' do
|
14
15
|
describe 'the unserialized subscription' do
|
16
|
+
let(:response) { double :response }
|
17
|
+
let(:subscription_id) { 'ACD66517-6F32-44CB-AF8C-3097F97E1E67' }
|
18
|
+
let(:subscription) { BillForward::Subscription.get_by_id(subscription_id) }
|
19
|
+
|
20
|
+
before do
|
21
|
+
allow(response).to receive(:to_str).and_return(canned_subscription_get)
|
22
|
+
allow(RestClient::Request).to receive(:execute).and_return(response)
|
23
|
+
# mainly just confirm that unserialization is reasonably healthy.
|
24
|
+
expect(subscription.id).to eq(subscription_id)
|
25
|
+
end
|
26
|
+
|
15
27
|
describe '.to_ordered_hash' do
|
16
28
|
context 'using array access' do
|
17
29
|
it "has @type at top" do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
allow(RestClient::Request).to receive(:execute).and_return(response)
|
23
|
-
|
24
|
-
subscription = BillForward::Subscription.get_by_id subscription_id
|
25
|
-
|
26
|
-
# mainly just confirm that unserialization is reasonably healthy.
|
27
|
-
expect(subscription.id).to eq(subscription_id)
|
28
|
-
|
29
|
-
# check that @type is the first key on subscription (we use ordered hashes)
|
30
|
-
payload = subscription.to_ordered_hash
|
31
|
-
payload_first_kvp = payload.first
|
32
|
-
kvp_key = payload_first_kvp.first
|
30
|
+
# check that @type is the first key on subscription (we use ordered hashes)
|
31
|
+
payload = subscription.to_ordered_hash
|
32
|
+
payload_first_kvp = payload.first
|
33
|
+
kvp_key = payload_first_kvp.first
|
33
34
|
expect(kvp_key).to eq('@type')
|
34
35
|
|
35
36
|
# check that @type is the first key on nested entities (we use ordered hashes)
|
@@ -41,17 +42,6 @@ describe BillForward::Subscription do
|
|
41
42
|
end
|
42
43
|
context 'using dot access' do
|
43
44
|
it "has @type at top" do
|
44
|
-
subscription_id = 'ACD66517-6F32-44CB-AF8C-3097F97E1E67'
|
45
|
-
|
46
|
-
response = double
|
47
|
-
allow(response).to receive(:to_str).and_return(canned_subscription_get)
|
48
|
-
allow(RestClient::Request).to receive(:execute).and_return(response)
|
49
|
-
|
50
|
-
subscription = BillForward::Subscription.get_by_id subscription_id
|
51
|
-
|
52
|
-
# mainly just confirm that unserialization is reasonably healthy.
|
53
|
-
expect(subscription.id).to eq(subscription_id)
|
54
|
-
|
55
45
|
# check that @type is the first key on subscription (we use ordered hashes)
|
56
46
|
payload = subscription.to_ordered_hash
|
57
47
|
payload_first_kvp = payload.first
|
@@ -64,6 +54,17 @@ describe BillForward::Subscription do
|
|
64
54
|
kvp_key = pricing_component_first_kvp.first
|
65
55
|
expect(kvp_key).to eq('@type')
|
66
56
|
end
|
57
|
+
|
58
|
+
it 'has product_id at the top' do
|
59
|
+
expect(subscription.product_id).to eq("0CE0A471-A8B1-4E33-B5F4-115947DE8C55")
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'can set the product_id to something else' do
|
63
|
+
subscription.product_id = 100
|
64
|
+
expect(subscription.product_id).to eq(100)
|
65
|
+
expect(subscription.productID).to eq(100)
|
66
|
+
expect(subscription['productID']).to eq(100)
|
67
|
+
end
|
67
68
|
end
|
68
69
|
end
|
69
70
|
# NOTE: ideally no anonymous entity would exist, because we would register all known nested entities.
|
@@ -74,26 +75,10 @@ describe BillForward::Subscription do
|
|
74
75
|
describe 'nested anonymous entity' do
|
75
76
|
context 'using dot access' do
|
76
77
|
it "can be read" do
|
77
|
-
subscription_id = 'ACD66517-6F32-44CB-AF8C-3097F97E1E67'
|
78
|
-
|
79
|
-
response = double
|
80
|
-
allow(response).to receive(:to_str).and_return(canned_subscription_get)
|
81
|
-
allow(RestClient::Request).to receive(:execute).and_return(response)
|
82
|
-
|
83
|
-
subscription = BillForward::Subscription.get_by_id subscription_id
|
84
|
-
|
85
78
|
a_pricing_component = subscription.productRatePlan.pricingComponents.first
|
86
79
|
expect(a_pricing_component.name).to eq('Devices used, fixed')
|
87
80
|
end
|
88
81
|
it "can be changed" do
|
89
|
-
subscription_id = 'ACD66517-6F32-44CB-AF8C-3097F97E1E67'
|
90
|
-
|
91
|
-
response = double
|
92
|
-
allow(response).to receive(:to_str).and_return(canned_subscription_get)
|
93
|
-
allow(RestClient::Request).to receive(:execute).and_return(response)
|
94
|
-
|
95
|
-
subscription = BillForward::Subscription.get_by_id subscription_id
|
96
|
-
|
97
82
|
a_pricing_component = subscription.productRatePlan.pricingComponents.first
|
98
83
|
expect(a_pricing_component.name).to eq('Devices used, fixed')
|
99
84
|
|
@@ -105,26 +90,10 @@ describe BillForward::Subscription do
|
|
105
90
|
end
|
106
91
|
context 'using array access' do
|
107
92
|
it "can be read" do
|
108
|
-
subscription_id = 'ACD66517-6F32-44CB-AF8C-3097F97E1E67'
|
109
|
-
|
110
|
-
response = double
|
111
|
-
allow(response).to receive(:to_str).and_return(canned_subscription_get)
|
112
|
-
allow(RestClient::Request).to receive(:execute).and_return(response)
|
113
|
-
|
114
|
-
subscription = BillForward::Subscription.get_by_id subscription_id
|
115
|
-
|
116
93
|
a_pricing_component = subscription['productRatePlan']['pricingComponents'].first
|
117
94
|
expect(a_pricing_component['name']).to eq('Devices used, fixed')
|
118
95
|
end
|
119
96
|
it "can be changed" do
|
120
|
-
subscription_id = 'ACD66517-6F32-44CB-AF8C-3097F97E1E67'
|
121
|
-
|
122
|
-
response = double
|
123
|
-
allow(response).to receive(:to_str).and_return(canned_subscription_get)
|
124
|
-
allow(RestClient::Request).to receive(:execute).and_return(response)
|
125
|
-
|
126
|
-
subscription = BillForward::Subscription.get_by_id subscription_id
|
127
|
-
|
128
97
|
a_pricing_component = subscription['productRatePlan']['pricingComponents'].first
|
129
98
|
expect(a_pricing_component['name']).to eq('Devices used, fixed')
|
130
99
|
|
@@ -354,4 +323,4 @@ def canned_subscription_get
|
|
354
323
|
"fixedTerms" : [ ]
|
355
324
|
} ]
|
356
325
|
}'
|
357
|
-
end
|
326
|
+
end
|
@@ -21,21 +21,21 @@ describe BillForward::Subscription do
|
|
21
21
|
first_org = organisations.first
|
22
22
|
|
23
23
|
|
24
|
-
# remove from our organisation all existing AuthorizeNetConfigurations (if any)
|
25
|
-
filtered = first_org.apiConfigurations.reject do |config|
|
26
|
-
|
27
|
-
end
|
28
|
-
first_org.apiConfigurations = filtered
|
24
|
+
# # remove from our organisation all existing AuthorizeNetConfigurations (if any)
|
25
|
+
# filtered = first_org.apiConfigurations.reject do |config|
|
26
|
+
# config['@type'] == 'AuthorizeNetConfiguration'
|
27
|
+
# end
|
28
|
+
# first_org.apiConfigurations = filtered
|
29
29
|
|
30
30
|
|
31
|
-
# add to our organisation: a new AuthorizeNetConfiguration
|
32
|
-
first_org.apiConfigurations.push BillForward::APIConfiguration.new({
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
updated_org = first_org.save
|
31
|
+
# # add to our organisation: a new AuthorizeNetConfiguration
|
32
|
+
# first_org.apiConfigurations.push BillForward::APIConfiguration.new({
|
33
|
+
# "@type" => "AuthorizeNetConfiguration",
|
34
|
+
# "APILoginID" => @authorize_net_login_id,
|
35
|
+
# "transactionKey" => @authorize_net_transaction_key,
|
36
|
+
# "environment" => "Sandbox"
|
37
|
+
# })
|
38
|
+
# updated_org = first_org.save
|
39
39
|
|
40
40
|
|
41
41
|
# create an account
|
@@ -236,7 +236,7 @@ describe BillForward::Subscription do
|
|
236
236
|
@created_account = created_account
|
237
237
|
@created_prp = created_prp
|
238
238
|
@created_payment_method = created_payment_method
|
239
|
-
@updated_org =
|
239
|
+
@updated_org = first_org
|
240
240
|
end
|
241
241
|
subject(:account) { @created_account }
|
242
242
|
subject(:prp) { @created_prp }
|
metadata
CHANGED
@@ -1,85 +1,122 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bill_forward
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.2016.209
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- BillForward
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: rest-client
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
version: "1.4"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
22
20
|
type: :runtime
|
23
|
-
version_requirements: *id001
|
24
|
-
- !ruby/object:Gem::Dependency
|
25
|
-
name: json
|
26
21
|
prerelease: false
|
27
|
-
|
28
|
-
requirements:
|
29
|
-
- - ~>
|
30
|
-
- !ruby/object:Gem::Version
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
31
33
|
version: 1.8.1
|
32
34
|
type: :runtime
|
33
|
-
|
34
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
35
42
|
name: require_all
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
36
49
|
prerelease: false
|
37
|
-
|
38
|
-
requirements:
|
39
|
-
-
|
40
|
-
-
|
41
|
-
|
42
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
43
62
|
type: :runtime
|
44
|
-
version_requirements: *id003
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: bundler
|
47
63
|
prerelease: false
|
48
|
-
|
49
|
-
requirements:
|
50
|
-
- -
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
53
76
|
type: :development
|
54
|
-
version_requirements: *id004
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
77
|
prerelease: false
|
58
|
-
|
59
|
-
requirements:
|
60
|
-
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
61
90
|
type: :development
|
62
|
-
version_requirements: *id006
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: rake
|
65
91
|
prerelease: false
|
66
|
-
|
67
|
-
requirements:
|
68
|
-
-
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
69
104
|
type: :development
|
70
|
-
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
71
111
|
description: Enables you to call the BillForward API easily using Ruby
|
72
|
-
email:
|
112
|
+
email:
|
73
113
|
- support@billforward.net
|
74
114
|
executables: []
|
75
|
-
|
76
115
|
extensions: []
|
77
|
-
|
78
116
|
extra_rdoc_files: []
|
79
|
-
|
80
|
-
|
81
|
-
- .
|
82
|
-
- .rspec
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
83
120
|
- Gemfile
|
84
121
|
- LICENSE.md
|
85
122
|
- README.md
|
@@ -167,29 +204,30 @@ files:
|
|
167
204
|
- tools/local_bundle_build.sh
|
168
205
|
- tools/local_bundle_install.sh
|
169
206
|
homepage: http://www.billforward.net
|
170
|
-
licenses:
|
207
|
+
licenses:
|
171
208
|
- MIT
|
172
209
|
metadata: {}
|
173
|
-
|
174
210
|
post_install_message:
|
175
211
|
rdoc_options: []
|
176
|
-
|
177
|
-
require_paths:
|
212
|
+
require_paths:
|
178
213
|
- lib
|
179
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
-
requirements:
|
181
|
-
-
|
182
|
-
|
183
|
-
|
184
|
-
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
185
224
|
requirements: []
|
186
|
-
|
187
225
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
226
|
+
rubygems_version: 2.5.1
|
189
227
|
signing_key:
|
190
228
|
specification_version: 4
|
191
229
|
summary: BillForward Ruby Client Library
|
192
|
-
test_files:
|
230
|
+
test_files:
|
193
231
|
- spec/component/account_spec.rb
|
194
232
|
- spec/component/billing_entity_spec.rb
|
195
233
|
- spec/component/invoice_spec.rb
|