pin_up 1.3.4 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +4 -9
- data/Gemfile.lock +74 -99
- data/README.md +155 -11
- data/VERSION +1 -1
- data/lib/pin_up.rb +3 -0
- data/lib/pin_up/pin_errors.rb +6 -0
- data/lib/pin_up/plan.rb +79 -0
- data/lib/pin_up/subscription.rb +80 -0
- data/lib/pin_up/webhook_endpoints.rb +45 -0
- data/pin_up.gemspec +48 -44
- data/spec/cards_spec.rb +14 -2
- data/spec/charges_spec.rb +57 -13
- data/spec/customers_spec.rb +52 -23
- data/spec/errors_spec.rb +294 -61
- data/spec/plan_spec.rb +189 -0
- data/spec/recipients_spec.rb +14 -9
- data/spec/refund_spec.rb +42 -8
- data/spec/spec_helper.rb +3 -4
- data/spec/subscription_spec.rb +201 -0
- data/spec/transfers_spec.rb +23 -17
- data/spec/webhook_endpoints_spec.rb +36 -0
- metadata +20 -27
data/spec/transfers_spec.rb
CHANGED
@@ -1,25 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Pin::Transfer, :vcr do
|
4
|
+
let(:recipient_hash) {
|
5
|
+
{ email: 'test@example.com',
|
6
|
+
name: 'Roland Robot',
|
7
|
+
bank_account: { name: 'Roland Robot',
|
8
|
+
bsb: '123456',
|
9
|
+
number: 987654321 } }
|
10
|
+
}
|
11
|
+
|
12
|
+
let(:recipient) {
|
13
|
+
Pin::Recipient.create(recipient_hash)
|
14
|
+
}
|
15
|
+
|
16
|
+
let(:transfer) {
|
17
|
+
Pin::Transfer.create({ amount: 400,
|
18
|
+
currency: 'AUD',
|
19
|
+
description: 'Pay day',
|
20
|
+
recipient: recipient['token'] })
|
21
|
+
}
|
22
|
+
|
4
23
|
before(:each) do
|
5
24
|
Pin::Base.new(ENV['PIN_SECRET'], :test)
|
6
25
|
end
|
7
26
|
|
8
27
|
it 'returns the line items associated with transfer' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
options = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
13
|
-
transfer_token = Pin::Transfer.create(options)['token']
|
14
|
-
expect(Pin::Transfer.line_items(transfer_token).first).to include('amount', 'created_at', 'currency', 'type')
|
28
|
+
expect(Pin::Transfer.line_items(transfer['token']).first)
|
29
|
+
.to include('amount', 'created_at', 'currency', 'type')
|
15
30
|
end
|
16
31
|
|
17
32
|
it 'creates a transfer for a recipient, given a transfer hash' do
|
18
|
-
|
19
|
-
recipient = Pin::Recipient.create(options)
|
20
|
-
|
21
|
-
transfer = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
22
|
-
expect(Pin::Transfer.create(transfer)['token']).to match(/^[a-z]{4}[_]/)
|
33
|
+
expect(transfer['token']).to match(/^[a-z]{4}[_]/)
|
23
34
|
end
|
24
35
|
|
25
36
|
it 'returns a paginated list of all transfers' do
|
@@ -27,12 +38,7 @@ describe Pin::Transfer, :vcr do
|
|
27
38
|
end
|
28
39
|
|
29
40
|
it 'returns the details of a transfer' do
|
30
|
-
|
31
|
-
recipient = Pin::Recipient.create(options)
|
32
|
-
|
33
|
-
options = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
34
|
-
transfer_token = Pin::Transfer.create(options)['token']
|
35
|
-
expect(Pin::Transfer.find(transfer_token)['token']).to eq transfer_token
|
41
|
+
expect(Pin::Transfer.find(transfer['token'])['token']).to eq transfer['token']
|
36
42
|
end
|
37
43
|
|
38
44
|
it 'should not show a charge if end_date is out of range' do
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'WebhookEndpoints', :vcr, class: Pin::WebhookEndpoints do
|
4
|
+
let(:token) {
|
5
|
+
Pin::WebhookEndpoints.create({ url: "http://example.com/webhooks#{Time.now.to_i}/" })['token']
|
6
|
+
}
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
Pin::Base.new(ENV['PIN_SECRET'], :test)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should create a webhook endpoint and returns its details' do
|
13
|
+
expect(token).to match(/^whe_/)
|
14
|
+
Pin::WebhookEndpoints.delete(token) # since we are only allowed 5 or so sandbox webhooks
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should list webhook endpoints' do
|
18
|
+
expect(Pin::WebhookEndpoints.all).to_not eq []
|
19
|
+
Pin::WebhookEndpoints.delete(token) # since we are only allowed 5 or so sandbox webhooks
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should list webhook endpoint on a page given a page' do
|
23
|
+
request = Pin::WebhookEndpoints.all(1, true)
|
24
|
+
expect(request[:response]).to_not eq []
|
25
|
+
Pin::WebhookEndpoints.delete(token) # since we are only allowed 5 or so sandbox webhooks
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should show a webhook endpoint given a token' do
|
29
|
+
expect(Pin::WebhookEndpoints.find(token)['token']).to eq token
|
30
|
+
Pin::WebhookEndpoints.delete(token) # since we are only allowed 5 or so sandbox webhooks
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should delete a webhook endpoint given a token' do
|
34
|
+
expect(Pin::WebhookEndpoints.delete(token).response.code).to eq "204"
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pin_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Nitsikopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.11.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: shoulda
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.5'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.5'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rdoc
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +58,14 @@ dependencies:
|
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
61
|
+
version: 2.3.9
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
68
|
+
version: 2.3.9
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: simplecov
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,30 +84,30 @@ dependencies:
|
|
98
84
|
name: webmock
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- - "
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- - "
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
96
|
+
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: vcr
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- - "
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- - "
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
110
|
+
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: guard-rspec
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +146,7 @@ extra_rdoc_files:
|
|
160
146
|
files:
|
161
147
|
- ".document"
|
162
148
|
- ".travis.yml"
|
149
|
+
- CHANGELOG.md
|
163
150
|
- Gemfile
|
164
151
|
- Gemfile.lock
|
165
152
|
- Guardfile
|
@@ -177,9 +164,12 @@ files:
|
|
177
164
|
- lib/pin_up/client.rb
|
178
165
|
- lib/pin_up/customer.rb
|
179
166
|
- lib/pin_up/pin_errors.rb
|
167
|
+
- lib/pin_up/plan.rb
|
180
168
|
- lib/pin_up/recipient.rb
|
181
169
|
- lib/pin_up/refund.rb
|
170
|
+
- lib/pin_up/subscription.rb
|
182
171
|
- lib/pin_up/transfer.rb
|
172
|
+
- lib/pin_up/webhook_endpoints.rb
|
183
173
|
- pin_up.gemspec
|
184
174
|
- spec/balance_spec.rb
|
185
175
|
- spec/bank_accounts_spec.rb
|
@@ -189,10 +179,13 @@ files:
|
|
189
179
|
- spec/client_spec.rb
|
190
180
|
- spec/customers_spec.rb
|
191
181
|
- spec/errors_spec.rb
|
182
|
+
- spec/plan_spec.rb
|
192
183
|
- spec/recipients_spec.rb
|
193
184
|
- spec/refund_spec.rb
|
194
185
|
- spec/spec_helper.rb
|
186
|
+
- spec/subscription_spec.rb
|
195
187
|
- spec/transfers_spec.rb
|
188
|
+
- spec/webhook_endpoints_spec.rb
|
196
189
|
homepage: http://github.com/dNitza/pin_up
|
197
190
|
licenses:
|
198
191
|
- MIT
|
@@ -213,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
206
|
version: '0'
|
214
207
|
requirements: []
|
215
208
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
209
|
+
rubygems_version: 2.7.3
|
217
210
|
signing_key:
|
218
211
|
specification_version: 4
|
219
212
|
summary: A Ruby gem wrapper for the pin-payments API
|