besepa 0.4.1 → 0.5.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/.gitignore +15 -0
- data/lib/besepa/api_calls/search.rb +25 -0
- data/lib/besepa/customer.rb +2 -1
- data/lib/besepa/group.rb +5 -1
- data/lib/besepa/utils/version.rb +2 -2
- data/spec/besepa/customer_spec.rb +27 -34
- data/spec/besepa/group_spec.rb +18 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c069ce337f4d79698fad699f1b84963b81b083b2
|
4
|
+
data.tar.gz: 88a9d145c8bffd3987a5426efb3ac3161339ce1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b68ac3392ce09105c3109845cffdd641edc88385e468f2ff4c7c6fb13a534597292fbcad5239321bb38a430a194b3cf39ef42241717d0a06f647ae64e5d21160
|
7
|
+
data.tar.gz: a40e01d429ac07a1cf07c40d8ffd6574dc56f69c14b7ab6a347aca4aad946f6e3585f794ccdda700bc46d9aebe91f617182bc87fbcc7cd1a76e7fbd721533fc0
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Besepa
|
2
|
+
module ApiCalls
|
3
|
+
module Search
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
def search(filters = {})
|
7
|
+
response = get "/#{api_path}/search?field=#{filters[:field]}&value=#{filters[:value]}"
|
8
|
+
objects = Array.new
|
9
|
+
if response['count'] > 0
|
10
|
+
response['response'].each do |c|
|
11
|
+
objects << self.new(c)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
objects
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.included(base)
|
20
|
+
base.extend(ClassMethods)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/besepa/customer.rb
CHANGED
@@ -3,6 +3,7 @@ module Besepa
|
|
3
3
|
class Customer < Besepa::Resource
|
4
4
|
|
5
5
|
include Besepa::ApiCalls::List
|
6
|
+
include Besepa::ApiCalls::Search
|
6
7
|
include Besepa::ApiCalls::Create
|
7
8
|
include Besepa::ApiCalls::Update
|
8
9
|
include Besepa::ApiCalls::Destroy
|
@@ -141,4 +142,4 @@ module Besepa
|
|
141
142
|
end
|
142
143
|
|
143
144
|
end
|
144
|
-
end
|
145
|
+
end
|
data/lib/besepa/group.rb
CHANGED
data/lib/besepa/utils/version.rb
CHANGED
@@ -1,60 +1,66 @@
|
|
1
|
-
|
2
1
|
require 'helper'
|
3
2
|
|
4
3
|
describe Besepa::Customer do
|
5
4
|
|
6
5
|
describe '#all' do
|
7
|
-
|
8
6
|
before do
|
9
7
|
stub_get('/customers').to_return(body: fixture('customers.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
10
8
|
end
|
11
|
-
|
9
|
+
|
12
10
|
it 'returns a list of customers' do
|
13
11
|
customers = Besepa::Customer.all
|
14
12
|
expect(customers).to be_an Array
|
15
13
|
expect(customers.first).to be_an Besepa::Customer
|
16
14
|
expect(customers.size).to eq(1)
|
17
15
|
end
|
18
|
-
|
19
16
|
end
|
20
17
|
|
21
18
|
describe '#find' do
|
22
|
-
|
23
19
|
before do
|
24
20
|
stub_get('/customers/cus12345').to_return(body: fixture('customer.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
25
21
|
end
|
26
|
-
|
22
|
+
|
27
23
|
it 'returns a a customer' do
|
28
24
|
customer = Besepa::Customer.find('cus12345')
|
29
25
|
expect(customer).to be_an Besepa::Customer
|
30
26
|
expect(customer.name).to eq("Pancho Villa SLU")
|
31
27
|
end
|
32
|
-
|
33
28
|
end
|
34
|
-
|
35
|
-
describe '.save' do
|
36
29
|
|
30
|
+
describe '#search' do
|
31
|
+
before do
|
32
|
+
stub_get('/customers/search?field=group_id&value=foo').to_return(body: fixture('customers.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returs a list of customers' do
|
36
|
+
customers = Besepa::Customer.search(field: 'group_id', value: 'foo')
|
37
|
+
expect(customers).to be_an Array
|
38
|
+
expect(customers.first).to be_an Besepa::Customer
|
39
|
+
expect(customers.size).to eq(1)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.save' do
|
37
44
|
before do
|
38
45
|
stub_get('/customers/cus12345').to_return(body: fixture('customer.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
39
46
|
stub_put('/customers/cus12345').to_return(body: fixture('customer.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
40
47
|
end
|
41
|
-
|
48
|
+
|
42
49
|
it 'returns a a customer' do
|
43
50
|
customer = Besepa::Customer.find('cus12345')
|
44
51
|
customer.name = customer.name.reverse
|
45
52
|
customer = customer.save
|
46
53
|
expect(customer).to be_an Besepa::Customer
|
47
54
|
end
|
48
|
-
|
49
55
|
end
|
50
|
-
|
56
|
+
|
51
57
|
describe '.destroy' do
|
52
58
|
|
53
59
|
before do
|
54
60
|
stub_get('/customers/cus12345').to_return(body: fixture('customer.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
55
61
|
stub_delete('/customers/cus12345').to_return(body: fixture('customer_removed.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
56
62
|
end
|
57
|
-
|
63
|
+
|
58
64
|
it 'returns a a customer' do
|
59
65
|
customer = Besepa::Customer.find('cus12345')
|
60
66
|
customer.name = customer.name.reverse
|
@@ -62,58 +68,45 @@ describe Besepa::Customer do
|
|
62
68
|
expect(customer).to be_an Besepa::Customer
|
63
69
|
expect(customer.status).to eq('REMOVED')
|
64
70
|
end
|
65
|
-
|
66
71
|
end
|
67
|
-
|
68
|
-
|
72
|
+
|
69
73
|
describe "getting customer debits" do
|
70
|
-
|
71
74
|
before do
|
72
75
|
stub_get('/customers/cus12345/debits').to_return(body: fixture('customer_debits.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
73
76
|
end
|
74
|
-
|
77
|
+
|
75
78
|
it 'returns a list of debits' do
|
76
79
|
debits = Besepa::Customer.new(id: 'cus12345').debits
|
77
80
|
expect(debits).to be_an Array
|
78
81
|
expect(debits.first).to be_an Besepa::Debit
|
79
82
|
expect(debits.size).to eq(1)
|
80
83
|
end
|
81
|
-
|
82
84
|
end
|
83
|
-
|
84
|
-
describe "creating a debit for a customer" do
|
85
85
|
|
86
|
+
describe "creating a debit for a customer" do
|
86
87
|
describe "with valid data" do
|
87
|
-
|
88
88
|
before do
|
89
89
|
stub_post('/customers/cus12345/debits').to_return(body: fixture('customer_add_debit.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
it 'returns the new created debit' do
|
93
93
|
debit = Besepa::Customer.new(id: 'cus12345').add_debit("man123", "ref123", "desc123", 1000, '2015-11-23')
|
94
|
-
|
94
|
+
|
95
95
|
expect(debit).to be_an Besepa::Debit
|
96
96
|
end
|
97
|
-
|
98
97
|
end
|
99
|
-
|
100
98
|
end
|
101
|
-
|
102
|
-
|
99
|
+
|
103
100
|
describe "getting customer bank_accounts" do
|
104
|
-
|
105
101
|
before do
|
106
102
|
stub_get('/customers/cus12345/bank_accounts').to_return(body: fixture('customer_bank_accounts.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
107
103
|
end
|
108
|
-
|
109
|
-
|
104
|
+
|
110
105
|
it 'returns a list of bank accounts' do
|
111
106
|
bank_accounts = Besepa::Customer.new(id: 'cus12345').bank_accounts
|
112
107
|
expect(bank_accounts).to be_an Array
|
113
108
|
expect(bank_accounts.first).to be_an Besepa::BankAccount
|
114
109
|
expect(bank_accounts.size).to eq(1)
|
115
110
|
end
|
116
|
-
|
117
111
|
end
|
118
|
-
|
119
|
-
end
|
112
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Besepa::Group do
|
4
|
+
|
5
|
+
describe '#customers' do
|
6
|
+
before do
|
7
|
+
@group = Besepa::Group.new(id: 42)
|
8
|
+
stub_get('/customers/search?field=group_id&value=42').to_return(body: fixture('customers.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns a list of customers' do
|
12
|
+
customers = @group.customers
|
13
|
+
expect(customers).to be_an Array
|
14
|
+
expect(customers.first).to be_an Besepa::Customer
|
15
|
+
expect(customers.size).to eq(1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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.5.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:
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -101,6 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".gitignore"
|
104
105
|
- Gemfile
|
105
106
|
- Gemfile.lock
|
106
107
|
- LICENSE.txt
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- lib/besepa/api_calls/create.rb
|
113
114
|
- lib/besepa/api_calls/destroy.rb
|
114
115
|
- lib/besepa/api_calls/list.rb
|
116
|
+
- lib/besepa/api_calls/search.rb
|
115
117
|
- lib/besepa/api_calls/update.rb
|
116
118
|
- lib/besepa/bank_account.rb
|
117
119
|
- lib/besepa/business_account.rb
|
@@ -132,6 +134,7 @@ files:
|
|
132
134
|
- lib/besepa/utils/version.rb
|
133
135
|
- lib/besepa/webhook.rb
|
134
136
|
- spec/besepa/customer_spec.rb
|
137
|
+
- spec/besepa/group_spec.rb
|
135
138
|
- spec/fixtures/customer.json
|
136
139
|
- spec/fixtures/customer_add_debit.json
|
137
140
|
- spec/fixtures/customer_bank_accounts.json
|
@@ -159,12 +162,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
162
|
version: '0'
|
160
163
|
requirements: []
|
161
164
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.5.1
|
163
166
|
signing_key:
|
164
167
|
specification_version: 4
|
165
168
|
summary: Ruby client for besepa.com
|
166
169
|
test_files:
|
167
170
|
- spec/besepa/customer_spec.rb
|
171
|
+
- spec/besepa/group_spec.rb
|
168
172
|
- spec/fixtures/customer.json
|
169
173
|
- spec/fixtures/customer_add_debit.json
|
170
174
|
- spec/fixtures/customer_bank_accounts.json
|