gocardless_pro 0.3.0 → 1.0.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 +14 -29
- data/lib/gocardless_pro.rb +7 -3
- data/lib/gocardless_pro/api_response.rb +14 -0
- data/lib/gocardless_pro/client.rb +24 -12
- data/lib/gocardless_pro/list_response.rb +7 -3
- data/lib/gocardless_pro/request.rb +3 -11
- data/lib/gocardless_pro/resources/{helper.rb → bank_details_lookup.rb} +15 -4
- data/lib/gocardless_pro/resources/creditor.rb +14 -13
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +14 -10
- data/lib/gocardless_pro/resources/customer.rb +8 -4
- data/lib/gocardless_pro/resources/customer_bank_account.rb +15 -13
- data/lib/gocardless_pro/resources/event.rb +6 -1
- data/lib/gocardless_pro/resources/mandate.rb +10 -7
- data/lib/gocardless_pro/resources/mandate_pdf.rb +42 -0
- data/lib/gocardless_pro/resources/payment.rb +12 -11
- data/lib/gocardless_pro/resources/payout.rb +9 -6
- data/lib/gocardless_pro/resources/redirect_flow.rb +24 -30
- data/lib/gocardless_pro/resources/refund.rb +15 -15
- data/lib/gocardless_pro/resources/subscription.rb +26 -22
- data/lib/gocardless_pro/response.rb +5 -0
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +55 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +8 -9
- data/lib/gocardless_pro/services/creditors_service.rb +6 -7
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +15 -18
- data/lib/gocardless_pro/services/customers_service.rb +6 -7
- data/lib/gocardless_pro/services/events_service.rb +4 -6
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +63 -0
- data/lib/gocardless_pro/services/mandates_service.rb +12 -24
- data/lib/gocardless_pro/services/payments_service.rb +15 -16
- data/lib/gocardless_pro/services/payouts_service.rb +5 -6
- data/lib/gocardless_pro/services/redirect_flows_service.rb +13 -17
- data/lib/gocardless_pro/services/refunds_service.rb +16 -19
- data/lib/gocardless_pro/services/subscriptions_service.rb +10 -11
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/api_response_spec.rb +28 -0
- data/spec/resources/bank_details_lookup_spec.rb +39 -0
- data/spec/resources/creditor_spec.rb +0 -4
- data/spec/resources/{helper_spec.rb → mandate_pdf_spec.rb} +17 -1
- data/spec/resources/subscription_spec.rb +4 -4
- data/spec/services/bank_details_lookups_service_spec.rb +80 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +2 -0
- data/spec/services/creditors_service_spec.rb +2 -0
- data/spec/services/customer_bank_accounts_service_spec.rb +2 -0
- data/spec/services/customers_service_spec.rb +2 -0
- data/spec/services/events_service_spec.rb +2 -0
- data/spec/services/mandate_pdfs_service_spec.rb +80 -0
- data/spec/services/mandates_service_spec.rb +2 -0
- data/spec/services/payments_service_spec.rb +2 -0
- data/spec/services/payouts_service_spec.rb +2 -0
- data/spec/services/refunds_service_spec.rb +2 -0
- data/spec/services/subscriptions_service_spec.rb +26 -24
- metadata +17 -8
- data/lib/gocardless_pro/services/helpers_service.rb +0 -99
- data/spec/services/helpers_service_spec.rb +0 -122
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocardless_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- demo.rb
|
102
102
|
- gocardless_pro.gemspec
|
103
103
|
- lib/gocardless_pro.rb
|
104
|
+
- lib/gocardless_pro/api_response.rb
|
104
105
|
- lib/gocardless_pro/api_service.rb
|
105
106
|
- lib/gocardless_pro/client.rb
|
106
107
|
- lib/gocardless_pro/error.rb
|
@@ -111,26 +112,28 @@ files:
|
|
111
112
|
- lib/gocardless_pro/list_response.rb
|
112
113
|
- lib/gocardless_pro/paginator.rb
|
113
114
|
- lib/gocardless_pro/request.rb
|
115
|
+
- lib/gocardless_pro/resources/bank_details_lookup.rb
|
114
116
|
- lib/gocardless_pro/resources/creditor.rb
|
115
117
|
- lib/gocardless_pro/resources/creditor_bank_account.rb
|
116
118
|
- lib/gocardless_pro/resources/customer.rb
|
117
119
|
- lib/gocardless_pro/resources/customer_bank_account.rb
|
118
120
|
- lib/gocardless_pro/resources/event.rb
|
119
|
-
- lib/gocardless_pro/resources/helper.rb
|
120
121
|
- lib/gocardless_pro/resources/mandate.rb
|
122
|
+
- lib/gocardless_pro/resources/mandate_pdf.rb
|
121
123
|
- lib/gocardless_pro/resources/payment.rb
|
122
124
|
- lib/gocardless_pro/resources/payout.rb
|
123
125
|
- lib/gocardless_pro/resources/redirect_flow.rb
|
124
126
|
- lib/gocardless_pro/resources/refund.rb
|
125
127
|
- lib/gocardless_pro/resources/subscription.rb
|
126
128
|
- lib/gocardless_pro/response.rb
|
129
|
+
- lib/gocardless_pro/services/bank_details_lookups_service.rb
|
127
130
|
- lib/gocardless_pro/services/base_service.rb
|
128
131
|
- lib/gocardless_pro/services/creditor_bank_accounts_service.rb
|
129
132
|
- lib/gocardless_pro/services/creditors_service.rb
|
130
133
|
- lib/gocardless_pro/services/customer_bank_accounts_service.rb
|
131
134
|
- lib/gocardless_pro/services/customers_service.rb
|
132
135
|
- lib/gocardless_pro/services/events_service.rb
|
133
|
-
- lib/gocardless_pro/services/
|
136
|
+
- lib/gocardless_pro/services/mandate_pdfs_service.rb
|
134
137
|
- lib/gocardless_pro/services/mandates_service.rb
|
135
138
|
- lib/gocardless_pro/services/payments_service.rb
|
136
139
|
- lib/gocardless_pro/services/payouts_service.rb
|
@@ -138,15 +141,17 @@ files:
|
|
138
141
|
- lib/gocardless_pro/services/refunds_service.rb
|
139
142
|
- lib/gocardless_pro/services/subscriptions_service.rb
|
140
143
|
- lib/gocardless_pro/version.rb
|
144
|
+
- spec/api_response_spec.rb
|
141
145
|
- spec/api_service_spec.rb
|
142
146
|
- spec/client_spec.rb
|
143
147
|
- spec/error_spec.rb
|
148
|
+
- spec/resources/bank_details_lookup_spec.rb
|
144
149
|
- spec/resources/creditor_bank_account_spec.rb
|
145
150
|
- spec/resources/creditor_spec.rb
|
146
151
|
- spec/resources/customer_bank_account_spec.rb
|
147
152
|
- spec/resources/customer_spec.rb
|
148
153
|
- spec/resources/event_spec.rb
|
149
|
-
- spec/resources/
|
154
|
+
- spec/resources/mandate_pdf_spec.rb
|
150
155
|
- spec/resources/mandate_spec.rb
|
151
156
|
- spec/resources/payment_spec.rb
|
152
157
|
- spec/resources/payout_spec.rb
|
@@ -154,12 +159,13 @@ files:
|
|
154
159
|
- spec/resources/refund_spec.rb
|
155
160
|
- spec/resources/subscription_spec.rb
|
156
161
|
- spec/response_spec.rb
|
162
|
+
- spec/services/bank_details_lookups_service_spec.rb
|
157
163
|
- spec/services/creditor_bank_accounts_service_spec.rb
|
158
164
|
- spec/services/creditors_service_spec.rb
|
159
165
|
- spec/services/customer_bank_accounts_service_spec.rb
|
160
166
|
- spec/services/customers_service_spec.rb
|
161
167
|
- spec/services/events_service_spec.rb
|
162
|
-
- spec/services/
|
168
|
+
- spec/services/mandate_pdfs_service_spec.rb
|
163
169
|
- spec/services/mandates_service_spec.rb
|
164
170
|
- spec/services/payments_service_spec.rb
|
165
171
|
- spec/services/payouts_service_spec.rb
|
@@ -192,15 +198,17 @@ signing_key:
|
|
192
198
|
specification_version: 4
|
193
199
|
summary: A gem for calling the GoCardless Pro API
|
194
200
|
test_files:
|
201
|
+
- spec/api_response_spec.rb
|
195
202
|
- spec/api_service_spec.rb
|
196
203
|
- spec/client_spec.rb
|
197
204
|
- spec/error_spec.rb
|
205
|
+
- spec/resources/bank_details_lookup_spec.rb
|
198
206
|
- spec/resources/creditor_bank_account_spec.rb
|
199
207
|
- spec/resources/creditor_spec.rb
|
200
208
|
- spec/resources/customer_bank_account_spec.rb
|
201
209
|
- spec/resources/customer_spec.rb
|
202
210
|
- spec/resources/event_spec.rb
|
203
|
-
- spec/resources/
|
211
|
+
- spec/resources/mandate_pdf_spec.rb
|
204
212
|
- spec/resources/mandate_spec.rb
|
205
213
|
- spec/resources/payment_spec.rb
|
206
214
|
- spec/resources/payout_spec.rb
|
@@ -208,12 +216,13 @@ test_files:
|
|
208
216
|
- spec/resources/refund_spec.rb
|
209
217
|
- spec/resources/subscription_spec.rb
|
210
218
|
- spec/response_spec.rb
|
219
|
+
- spec/services/bank_details_lookups_service_spec.rb
|
211
220
|
- spec/services/creditor_bank_accounts_service_spec.rb
|
212
221
|
- spec/services/creditors_service_spec.rb
|
213
222
|
- spec/services/customer_bank_accounts_service_spec.rb
|
214
223
|
- spec/services/customers_service_spec.rb
|
215
224
|
- spec/services/events_service_spec.rb
|
216
|
-
- spec/services/
|
225
|
+
- spec/services/mandate_pdfs_service_spec.rb
|
217
226
|
- spec/services/mandates_service_spec.rb
|
218
227
|
- spec/services/payments_service_spec.rb
|
219
228
|
- spec/services/payouts_service_spec.rb
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require_relative './base_service'
|
2
|
-
|
3
|
-
# encoding: utf-8
|
4
|
-
#
|
5
|
-
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
-
#
|
7
|
-
# https://github.com/gocardless/crank
|
8
|
-
|
9
|
-
module GoCardlessPro
|
10
|
-
module Services
|
11
|
-
# Service for making requests to the Helper endpoints
|
12
|
-
class HelpersService < BaseService
|
13
|
-
# Returns a PDF mandate form with a signature field, ready to be signed by your
|
14
|
-
# customer. May be fully or partially pre-filled.
|
15
|
-
#
|
16
|
-
# You must specify `Accept:
|
17
|
-
# application/pdf` on requests to this endpoint.
|
18
|
-
#
|
19
|
-
# Bank account details may
|
20
|
-
# either be supplied using the IBAN (international bank account number), or
|
21
|
-
# [local
|
22
|
-
# details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details).
|
23
|
-
# For more information on the different fields required in each country, please
|
24
|
-
# see the [local bank
|
25
|
-
# details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details)
|
26
|
-
# section.
|
27
|
-
#
|
28
|
-
# To generate a mandate in a foreign language, set your
|
29
|
-
# `Accept-Language` header to the relevant [ISO
|
30
|
-
# 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table)
|
31
|
-
# language code. Currently Dutch, English, French, German, Italian, Portuguese
|
32
|
-
# and Spanish are supported.
|
33
|
-
#
|
34
|
-
# _Note:_ If you want to render a PDF of an
|
35
|
-
# existing mandate you can also do so using the [mandate show
|
36
|
-
# endpoint](https://developer.gocardless.com/pro/2015-04-29/#mandates-get-a-single-mandate).
|
37
|
-
# Example URL: /helpers/mandate
|
38
|
-
# @param options [Hash] parameters as a hash, under a params key.
|
39
|
-
def mandate(options = {})
|
40
|
-
path = '/helpers/mandate'
|
41
|
-
|
42
|
-
params = options.delete(:params) || {}
|
43
|
-
options[:params] = {}
|
44
|
-
options[:params]['data'] = params
|
45
|
-
response = make_request(:post, path, options)
|
46
|
-
|
47
|
-
return if response.body.nil?
|
48
|
-
Resources::Helper.new(unenvelope_body(response.body))
|
49
|
-
end
|
50
|
-
|
51
|
-
# Check whether an account number and bank / branch code combination are
|
52
|
-
# compatible.
|
53
|
-
#
|
54
|
-
# Bank account details may either be supplied using the IBAN
|
55
|
-
# (international bank account number), or [local
|
56
|
-
# details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details).
|
57
|
-
# For more information on the different fields required in each country, please
|
58
|
-
# see the [local bank
|
59
|
-
# details](https://developer.gocardless.com/pro/2015-04-29/#ui-local-bank-details)
|
60
|
-
# section.
|
61
|
-
# Example URL: /helpers/modulus_check
|
62
|
-
# @param options [Hash] parameters as a hash, under a params key.
|
63
|
-
def modulus_check(options = {})
|
64
|
-
path = '/helpers/modulus_check'
|
65
|
-
|
66
|
-
params = options.delete(:params) || {}
|
67
|
-
options[:params] = {}
|
68
|
-
options[:params]['data'] = params
|
69
|
-
response = make_request(:post, path, options)
|
70
|
-
|
71
|
-
return if response.body.nil?
|
72
|
-
Resources::Helper.new(unenvelope_body(response.body))
|
73
|
-
end
|
74
|
-
|
75
|
-
# Unenvelope the response of the body using the service's `envelope_key`
|
76
|
-
#
|
77
|
-
# @param body [Hash]
|
78
|
-
def unenvelope_body(body)
|
79
|
-
body[envelope_key] || body['data']
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
# return the key which API responses will envelope data under
|
85
|
-
def envelope_key
|
86
|
-
'helpers'
|
87
|
-
end
|
88
|
-
|
89
|
-
# take a URL with placeholder params and substitute them out for the acutal value
|
90
|
-
# @param url [String] the URL with placeholders in
|
91
|
-
# @param param_map [Hash] a hash of placeholders and their actual values
|
92
|
-
def sub_url(url, param_map)
|
93
|
-
param_map.reduce(url) do |new_url, (param, value)|
|
94
|
-
new_url.gsub(":#{param}", value)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GoCardlessPro::Services::HelpersService do
|
4
|
-
let(:client) do
|
5
|
-
GoCardlessPro::Client.new(
|
6
|
-
access_token: "SECRET_TOKEN"
|
7
|
-
)
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
describe "#mandate" do
|
16
|
-
|
17
|
-
|
18
|
-
subject(:post_response) { client.helpers.mandate }
|
19
|
-
|
20
|
-
let(:resource_id) { "ABC123" }
|
21
|
-
|
22
|
-
let!(:stub) do
|
23
|
-
# /helpers/mandate
|
24
|
-
stub_url = "/helpers/mandate".gsub(':identity', resource_id)
|
25
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
26
|
-
body: {
|
27
|
-
helpers: {
|
28
|
-
|
29
|
-
}
|
30
|
-
}.to_json,
|
31
|
-
headers: {'Content-Type' => 'application/json'},
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "wraps the response and calls the right endpoint" do
|
36
|
-
expect(post_response).to be_a(GoCardlessPro::Resources::Helper)
|
37
|
-
|
38
|
-
expect(stub).to have_been_requested
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when the request needs a body and custom header" do
|
42
|
-
|
43
|
-
subject(:post_response) { client.helpers.mandate(body, headers) }
|
44
|
-
|
45
|
-
let(:resource_id) { "ABC123" }
|
46
|
-
|
47
|
-
let!(:stub) do
|
48
|
-
# /helpers/mandate
|
49
|
-
stub_url = "/helpers/mandate".gsub(':identity', resource_id)
|
50
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
51
|
-
with(
|
52
|
-
body: { foo: 'bar' },
|
53
|
-
headers: { 'Foo' => 'Bar' }
|
54
|
-
).to_return(
|
55
|
-
body: {
|
56
|
-
helpers: {
|
57
|
-
|
58
|
-
}
|
59
|
-
}.to_json,
|
60
|
-
headers: {'Content-Type' => 'application/json'},
|
61
|
-
)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
describe "#modulus_check" do
|
71
|
-
|
72
|
-
|
73
|
-
subject(:post_response) { client.helpers.modulus_check }
|
74
|
-
|
75
|
-
let(:resource_id) { "ABC123" }
|
76
|
-
|
77
|
-
let!(:stub) do
|
78
|
-
# /helpers/modulus_check
|
79
|
-
stub_url = "/helpers/modulus_check".gsub(':identity', resource_id)
|
80
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
|
81
|
-
body: {
|
82
|
-
helpers: {
|
83
|
-
|
84
|
-
}
|
85
|
-
}.to_json,
|
86
|
-
headers: {'Content-Type' => 'application/json'},
|
87
|
-
)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "wraps the response and calls the right endpoint" do
|
91
|
-
expect(post_response).to be_a(GoCardlessPro::Resources::Helper)
|
92
|
-
|
93
|
-
expect(stub).to have_been_requested
|
94
|
-
end
|
95
|
-
|
96
|
-
context "when the request needs a body and custom header" do
|
97
|
-
|
98
|
-
subject(:post_response) { client.helpers.modulus_check(body, headers) }
|
99
|
-
|
100
|
-
let(:resource_id) { "ABC123" }
|
101
|
-
|
102
|
-
let!(:stub) do
|
103
|
-
# /helpers/modulus_check
|
104
|
-
stub_url = "/helpers/modulus_check".gsub(':identity', resource_id)
|
105
|
-
stub_request(:post, /.*api.gocardless.com#{stub_url}/).
|
106
|
-
with(
|
107
|
-
body: { foo: 'bar' },
|
108
|
-
headers: { 'Foo' => 'Bar' }
|
109
|
-
).to_return(
|
110
|
-
body: {
|
111
|
-
helpers: {
|
112
|
-
|
113
|
-
}
|
114
|
-
}.to_json,
|
115
|
-
headers: {'Content-Type' => 'application/json'},
|
116
|
-
)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
end
|