gocardless_pro 1.0.0 → 1.0.1
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 +9 -0
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +3 -0
- data/lib/gocardless_pro/resources/creditor.rb +4 -1
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +12 -9
- data/lib/gocardless_pro/resources/customer_bank_account.rb +4 -1
- data/lib/gocardless_pro/resources/event.rb +4 -1
- data/lib/gocardless_pro/resources/mandate.rb +4 -1
- data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -1
- data/lib/gocardless_pro/resources/payment.rb +8 -5
- data/lib/gocardless_pro/resources/payout.rb +8 -4
- data/lib/gocardless_pro/resources/redirect_flow.rb +8 -1
- data/lib/gocardless_pro/resources/refund.rb +4 -1
- data/lib/gocardless_pro/resources/subscription.rb +4 -1
- data/lib/gocardless_pro/services/payouts_service.rb +1 -1
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/resources/bank_details_lookup_spec.rb +16 -1
- data/spec/resources/creditor_bank_account_spec.rb +13 -1
- data/spec/resources/creditor_spec.rb +13 -1
- data/spec/resources/customer_bank_account_spec.rb +13 -1
- data/spec/resources/customer_spec.rb +8 -1
- data/spec/resources/event_spec.rb +13 -1
- data/spec/resources/mandate_pdf_spec.rb +8 -1
- data/spec/resources/mandate_spec.rb +13 -1
- data/spec/resources/payment_spec.rb +13 -1
- data/spec/resources/payout_spec.rb +13 -1
- data/spec/resources/redirect_flow_spec.rb +21 -1
- data/spec/resources/refund_spec.rb +13 -1
- data/spec/resources/subscription_spec.rb +13 -1
- data/spec/services/bank_details_lookups_service_spec.rb +8 -4
- data/spec/services/creditor_bank_accounts_service_spec.rb +25 -21
- data/spec/services/creditors_service_spec.rb +24 -19
- data/spec/services/customer_bank_accounts_service_spec.rb +28 -23
- data/spec/services/customers_service_spec.rb +24 -19
- data/spec/services/events_service_spec.rb +17 -13
- data/spec/services/mandate_pdfs_service_spec.rb +5 -4
- data/spec/services/mandates_service_spec.rb +32 -27
- data/spec/services/payments_service_spec.rb +32 -27
- data/spec/services/payouts_service_spec.rb +17 -13
- data/spec/services/redirect_flows_service_spec.rb +19 -15
- data/spec/services/refunds_service_spec.rb +24 -19
- data/spec/services/subscriptions_service_spec.rb +28 -23
- metadata +3 -3
@@ -64,7 +64,7 @@ describe GoCardlessPro::Resources::Customer do
|
|
64
64
|
}
|
65
65
|
end
|
66
66
|
|
67
|
-
it "can be initialized from an
|
67
|
+
it "can be initialized from an unenveloped response" do
|
68
68
|
resource = described_class.new(data)
|
69
69
|
|
70
70
|
|
@@ -125,6 +125,13 @@ describe GoCardlessPro::Resources::Customer do
|
|
125
125
|
|
126
126
|
end
|
127
127
|
|
128
|
+
it "can handle new attributes without erroring" do
|
129
|
+
data["foo"] = "bar"
|
130
|
+
expect { described_class.new(data) }.to_not raise_error
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
128
135
|
describe "#to_h" do
|
129
136
|
it "returns a hash representing the resource" do
|
130
137
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -54,7 +54,7 @@ describe GoCardlessPro::Resources::Event do
|
|
54
54
|
}
|
55
55
|
end
|
56
56
|
|
57
|
-
it "can be initialized from an
|
57
|
+
it "can be initialized from an unenveloped response" do
|
58
58
|
resource = described_class.new(data)
|
59
59
|
|
60
60
|
|
@@ -103,6 +103,18 @@ describe GoCardlessPro::Resources::Event do
|
|
103
103
|
|
104
104
|
end
|
105
105
|
|
106
|
+
it "can handle new attributes without erroring" do
|
107
|
+
data["foo"] = "bar"
|
108
|
+
expect { described_class.new(data) }.to_not raise_error
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
it "can handle new link attributes without erroring" do
|
113
|
+
data["links"]["foo"] = "bar"
|
114
|
+
expect { described_class.new(data) }.to_not raise_error
|
115
|
+
end
|
116
|
+
|
117
|
+
|
106
118
|
describe "#to_h" do
|
107
119
|
it "returns a hash representing the resource" do
|
108
120
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -16,7 +16,7 @@ describe GoCardlessPro::Resources::MandatePdf do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
it "can be initialized from an
|
19
|
+
it "can be initialized from an unenveloped response" do
|
20
20
|
resource = described_class.new(data)
|
21
21
|
|
22
22
|
|
@@ -29,6 +29,13 @@ describe GoCardlessPro::Resources::MandatePdf do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
+
it "can handle new attributes without erroring" do
|
33
|
+
data["foo"] = "bar"
|
34
|
+
expect { described_class.new(data) }.to_not raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
32
39
|
describe "#to_h" do
|
33
40
|
it "returns a hash representing the resource" do
|
34
41
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -46,7 +46,7 @@ describe GoCardlessPro::Resources::Mandate do
|
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
-
it "can be initialized from an
|
49
|
+
it "can be initialized from an unenveloped response" do
|
50
50
|
resource = described_class.new(data)
|
51
51
|
|
52
52
|
|
@@ -87,6 +87,18 @@ describe GoCardlessPro::Resources::Mandate do
|
|
87
87
|
|
88
88
|
end
|
89
89
|
|
90
|
+
it "can handle new attributes without erroring" do
|
91
|
+
data["foo"] = "bar"
|
92
|
+
expect { described_class.new(data) }.to_not raise_error
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
it "can handle new link attributes without erroring" do
|
97
|
+
data["links"]["foo"] = "bar"
|
98
|
+
expect { described_class.new(data) }.to_not raise_error
|
99
|
+
end
|
100
|
+
|
101
|
+
|
90
102
|
describe "#to_h" do
|
91
103
|
it "returns a hash representing the resource" do
|
92
104
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -62,7 +62,7 @@ describe GoCardlessPro::Resources::Payment do
|
|
62
62
|
}
|
63
63
|
end
|
64
64
|
|
65
|
-
it "can be initialized from an
|
65
|
+
it "can be initialized from an unenveloped response" do
|
66
66
|
resource = described_class.new(data)
|
67
67
|
|
68
68
|
|
@@ -119,6 +119,18 @@ describe GoCardlessPro::Resources::Payment do
|
|
119
119
|
|
120
120
|
end
|
121
121
|
|
122
|
+
it "can handle new attributes without erroring" do
|
123
|
+
data["foo"] = "bar"
|
124
|
+
expect { described_class.new(data) }.to_not raise_error
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
it "can handle new link attributes without erroring" do
|
129
|
+
data["links"]["foo"] = "bar"
|
130
|
+
expect { described_class.new(data) }.to_not raise_error
|
131
|
+
end
|
132
|
+
|
133
|
+
|
122
134
|
describe "#to_h" do
|
123
135
|
it "returns a hash representing the resource" do
|
124
136
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -42,7 +42,7 @@ describe GoCardlessPro::Resources::Payout do
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
it "can be initialized from an
|
45
|
+
it "can be initialized from an unenveloped response" do
|
46
46
|
resource = described_class.new(data)
|
47
47
|
|
48
48
|
|
@@ -79,6 +79,18 @@ describe GoCardlessPro::Resources::Payout do
|
|
79
79
|
|
80
80
|
end
|
81
81
|
|
82
|
+
it "can handle new attributes without erroring" do
|
83
|
+
data["foo"] = "bar"
|
84
|
+
expect { described_class.new(data) }.to_not raise_error
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
it "can handle new link attributes without erroring" do
|
89
|
+
data["links"]["foo"] = "bar"
|
90
|
+
expect { described_class.new(data) }.to_not raise_error
|
91
|
+
end
|
92
|
+
|
93
|
+
|
82
94
|
describe "#to_h" do
|
83
95
|
it "returns a hash representing the resource" do
|
84
96
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -22,6 +22,10 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
22
22
|
|
23
23
|
"creditor" => "creditor-input",
|
24
24
|
|
25
|
+
"customer" => "customer-input",
|
26
|
+
|
27
|
+
"customer_bank_account" => "customer_bank_account-input",
|
28
|
+
|
25
29
|
"mandate" => "mandate-input",
|
26
30
|
|
27
31
|
},
|
@@ -46,7 +50,7 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
46
50
|
}
|
47
51
|
end
|
48
52
|
|
49
|
-
it "can be initialized from an
|
53
|
+
it "can be initialized from an unenveloped response" do
|
50
54
|
resource = described_class.new(data)
|
51
55
|
|
52
56
|
|
@@ -65,6 +69,10 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
65
69
|
|
66
70
|
expect(resource.links.creditor).to eq("creditor-input")
|
67
71
|
|
72
|
+
expect(resource.links.customer).to eq("customer-input")
|
73
|
+
|
74
|
+
expect(resource.links.customer_bank_account).to eq("customer_bank_account-input")
|
75
|
+
|
68
76
|
expect(resource.links.mandate).to eq("mandate-input")
|
69
77
|
|
70
78
|
|
@@ -87,6 +95,18 @@ describe GoCardlessPro::Resources::RedirectFlow do
|
|
87
95
|
|
88
96
|
end
|
89
97
|
|
98
|
+
it "can handle new attributes without erroring" do
|
99
|
+
data["foo"] = "bar"
|
100
|
+
expect { described_class.new(data) }.to_not raise_error
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
it "can handle new link attributes without erroring" do
|
105
|
+
data["links"]["foo"] = "bar"
|
106
|
+
expect { described_class.new(data) }.to_not raise_error
|
107
|
+
end
|
108
|
+
|
109
|
+
|
90
110
|
describe "#to_h" do
|
91
111
|
it "returns a hash representing the resource" do
|
92
112
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -36,7 +36,7 @@ describe GoCardlessPro::Resources::Refund do
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
-
it "can be initialized from an
|
39
|
+
it "can be initialized from an unenveloped response" do
|
40
40
|
resource = described_class.new(data)
|
41
41
|
|
42
42
|
|
@@ -67,6 +67,18 @@ describe GoCardlessPro::Resources::Refund do
|
|
67
67
|
|
68
68
|
end
|
69
69
|
|
70
|
+
it "can handle new attributes without erroring" do
|
71
|
+
data["foo"] = "bar"
|
72
|
+
expect { described_class.new(data) }.to_not raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
it "can handle new link attributes without erroring" do
|
77
|
+
data["links"]["foo"] = "bar"
|
78
|
+
expect { described_class.new(data) }.to_not raise_error
|
79
|
+
end
|
80
|
+
|
81
|
+
|
70
82
|
describe "#to_h" do
|
71
83
|
it "returns a hash representing the resource" do
|
72
84
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -80,7 +80,7 @@ describe GoCardlessPro::Resources::Subscription do
|
|
80
80
|
}
|
81
81
|
end
|
82
82
|
|
83
|
-
it "can be initialized from an
|
83
|
+
it "can be initialized from an unenveloped response" do
|
84
84
|
resource = described_class.new(data)
|
85
85
|
|
86
86
|
|
@@ -155,6 +155,18 @@ describe GoCardlessPro::Resources::Subscription do
|
|
155
155
|
|
156
156
|
end
|
157
157
|
|
158
|
+
it "can handle new attributes without erroring" do
|
159
|
+
data["foo"] = "bar"
|
160
|
+
expect { described_class.new(data) }.to_not raise_error
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
it "can handle new link attributes without erroring" do
|
165
|
+
data["links"]["foo"] = "bar"
|
166
|
+
expect { described_class.new(data) }.to_not raise_error
|
167
|
+
end
|
168
|
+
|
169
|
+
|
158
170
|
describe "#to_h" do
|
159
171
|
it "returns a hash representing the resource" do
|
160
172
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -9,6 +9,7 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
|
|
9
9
|
|
10
10
|
|
11
11
|
|
12
|
+
|
12
13
|
|
13
14
|
|
14
15
|
|
@@ -20,26 +21,29 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
|
|
20
21
|
|
21
22
|
"available_debit_schemes" => "available_debit_schemes-input",
|
22
23
|
"bank_name" => "bank_name-input",
|
24
|
+
"bic" => "bic-input",
|
23
25
|
}
|
24
26
|
end
|
25
27
|
|
26
28
|
before do
|
27
|
-
stub_request(:post,
|
29
|
+
stub_request(:post, %r(.*api.gocardless.com/bank_details_lookups)).
|
28
30
|
with(
|
29
31
|
body: {
|
30
|
-
bank_details_lookups
|
32
|
+
"bank_details_lookups" => {
|
31
33
|
|
32
34
|
"available_debit_schemes" => "available_debit_schemes-input",
|
33
35
|
"bank_name" => "bank_name-input",
|
36
|
+
"bic" => "bic-input",
|
34
37
|
}
|
35
38
|
}
|
36
39
|
).
|
37
40
|
to_return(
|
38
41
|
body: {
|
39
|
-
bank_details_lookups
|
42
|
+
"bank_details_lookups" => {
|
40
43
|
|
41
44
|
"available_debit_schemes" => "available_debit_schemes-input",
|
42
45
|
"bank_name" => "bank_name-input",
|
46
|
+
"bic" => "bic-input",
|
43
47
|
}
|
44
48
|
}.to_json,
|
45
49
|
:headers => {'Content-Type' => 'application/json'}
|
@@ -55,7 +59,7 @@ describe GoCardlessPro::Services::BankDetailsLookupsService do
|
|
55
59
|
let(:new_resource) { {} }
|
56
60
|
|
57
61
|
before do
|
58
|
-
stub_request(:post,
|
62
|
+
stub_request(:post, %r(.*api.gocardless.com/bank_details_lookups)).to_return(
|
59
63
|
body: {
|
60
64
|
error: {
|
61
65
|
type: 'validation_failed',
|
@@ -9,6 +9,7 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
9
9
|
|
10
10
|
|
11
11
|
|
12
|
+
|
12
13
|
|
13
14
|
|
14
15
|
|
@@ -32,10 +33,10 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
before do
|
35
|
-
stub_request(:post,
|
36
|
+
stub_request(:post, %r(.*api.gocardless.com/creditor_bank_accounts)).
|
36
37
|
with(
|
37
38
|
body: {
|
38
|
-
creditor_bank_accounts
|
39
|
+
"creditor_bank_accounts" => {
|
39
40
|
|
40
41
|
"account_holder_name" => "account_holder_name-input",
|
41
42
|
"account_number_ending" => "account_number_ending-input",
|
@@ -52,7 +53,7 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
52
53
|
).
|
53
54
|
to_return(
|
54
55
|
body: {
|
55
|
-
creditor_bank_accounts
|
56
|
+
"creditor_bank_accounts" => {
|
56
57
|
|
57
58
|
"account_holder_name" => "account_holder_name-input",
|
58
59
|
"account_number_ending" => "account_number_ending-input",
|
@@ -79,7 +80,7 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
79
80
|
let(:new_resource) { {} }
|
80
81
|
|
81
82
|
before do
|
82
|
-
stub_request(:post,
|
83
|
+
stub_request(:post, %r(.*api.gocardless.com/creditor_bank_accounts)).to_return(
|
83
84
|
body: {
|
84
85
|
error: {
|
85
86
|
type: 'validation_failed',
|
@@ -109,9 +110,9 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
109
110
|
subject(:get_list_response) { client.creditor_bank_accounts.list }
|
110
111
|
|
111
112
|
before do
|
112
|
-
stub_request(:get,
|
113
|
+
stub_request(:get, %r(.*api.gocardless.com/creditor_bank_accounts)).to_return(
|
113
114
|
body: {
|
114
|
-
creditor_bank_accounts
|
115
|
+
"creditor_bank_accounts" => [{
|
115
116
|
|
116
117
|
"account_holder_name" => "account_holder_name-input",
|
117
118
|
"account_number_ending" => "account_number_ending-input",
|
@@ -190,9 +191,9 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
190
191
|
|
191
192
|
describe "#all" do
|
192
193
|
let!(:first_response_stub) do
|
193
|
-
stub_request(:get,
|
194
|
+
stub_request(:get, %r(.*api.gocardless.com/creditor_bank_accounts$)).to_return(
|
194
195
|
body: {
|
195
|
-
creditor_bank_accounts
|
196
|
+
"creditor_bank_accounts" => [{
|
196
197
|
|
197
198
|
"account_holder_name" => "account_holder_name-input",
|
198
199
|
"account_number_ending" => "account_number_ending-input",
|
@@ -215,9 +216,9 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
215
216
|
end
|
216
217
|
|
217
218
|
let!(:second_response_stub) do
|
218
|
-
stub_request(:get,
|
219
|
+
stub_request(:get, %r(.*api.gocardless.com/creditor_bank_accounts\?after=AB345)).to_return(
|
219
220
|
body: {
|
220
|
-
creditor_bank_accounts
|
221
|
+
"creditor_bank_accounts" => [{
|
221
222
|
|
222
223
|
"account_holder_name" => "account_holder_name-input",
|
223
224
|
"account_number_ending" => "account_number_ending-input",
|
@@ -258,11 +259,12 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
258
259
|
|
259
260
|
context "passing in a custom header" do
|
260
261
|
let!(:stub) do
|
261
|
-
|
262
|
-
|
263
|
-
.
|
262
|
+
stub_url = "/creditor_bank_accounts/:identity".gsub(':identity', id)
|
263
|
+
stub_request(:get, %r(.*api.gocardless.com#{stub_url})).
|
264
|
+
with(headers: { 'Foo' => 'Bar' }).
|
265
|
+
to_return(
|
264
266
|
body: {
|
265
|
-
creditor_bank_accounts
|
267
|
+
"creditor_bank_accounts" => {
|
266
268
|
|
267
269
|
"account_holder_name" => "account_holder_name-input",
|
268
270
|
"account_number_ending" => "account_number_ending-input",
|
@@ -294,9 +296,10 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
294
296
|
|
295
297
|
context "when there is a creditor_bank_account to return" do
|
296
298
|
before do
|
297
|
-
|
299
|
+
stub_url = "/creditor_bank_accounts/:identity".gsub(':identity', id)
|
300
|
+
stub_request(:get, %r(.*api.gocardless.com#{stub_url})).to_return(
|
298
301
|
body: {
|
299
|
-
creditor_bank_accounts
|
302
|
+
"creditor_bank_accounts" => {
|
300
303
|
|
301
304
|
"account_holder_name" => "account_holder_name-input",
|
302
305
|
"account_number_ending" => "account_number_ending-input",
|
@@ -321,7 +324,8 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
321
324
|
|
322
325
|
context "when nothing is returned" do
|
323
326
|
before do
|
324
|
-
|
327
|
+
stub_url = "/creditor_bank_accounts/:identity".gsub(':identity', id)
|
328
|
+
stub_request(:get, %r(.*api.gocardless.com#{stub_url})).to_return(
|
325
329
|
body: "",
|
326
330
|
headers: { 'Content-Type' => 'application/json' }
|
327
331
|
)
|
@@ -348,9 +352,9 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
348
352
|
let!(:stub) do
|
349
353
|
# /creditor_bank_accounts/%v/actions/disable
|
350
354
|
stub_url = "/creditor_bank_accounts/:identity/actions/disable".gsub(':identity', resource_id)
|
351
|
-
stub_request(:post,
|
355
|
+
stub_request(:post, %r(.*api.gocardless.com#{stub_url})).to_return(
|
352
356
|
body: {
|
353
|
-
creditor_bank_accounts
|
357
|
+
"creditor_bank_accounts" => {
|
354
358
|
|
355
359
|
"account_holder_name" => "account_holder_name-input",
|
356
360
|
"account_number_ending" => "account_number_ending-input",
|
@@ -385,13 +389,13 @@ describe GoCardlessPro::Services::CreditorBankAccountsService do
|
|
385
389
|
let!(:stub) do
|
386
390
|
# /creditor_bank_accounts/%v/actions/disable
|
387
391
|
stub_url = "/creditor_bank_accounts/:identity/actions/disable".gsub(':identity', resource_id)
|
388
|
-
stub_request(:post,
|
392
|
+
stub_request(:post, %r(.*api.gocardless.com#{stub_url})).
|
389
393
|
with(
|
390
394
|
body: { foo: 'bar' },
|
391
395
|
headers: { 'Foo' => 'Bar' }
|
392
396
|
).to_return(
|
393
397
|
body: {
|
394
|
-
creditor_bank_accounts
|
398
|
+
"creditor_bank_accounts" => {
|
395
399
|
|
396
400
|
"account_holder_name" => "account_holder_name-input",
|
397
401
|
"account_number_ending" => "account_number_ending-input",
|