gocardless-pro 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +132 -0
  6. data/circle.yml +18 -0
  7. data/demo.rb +10 -0
  8. data/gocardless-pro.gemspec +27 -0
  9. data/lib/gocardless-pro.rb +243 -0
  10. data/lib/gocardless-pro/api_service.rb +57 -0
  11. data/lib/gocardless-pro/error.rb +42 -0
  12. data/lib/gocardless-pro/error/gocardless_error.rb +5 -0
  13. data/lib/gocardless-pro/error/invalid_api_usage_error.rb +5 -0
  14. data/lib/gocardless-pro/error/invalid_state_error.rb +5 -0
  15. data/lib/gocardless-pro/error/validation_error.rb +5 -0
  16. data/lib/gocardless-pro/list_response.rb +34 -0
  17. data/lib/gocardless-pro/paginator.rb +37 -0
  18. data/lib/gocardless-pro/request.rb +69 -0
  19. data/lib/gocardless-pro/resources/api_key.rb +62 -0
  20. data/lib/gocardless-pro/resources/creditor.rb +83 -0
  21. data/lib/gocardless-pro/resources/creditor_bank_account.rb +78 -0
  22. data/lib/gocardless-pro/resources/customer.rb +72 -0
  23. data/lib/gocardless-pro/resources/customer_bank_account.rb +80 -0
  24. data/lib/gocardless-pro/resources/event.rb +75 -0
  25. data/lib/gocardless-pro/resources/helper.rb +29 -0
  26. data/lib/gocardless-pro/resources/mandate.rb +70 -0
  27. data/lib/gocardless-pro/resources/payment.rb +86 -0
  28. data/lib/gocardless-pro/resources/payout.rb +66 -0
  29. data/lib/gocardless-pro/resources/publishable_api_key.rb +51 -0
  30. data/lib/gocardless-pro/resources/redirect_flow.rb +104 -0
  31. data/lib/gocardless-pro/resources/refund.rb +70 -0
  32. data/lib/gocardless-pro/resources/role.rb +101 -0
  33. data/lib/gocardless-pro/resources/subscription.rb +152 -0
  34. data/lib/gocardless-pro/resources/user.rb +60 -0
  35. data/lib/gocardless-pro/response.rb +77 -0
  36. data/lib/gocardless-pro/services/api_key_service.rb +130 -0
  37. data/lib/gocardless-pro/services/base_service.rb +29 -0
  38. data/lib/gocardless-pro/services/creditor_bank_account_service.rb +122 -0
  39. data/lib/gocardless-pro/services/creditor_service.rb +112 -0
  40. data/lib/gocardless-pro/services/customer_bank_account_service.rb +153 -0
  41. data/lib/gocardless-pro/services/customer_service.rb +112 -0
  42. data/lib/gocardless-pro/services/event_service.rb +80 -0
  43. data/lib/gocardless-pro/services/helper_service.rb +97 -0
  44. data/lib/gocardless-pro/services/mandate_service.rb +170 -0
  45. data/lib/gocardless-pro/services/payment_service.rb +164 -0
  46. data/lib/gocardless-pro/services/payout_service.rb +80 -0
  47. data/lib/gocardless-pro/services/publishable_api_key_service.rb +130 -0
  48. data/lib/gocardless-pro/services/redirect_flow_service.rb +96 -0
  49. data/lib/gocardless-pro/services/refund_service.rb +126 -0
  50. data/lib/gocardless-pro/services/role_service.rb +127 -0
  51. data/lib/gocardless-pro/services/subscription_service.rb +133 -0
  52. data/lib/gocardless-pro/services/user_service.rb +148 -0
  53. data/lib/gocardless-pro/version.rb +8 -0
  54. data/spec/api_service_spec.rb +69 -0
  55. data/spec/client_spec.rb +29 -0
  56. data/spec/error_spec.rb +44 -0
  57. data/spec/resources/api_key_spec.rb +85 -0
  58. data/spec/resources/creditor_bank_account_spec.rb +109 -0
  59. data/spec/resources/creditor_spec.rb +125 -0
  60. data/spec/resources/customer_bank_account_spec.rb +109 -0
  61. data/spec/resources/customer_spec.rb +127 -0
  62. data/spec/resources/event_spec.rb +113 -0
  63. data/spec/resources/helper_spec.rb +23 -0
  64. data/spec/resources/mandate_spec.rb +97 -0
  65. data/spec/resources/payment_spec.rb +129 -0
  66. data/spec/resources/payout_spec.rb +89 -0
  67. data/spec/resources/publishable_api_key_spec.rb +63 -0
  68. data/spec/resources/redirect_flow_spec.rb +97 -0
  69. data/spec/resources/refund_spec.rb +77 -0
  70. data/spec/resources/role_spec.rb +63 -0
  71. data/spec/resources/subscription_spec.rb +157 -0
  72. data/spec/resources/user_spec.rb +85 -0
  73. data/spec/response_spec.rb +79 -0
  74. data/spec/services/api_key_service_spec.rb +362 -0
  75. data/spec/services/creditor_bank_account_service_spec.rb +365 -0
  76. data/spec/services/creditor_service_spec.rb +339 -0
  77. data/spec/services/customer_bank_account_service_spec.rb +404 -0
  78. data/spec/services/customer_service_spec.rb +365 -0
  79. data/spec/services/event_service_spec.rb +172 -0
  80. data/spec/services/helper_service_spec.rb +123 -0
  81. data/spec/services/mandate_service_spec.rb +449 -0
  82. data/spec/services/payment_service_spec.rb +497 -0
  83. data/spec/services/payout_service_spec.rb +172 -0
  84. data/spec/services/publishable_api_key_service_spec.rb +336 -0
  85. data/spec/services/redirect_flow_service_spec.rb +208 -0
  86. data/spec/services/refund_service_spec.rb +279 -0
  87. data/spec/services/role_service_spec.rb +336 -0
  88. data/spec/services/subscription_service_spec.rb +488 -0
  89. data/spec/services/user_service_spec.rb +433 -0
  90. data/spec/spec_helper.rb +91 -0
  91. metadata +255 -0
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoCardless::Resources::Role do
4
+ describe "initialising" do
5
+ let(:data) do
6
+ {
7
+
8
+
9
+ "created_at" => "created_at-input",
10
+
11
+
12
+
13
+ "enabled" => "enabled-input",
14
+
15
+
16
+
17
+ "id" => "id-input",
18
+
19
+
20
+
21
+ "name" => "name-input",
22
+
23
+
24
+
25
+ "permissions" => "permissions-input",
26
+
27
+
28
+ }
29
+ end
30
+
31
+ it "can be initialized from an uneveloped response" do
32
+ resource = described_class.new(data)
33
+
34
+
35
+ expect(resource.created_at).to eq("created_at-input")
36
+
37
+
38
+
39
+ expect(resource.enabled).to eq("enabled-input")
40
+
41
+
42
+
43
+ expect(resource.id).to eq("id-input")
44
+
45
+
46
+
47
+ expect(resource.name).to eq("name-input")
48
+
49
+
50
+
51
+ expect(resource.permissions).to eq("permissions-input")
52
+
53
+
54
+ end
55
+
56
+ describe "#to_h" do
57
+ it "returns a hash representing the resource" do
58
+ expect(described_class.new(data).to_h).to eq(data)
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoCardless::Resources::Subscription do
4
+ describe "initialising" do
5
+ let(:data) do
6
+ {
7
+
8
+
9
+ "amount" => "amount-input",
10
+
11
+
12
+
13
+ "count" => "count-input",
14
+
15
+
16
+
17
+ "created_at" => "created_at-input",
18
+
19
+
20
+
21
+ "currency" => "currency-input",
22
+
23
+
24
+
25
+ "day_of_month" => "day_of_month-input",
26
+
27
+
28
+
29
+ "end_at" => "end_at-input",
30
+
31
+
32
+
33
+ "id" => "id-input",
34
+
35
+
36
+
37
+ "interval" => "interval-input",
38
+
39
+
40
+
41
+ "interval_unit" => "interval_unit-input",
42
+
43
+
44
+
45
+ "links" => {
46
+
47
+ "mandate" => "mandate-input",
48
+
49
+ },
50
+
51
+
52
+
53
+ "metadata" => "metadata-input",
54
+
55
+
56
+
57
+ "month" => "month-input",
58
+
59
+
60
+
61
+ "name" => "name-input",
62
+
63
+
64
+
65
+ "start_at" => "start_at-input",
66
+
67
+
68
+
69
+ "status" => "status-input",
70
+
71
+
72
+
73
+ "upcoming_payments" => "upcoming_payments-input",
74
+
75
+
76
+ }
77
+ end
78
+
79
+ it "can be initialized from an uneveloped response" do
80
+ resource = described_class.new(data)
81
+
82
+
83
+ expect(resource.amount).to eq("amount-input")
84
+
85
+
86
+
87
+ expect(resource.count).to eq("count-input")
88
+
89
+
90
+
91
+ expect(resource.created_at).to eq("created_at-input")
92
+
93
+
94
+
95
+ expect(resource.currency).to eq("currency-input")
96
+
97
+
98
+
99
+ expect(resource.day_of_month).to eq("day_of_month-input")
100
+
101
+
102
+
103
+ expect(resource.end_at).to eq("end_at-input")
104
+
105
+
106
+
107
+ expect(resource.id).to eq("id-input")
108
+
109
+
110
+
111
+ expect(resource.interval).to eq("interval-input")
112
+
113
+
114
+
115
+ expect(resource.interval_unit).to eq("interval_unit-input")
116
+
117
+
118
+
119
+
120
+ expect(resource.links.mandate).to eq("mandate-input")
121
+
122
+
123
+
124
+
125
+ expect(resource.metadata).to eq("metadata-input")
126
+
127
+
128
+
129
+ expect(resource.month).to eq("month-input")
130
+
131
+
132
+
133
+ expect(resource.name).to eq("name-input")
134
+
135
+
136
+
137
+ expect(resource.start_at).to eq("start_at-input")
138
+
139
+
140
+
141
+ expect(resource.status).to eq("status-input")
142
+
143
+
144
+
145
+ expect(resource.upcoming_payments).to eq("upcoming_payments-input")
146
+
147
+
148
+ end
149
+
150
+ describe "#to_h" do
151
+ it "returns a hash representing the resource" do
152
+ expect(described_class.new(data).to_h).to eq(data)
153
+ end
154
+ end
155
+ end
156
+ end
157
+
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoCardless::Resources::User do
4
+ describe "initialising" do
5
+ let(:data) do
6
+ {
7
+
8
+
9
+ "created_at" => "created_at-input",
10
+
11
+
12
+
13
+ "email" => "email-input",
14
+
15
+
16
+
17
+ "enabled" => "enabled-input",
18
+
19
+
20
+
21
+ "family_name" => "family_name-input",
22
+
23
+
24
+
25
+ "given_name" => "given_name-input",
26
+
27
+
28
+
29
+ "id" => "id-input",
30
+
31
+
32
+
33
+ "links" => {
34
+
35
+ "role" => "role-input",
36
+
37
+ },
38
+
39
+
40
+ }
41
+ end
42
+
43
+ it "can be initialized from an uneveloped response" do
44
+ resource = described_class.new(data)
45
+
46
+
47
+ expect(resource.created_at).to eq("created_at-input")
48
+
49
+
50
+
51
+ expect(resource.email).to eq("email-input")
52
+
53
+
54
+
55
+ expect(resource.enabled).to eq("enabled-input")
56
+
57
+
58
+
59
+ expect(resource.family_name).to eq("family_name-input")
60
+
61
+
62
+
63
+ expect(resource.given_name).to eq("given_name-input")
64
+
65
+
66
+
67
+ expect(resource.id).to eq("id-input")
68
+
69
+
70
+
71
+
72
+ expect(resource.links.role).to eq("role-input")
73
+
74
+
75
+
76
+ end
77
+
78
+ describe "#to_h" do
79
+ it "returns a hash representing the resource" do
80
+ expect(described_class.new(data).to_h).to eq(data)
81
+ end
82
+ end
83
+ end
84
+ end
85
+
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoCardless::Response do
4
+
5
+ subject(:response) { described_class.new(raw_response) }
6
+ let(:default_headers) do
7
+ { 'Content-Type' => 'application/json' }
8
+ end
9
+
10
+ context "when the response is not an error" do
11
+ let(:raw_response) do
12
+ double("response",
13
+ headers: default_headers,
14
+ status: 200,
15
+ body: { customers: [] }.to_json
16
+ )
17
+ end
18
+
19
+ it "returns the body parsed into a hash" do
20
+ expect(response.body).to eq("customers" => [])
21
+ end
22
+ end
23
+
24
+ context "when the resonse is a validation error" do
25
+ let(:raw_response) do
26
+ double("response",
27
+ headers: default_headers,
28
+ status: 400,
29
+ body: { error: { type: 'validation_failed' } }.to_json
30
+ )
31
+ end
32
+
33
+ it "raises a ValidationError" do
34
+ expect { response.body }.to raise_error(GoCardless::ValidationError)
35
+ end
36
+ end
37
+
38
+ context "when the resonse is a gocardless error" do
39
+ let(:raw_response) do
40
+ double("response",
41
+ headers: default_headers,
42
+ status: 400,
43
+ body: { error: { type: 'gocardless' } }.to_json
44
+ )
45
+ end
46
+
47
+ it "raises a ValidationError" do
48
+ expect { response.body }.to raise_error(GoCardless::GoCardlessError)
49
+ end
50
+ end
51
+
52
+ context "when the resonse is an invalid api usage error" do
53
+ let(:raw_response) do
54
+ double("response",
55
+ headers: default_headers,
56
+ status: 400,
57
+ body: { error: { type: 'invalid_api_usage' } }.to_json
58
+ )
59
+ end
60
+
61
+ it "raises a ValidationError" do
62
+ expect { response.body }.to raise_error(GoCardless::InvalidApiUsageError)
63
+ end
64
+ end
65
+
66
+ context "when the resonse is an invalid invalid state error" do
67
+ let(:raw_response) do
68
+ double("response",
69
+ headers: default_headers,
70
+ status: 400,
71
+ body: { error: { type: 'invalid_state' } }.to_json
72
+ )
73
+ end
74
+
75
+ it "raises a ValidationError" do
76
+ expect { response.body }.to raise_error(GoCardless::InvalidStateError)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,362 @@
1
+ require 'spec_helper'
2
+
3
+ describe GoCardless::Services::ApiKeyService do
4
+ let(:client) do
5
+ GoCardless::Client.new(
6
+ api_key: "AK123",
7
+ api_secret: "ABC"
8
+ )
9
+ end
10
+
11
+
12
+
13
+
14
+
15
+
16
+ describe "#create" do
17
+ subject(:post_create_response) { client.api_keys.create(new_resource) }
18
+ context "with a valid request" do
19
+ let(:new_resource) do
20
+ {
21
+
22
+ "created_at" => "created_at-input",
23
+ "enabled" => "enabled-input",
24
+ "id" => "id-input",
25
+ "key" => "key-input",
26
+ "links" => "links-input",
27
+ "name" => "name-input",
28
+ "webhook_url" => "webhook_url-input",
29
+ }
30
+ end
31
+
32
+ before do
33
+ stub_request(:post, /.*api.gocardless.com\/api_keys/).
34
+ with(
35
+ body: {
36
+ api_keys: {
37
+
38
+ "created_at" => "created_at-input",
39
+ "enabled" => "enabled-input",
40
+ "id" => "id-input",
41
+ "key" => "key-input",
42
+ "links" => "links-input",
43
+ "name" => "name-input",
44
+ "webhook_url" => "webhook_url-input",
45
+ }
46
+ }
47
+ ).
48
+ to_return(
49
+ body: {
50
+ api_keys: {
51
+
52
+ "created_at" => "created_at-input",
53
+ "enabled" => "enabled-input",
54
+ "id" => "id-input",
55
+ "key" => "key-input",
56
+ "links" => "links-input",
57
+ "name" => "name-input",
58
+ "webhook_url" => "webhook_url-input",
59
+ }
60
+ }.to_json,
61
+ :headers => {'Content-Type' => 'application/json'}
62
+ )
63
+ end
64
+
65
+ it "creates and returns the resource" do
66
+ expect(post_create_response).to be_a(GoCardless::Resources::ApiKey)
67
+ end
68
+ end
69
+
70
+ context "with a request that returns a validation error" do
71
+ let(:new_resource) { {} }
72
+
73
+ before do
74
+ stub_request(:post, /.*api.gocardless.com\/api_keys/).to_return(
75
+ body: {
76
+ error: {
77
+ type: 'validation_failed',
78
+ code: 422,
79
+ errors: [
80
+ { message: 'test error message', field: 'test_field' }
81
+ ]
82
+ }
83
+ }.to_json,
84
+ headers: {'Content-Type' => 'application/json'},
85
+ status: 422
86
+ )
87
+ end
88
+
89
+ it "throws the correct error" do
90
+ expect { post_create_response }.to raise_error(GoCardless::ValidationError)
91
+ end
92
+ end
93
+ end
94
+
95
+
96
+
97
+
98
+
99
+ describe "#list" do
100
+ describe "with no filters" do
101
+ subject(:get_list_response) { client.api_keys.list }
102
+
103
+ before do
104
+ stub_request(:get, /.*api.gocardless.com\/api_keys/).to_return(
105
+ body: {
106
+ api_keys: [{
107
+
108
+ "created_at" => "created_at-input",
109
+ "enabled" => "enabled-input",
110
+ "id" => "id-input",
111
+ "key" => "key-input",
112
+ "links" => "links-input",
113
+ "name" => "name-input",
114
+ "webhook_url" => "webhook_url-input",
115
+ }],
116
+ meta: {
117
+ cursors: {
118
+ before: nil,
119
+ after: "ABC123"
120
+ }
121
+ }
122
+ }.to_json,
123
+ :headers => {'Content-Type' => 'application/json'}
124
+ )
125
+ end
126
+
127
+ it "wraps each item in the resource class" do
128
+ expect(get_list_response.map { |x| x.class }.uniq.first).to eq(GoCardless::Resources::ApiKey)
129
+
130
+
131
+
132
+ expect(get_list_response.first.created_at).to eq("created_at-input")
133
+
134
+
135
+
136
+ expect(get_list_response.first.enabled).to eq("enabled-input")
137
+
138
+
139
+
140
+ expect(get_list_response.first.id).to eq("id-input")
141
+
142
+
143
+
144
+ expect(get_list_response.first.key).to eq("key-input")
145
+
146
+
147
+
148
+
149
+
150
+ expect(get_list_response.first.name).to eq("name-input")
151
+
152
+
153
+
154
+ expect(get_list_response.first.webhook_url).to eq("webhook_url-input")
155
+
156
+
157
+ end
158
+
159
+ it "exposes the cursors for before and after" do
160
+ expect(get_list_response.before).to eq(nil)
161
+ expect(get_list_response.after).to eq("ABC123")
162
+ end
163
+ end
164
+ end
165
+
166
+ describe "#all" do
167
+ let!(:first_response_stub) do
168
+ stub_request(:get, /.*api.gocardless.com\/api_keys$/).to_return(
169
+ body: {
170
+ api_keys: [{
171
+
172
+ "created_at" => "created_at-input",
173
+ "enabled" => "enabled-input",
174
+ "id" => "id-input",
175
+ "key" => "key-input",
176
+ "links" => "links-input",
177
+ "name" => "name-input",
178
+ "webhook_url" => "webhook_url-input",
179
+ }],
180
+ meta: {
181
+ cursors: { after: 'AB345' },
182
+ limit: 1
183
+ }
184
+ }.to_json,
185
+ :headers => {'Content-Type' => 'application/json'}
186
+ )
187
+ end
188
+
189
+ let!(:second_response_stub) do
190
+ stub_request(:get, /.*api.gocardless.com\/api_keys\?after=AB345/).to_return(
191
+ body: {
192
+ api_keys: [{
193
+
194
+ "created_at" => "created_at-input",
195
+ "enabled" => "enabled-input",
196
+ "id" => "id-input",
197
+ "key" => "key-input",
198
+ "links" => "links-input",
199
+ "name" => "name-input",
200
+ "webhook_url" => "webhook_url-input",
201
+ }],
202
+ meta: {
203
+ limit: 2,
204
+ cursors: {}
205
+ }
206
+ }.to_json,
207
+ :headers => {'Content-Type' => 'application/json'}
208
+ )
209
+ end
210
+
211
+ it "automatically makes the extra requests" do
212
+ expect(client.api_keys.all.to_a.length).to eq(2)
213
+ expect(first_response_stub).to have_been_requested
214
+ expect(second_response_stub).to have_been_requested
215
+ end
216
+ end
217
+
218
+
219
+
220
+
221
+
222
+
223
+ describe "#get" do
224
+ let(:id) { "ID123" }
225
+
226
+ subject(:get_response) { client.api_keys.get(id) }
227
+
228
+ context "when there is a api_key to return" do
229
+ before do
230
+ stub_request(:get, /.*api.gocardless.com\/api_keys\/ID123/).to_return(
231
+ body: {
232
+ api_keys: {
233
+
234
+ "created_at" => "created_at-input",
235
+ "enabled" => "enabled-input",
236
+ "id" => "id-input",
237
+ "key" => "key-input",
238
+ "links" => "links-input",
239
+ "name" => "name-input",
240
+ "webhook_url" => "webhook_url-input",
241
+ }
242
+ }.to_json,
243
+ :headers => {'Content-Type' => 'application/json'}
244
+ )
245
+ end
246
+
247
+ it "wraps the response in a resource" do
248
+ expect(get_response).to be_a(GoCardless::Resources::ApiKey)
249
+ end
250
+ end
251
+ end
252
+
253
+
254
+
255
+
256
+
257
+
258
+ describe "#update" do
259
+ subject(:put_update_response) { client.api_keys.update(id, update_params) }
260
+ let(:id) { "ABC123" }
261
+
262
+ context "with a valid request" do
263
+ let(:update_params) { { "hello" => "world" } }
264
+
265
+ let!(:stub) do
266
+ stub_request(:put, /.*api.gocardless.com\/api_keys\/ABC123/).to_return(
267
+ body: {
268
+ api_keys: {
269
+
270
+ "created_at" => "created_at-input",
271
+ "enabled" => "enabled-input",
272
+ "id" => "id-input",
273
+ "key" => "key-input",
274
+ "links" => "links-input",
275
+ "name" => "name-input",
276
+ "webhook_url" => "webhook_url-input",
277
+ }
278
+ }.to_json,
279
+ :headers => {'Content-Type' => 'application/json'}
280
+ )
281
+ end
282
+
283
+ it "updates and returns the resource" do
284
+ expect(put_update_response).to be_a(GoCardless::Resources::ApiKey)
285
+ expect(stub).to have_been_requested
286
+ end
287
+ end
288
+ end
289
+
290
+
291
+
292
+
293
+
294
+ describe "#disable" do
295
+
296
+
297
+ subject(:post_response) { client.api_keys.disable(resource_id) }
298
+
299
+ let(:resource_id) { "ABC123" }
300
+
301
+ let!(:stub) do
302
+ # /api_keys/%v/actions/disable
303
+ stub_url = "/api_keys/:identity/actions/disable".gsub(':identity', resource_id)
304
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).to_return(
305
+ body: {
306
+ api_keys: {
307
+
308
+ "created_at" => "created_at-input",
309
+ "enabled" => "enabled-input",
310
+ "id" => "id-input",
311
+ "key" => "key-input",
312
+ "links" => "links-input",
313
+ "name" => "name-input",
314
+ "webhook_url" => "webhook_url-input",
315
+ }
316
+ }.to_json,
317
+ headers: {'Content-Type' => 'application/json'},
318
+ )
319
+ end
320
+
321
+ it "wraps the response and calls the right endpoint" do
322
+ expect(post_response).to be_a(GoCardless::Resources::ApiKey)
323
+
324
+ expect(stub).to have_been_requested
325
+ end
326
+
327
+ context "when the request needs a body and custom header" do
328
+
329
+ let(:body) { { foo: 'bar' } }
330
+ let(:headers) { { 'Foo' => 'Bar' } }
331
+ subject(:post_response) { client.api_keys.disable(resource_id, body, headers) }
332
+
333
+ let(:resource_id) { "ABC123" }
334
+
335
+ let!(:stub) do
336
+ # /api_keys/%v/actions/disable
337
+ stub_url = "/api_keys/:identity/actions/disable".gsub(':identity', resource_id)
338
+ stub_request(:post, /.*api.gocardless.com#{stub_url}/).
339
+ with(
340
+ body: { foo: 'bar' },
341
+ headers: { 'Foo' => 'Bar' }
342
+ ).to_return(
343
+ body: {
344
+ api_keys: {
345
+
346
+ "created_at" => "created_at-input",
347
+ "enabled" => "enabled-input",
348
+ "id" => "id-input",
349
+ "key" => "key-input",
350
+ "links" => "links-input",
351
+ "name" => "name-input",
352
+ "webhook_url" => "webhook_url-input",
353
+ }
354
+ }.to_json,
355
+ headers: {'Content-Type' => 'application/json'},
356
+ )
357
+ end
358
+ end
359
+ end
360
+
361
+
362
+ end