besepa 0.6.0 → 0.7.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/README.md +2 -2
- data/lib/besepa/subscription.rb +17 -16
- data/lib/besepa/utils/version.rb +1 -1
- data/spec/besepa/subscription_spec.rb +48 -0
- data/spec/fixtures/collection.json +16 -0
- data/spec/fixtures/resource.json +6 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 541db1f857b26a78e692f0b9726339e47717dd0e
|
4
|
+
data.tar.gz: 4d1e77684718babafaa9a6a1ec3b94b09f5a6a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49fa1a8d2f6c9cf08cdaac2878c9fd044f117fd871f7d4d7e711ad238fea7807f83798fe8a137878b5ed49da2ec0d44532efd8d86d8e7016f74eb464d0fbee2a
|
7
|
+
data.tar.gz: 01d54c2de5ded148bb9ff013a7c23c9f3be98b480f8db7ec481fce533808e1ddb230949a3d040bb47b31cdb35815eb513a10cd3eb5b64d59213f2be10fe245e0
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ A Ruby gem to Besepa.com's API.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'besepa
|
9
|
+
gem 'besepa'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,7 +14,7 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install besepa
|
17
|
+
$ gem install besepa
|
18
18
|
|
19
19
|
## Documentation
|
20
20
|
|
data/lib/besepa/subscription.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
module Besepa
|
2
|
-
|
3
2
|
class Subscription < Besepa::Resource
|
4
|
-
|
3
|
+
|
5
4
|
include Besepa::ApiCalls::List
|
6
5
|
include Besepa::ApiCalls::Create
|
7
6
|
include Besepa::ApiCalls::Destroy
|
8
|
-
|
9
|
-
FIELDS = [:id, :last_debit, :next_debit, :status, :metadata, :starts_at, :renew_at, :created_at, :setup_fee]
|
10
|
-
|
11
|
-
|
7
|
+
|
8
|
+
FIELDS = [:id, :last_debit, :next_debit, :status, :metadata, :starts_at, :renew_at, :created_at, :setup_fee, :customer_code]
|
9
|
+
|
12
10
|
FIELDS.each do |f|
|
13
11
|
attr_accessor f
|
14
12
|
end
|
15
|
-
|
16
|
-
attr_accessor :debtor_bank_account, :product, :customer
|
17
|
-
|
13
|
+
|
14
|
+
attr_accessor :debtor_bank_account, :product, :customer
|
15
|
+
|
18
16
|
def to_hash
|
19
17
|
values = {}
|
20
18
|
self.class::FIELDS.each do |key|
|
@@ -25,15 +23,20 @@ module Besepa
|
|
25
23
|
values[:customer] = customer.to_hash if customer
|
26
24
|
values
|
27
25
|
end
|
28
|
-
|
26
|
+
|
29
27
|
def self.api_path(filters={})
|
30
|
-
|
28
|
+
customer_id = filters[:customer_id]
|
29
|
+
if customer_id
|
30
|
+
"#{Customer.api_path}/#{CGI.escape(customer_id)}/subscriptions"
|
31
|
+
else
|
32
|
+
"/subscriptions"
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
36
|
def api_path(filters={})
|
34
|
-
"#{
|
37
|
+
"#{self.class.api_path(filters)}/#{CGI.escape(id)}"
|
35
38
|
end
|
36
|
-
|
39
|
+
|
37
40
|
def process_attributes(attrs)
|
38
41
|
self.class::FIELDS.each do |key|
|
39
42
|
self.send("#{key.to_s}=", attrs[key.to_s] || attrs[key.to_sym])
|
@@ -44,7 +47,5 @@ module Besepa
|
|
44
47
|
process_activities(attrs)
|
45
48
|
self
|
46
49
|
end
|
47
|
-
|
48
|
-
|
49
50
|
end
|
50
|
-
end
|
51
|
+
end
|
data/lib/besepa/utils/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Besepa::Subscription do
|
4
|
+
|
5
|
+
describe '#all' do
|
6
|
+
it 'without customer' do
|
7
|
+
stub_get('/subscriptions?page=1').to_return(body: fixture('collection.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
8
|
+
|
9
|
+
subscriptions = Besepa::Subscription.all(page: 1)
|
10
|
+
expect(subscriptions).to respond_to(:each)
|
11
|
+
expect(subscriptions.first).to be_an Besepa::Subscription
|
12
|
+
expect(subscriptions.size).to eq(1)
|
13
|
+
expect(subscriptions.per_page).to eq(50)
|
14
|
+
expect(subscriptions.current_page).to eq(1)
|
15
|
+
expect(subscriptions.total).to eq(1)
|
16
|
+
expect(subscriptions.pages).to eq(1)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'with customer' do
|
20
|
+
stub_get('/customers/bar/subscriptions?page=1').to_return(body: fixture('collection.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
21
|
+
|
22
|
+
subscriptions = Besepa::Subscription.all(page: 1, customer_id: 'bar')
|
23
|
+
expect(subscriptions).to respond_to(:each)
|
24
|
+
expect(subscriptions.first).to be_an Besepa::Subscription
|
25
|
+
expect(subscriptions.size).to eq(1)
|
26
|
+
expect(subscriptions.per_page).to eq(50)
|
27
|
+
expect(subscriptions.current_page).to eq(1)
|
28
|
+
expect(subscriptions.total).to eq(1)
|
29
|
+
expect(subscriptions.pages).to eq(1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#find' do
|
34
|
+
it 'without customer' do
|
35
|
+
stub_get('/subscription/1?page=1').to_return(body: fixture('resource.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
36
|
+
|
37
|
+
subscription = Besepa::Subscription.find('1')
|
38
|
+
expect(subscription).to be_an Besepa::Subscription
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'with customer' do
|
42
|
+
stub_get('/customers/bar/subscription/1?page=1').to_return(body: fixture('resource.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
43
|
+
|
44
|
+
subscription = Besepa::Subscription.find('1')
|
45
|
+
expect(subscription).to be_an Besepa::Subscription
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: besepa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- besepa.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -135,12 +135,15 @@ files:
|
|
135
135
|
- lib/besepa/webhook.rb
|
136
136
|
- spec/besepa/customer_spec.rb
|
137
137
|
- spec/besepa/group_spec.rb
|
138
|
+
- spec/besepa/subscription_spec.rb
|
139
|
+
- spec/fixtures/collection.json
|
138
140
|
- spec/fixtures/customer.json
|
139
141
|
- spec/fixtures/customer_add_debit.json
|
140
142
|
- spec/fixtures/customer_bank_accounts.json
|
141
143
|
- spec/fixtures/customer_debits.json
|
142
144
|
- spec/fixtures/customer_removed.json
|
143
145
|
- spec/fixtures/customers.json
|
146
|
+
- spec/fixtures/resource.json
|
144
147
|
- spec/helper.rb
|
145
148
|
homepage: http://www.besepa.com
|
146
149
|
licenses:
|
@@ -162,17 +165,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
165
|
version: '0'
|
163
166
|
requirements: []
|
164
167
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.5.1
|
168
|
+
rubygems_version: 2.4.5.1
|
166
169
|
signing_key:
|
167
170
|
specification_version: 4
|
168
171
|
summary: Ruby client for besepa.com
|
169
172
|
test_files:
|
170
173
|
- spec/besepa/customer_spec.rb
|
171
174
|
- spec/besepa/group_spec.rb
|
175
|
+
- spec/besepa/subscription_spec.rb
|
176
|
+
- spec/fixtures/collection.json
|
172
177
|
- spec/fixtures/customer.json
|
173
178
|
- spec/fixtures/customer_add_debit.json
|
174
179
|
- spec/fixtures/customer_bank_accounts.json
|
175
180
|
- spec/fixtures/customer_debits.json
|
176
181
|
- spec/fixtures/customer_removed.json
|
177
182
|
- spec/fixtures/customers.json
|
183
|
+
- spec/fixtures/resource.json
|
178
184
|
- spec/helper.rb
|