gocardless_pro 2.19.0 → 2.20.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/lib/gocardless_pro/client.rb +1 -1
- data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -0
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/resources/instalment_schedule_spec.rb +35 -0
- data/spec/services/instalment_schedules_service_spec.rb +60 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7afba51474a66685fa1e954707bdc6c339a4c3c10e5f64160f5676137804d455
|
4
|
+
data.tar.gz: 378a39b27909235511aafcfcb207d6c4ffffb6358c1747c9c5b4d7e1b1e76340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 545b24573eec2cc2f9bceef08add1d8199d2769ee2256f1901f84a2c0b178b5860200c1fdb093f6bed07e432493bbee92758146fba64010d1072a7e0c048eea7
|
7
|
+
data.tar.gz: 7571194e496636bdd23bf173d1e31712592edcf5f3cefc26ea513ac48e871fe21d1291d4e5a365e59a7be7cebf21e71e43c72fd75fe7da88d270b8f86b6bc0c2
|
@@ -148,7 +148,7 @@ module GoCardlessPro
|
|
148
148
|
'User-Agent' => user_agent.to_s,
|
149
149
|
'Content-Type' => 'application/json',
|
150
150
|
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
|
151
|
-
'GoCardless-Client-Version' => '2.
|
151
|
+
'GoCardless-Client-Version' => '2.20.0',
|
152
152
|
},
|
153
153
|
}
|
154
154
|
end
|
@@ -162,6 +162,27 @@ module GoCardlessPro
|
|
162
162
|
Resources::InstalmentSchedule.new(unenvelope_body(response.body), response)
|
163
163
|
end
|
164
164
|
|
165
|
+
# Updates an instalment schedule. This accepts only the metadata parameter.
|
166
|
+
# Example URL: /instalment_schedules/:identity
|
167
|
+
#
|
168
|
+
# @param identity # Unique identifier, beginning with "IS".
|
169
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
170
|
+
def update(identity, options = {})
|
171
|
+
path = sub_url('/instalment_schedules/:identity', 'identity' => identity)
|
172
|
+
|
173
|
+
params = options.delete(:params) || {}
|
174
|
+
options[:params] = {}
|
175
|
+
options[:params][envelope_key] = params
|
176
|
+
|
177
|
+
options[:retry_failures] = true
|
178
|
+
|
179
|
+
response = make_request(:put, path, options)
|
180
|
+
|
181
|
+
return if response.body.nil?
|
182
|
+
|
183
|
+
Resources::InstalmentSchedule.new(unenvelope_body(response.body), response)
|
184
|
+
end
|
185
|
+
|
165
186
|
# Immediately cancels an instalment schedule; no further payments will be
|
166
187
|
# collected for it.
|
167
188
|
#
|
@@ -529,6 +529,41 @@ describe GoCardlessPro::Resources::InstalmentSchedule do
|
|
529
529
|
end
|
530
530
|
end
|
531
531
|
|
532
|
+
describe '#update' do
|
533
|
+
subject(:put_update_response) { client.instalment_schedules.update(id, params: update_params) }
|
534
|
+
let(:id) { 'ABC123' }
|
535
|
+
|
536
|
+
context 'with a valid request' do
|
537
|
+
let(:update_params) { { 'hello' => 'world' } }
|
538
|
+
|
539
|
+
let!(:stub) do
|
540
|
+
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
|
541
|
+
stub_request(:put, /.*api.gocardless.com#{stub_url}/).to_return(
|
542
|
+
body: {
|
543
|
+
'instalment_schedules' => {
|
544
|
+
|
545
|
+
'created_at' => 'created_at-input',
|
546
|
+
'currency' => 'currency-input',
|
547
|
+
'id' => 'id-input',
|
548
|
+
'links' => 'links-input',
|
549
|
+
'metadata' => 'metadata-input',
|
550
|
+
'name' => 'name-input',
|
551
|
+
'payment_errors' => 'payment_errors-input',
|
552
|
+
'status' => 'status-input',
|
553
|
+
'total_amount' => 'total_amount-input',
|
554
|
+
},
|
555
|
+
}.to_json,
|
556
|
+
headers: response_headers
|
557
|
+
)
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'updates and returns the resource' do
|
561
|
+
expect(put_update_response).to be_a(GoCardlessPro::Resources::InstalmentSchedule)
|
562
|
+
expect(stub).to have_been_requested
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
532
567
|
describe '#cancel' do
|
533
568
|
subject(:post_response) { client.instalment_schedules.cancel(resource_id) }
|
534
569
|
|
@@ -828,6 +828,66 @@ describe GoCardlessPro::Services::InstalmentSchedulesService do
|
|
828
828
|
end
|
829
829
|
end
|
830
830
|
|
831
|
+
describe '#update' do
|
832
|
+
subject(:put_update_response) { client.instalment_schedules.update(id, params: update_params) }
|
833
|
+
let(:id) { 'ABC123' }
|
834
|
+
|
835
|
+
context 'with a valid request' do
|
836
|
+
let(:update_params) { { 'hello' => 'world' } }
|
837
|
+
|
838
|
+
let!(:stub) do
|
839
|
+
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
|
840
|
+
stub_request(:put, /.*api.gocardless.com#{stub_url}/).to_return(
|
841
|
+
body: {
|
842
|
+
'instalment_schedules' => {
|
843
|
+
|
844
|
+
'created_at' => 'created_at-input',
|
845
|
+
'currency' => 'currency-input',
|
846
|
+
'id' => 'id-input',
|
847
|
+
'links' => 'links-input',
|
848
|
+
'metadata' => 'metadata-input',
|
849
|
+
'name' => 'name-input',
|
850
|
+
'payment_errors' => 'payment_errors-input',
|
851
|
+
'status' => 'status-input',
|
852
|
+
'total_amount' => 'total_amount-input',
|
853
|
+
},
|
854
|
+
}.to_json,
|
855
|
+
headers: response_headers
|
856
|
+
)
|
857
|
+
end
|
858
|
+
|
859
|
+
it 'updates and returns the resource' do
|
860
|
+
expect(put_update_response).to be_a(GoCardlessPro::Resources::InstalmentSchedule)
|
861
|
+
expect(stub).to have_been_requested
|
862
|
+
end
|
863
|
+
|
864
|
+
describe 'retry behaviour' do
|
865
|
+
before { allow_any_instance_of(GoCardlessPro::Request).to receive(:sleep) }
|
866
|
+
|
867
|
+
it 'retries timeouts' do
|
868
|
+
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
|
869
|
+
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
|
870
|
+
to_timeout.then.to_return(status: 200, headers: response_headers)
|
871
|
+
|
872
|
+
put_update_response
|
873
|
+
expect(stub).to have_been_requested.twice
|
874
|
+
end
|
875
|
+
|
876
|
+
it 'retries 5XX errors' do
|
877
|
+
stub_url = '/instalment_schedules/:identity'.gsub(':identity', id)
|
878
|
+
stub = stub_request(:put, /.*api.gocardless.com#{stub_url}/).
|
879
|
+
to_return(status: 502,
|
880
|
+
headers: { 'Content-Type' => 'text/html' },
|
881
|
+
body: '<html><body>Response from Cloudflare</body></html>').
|
882
|
+
then.to_return(status: 200, headers: response_headers)
|
883
|
+
|
884
|
+
put_update_response
|
885
|
+
expect(stub).to have_been_requested.twice
|
886
|
+
end
|
887
|
+
end
|
888
|
+
end
|
889
|
+
end
|
890
|
+
|
831
891
|
describe '#cancel' do
|
832
892
|
subject(:post_response) { client.instalment_schedules.cancel(resource_id) }
|
833
893
|
|
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: 2.
|
4
|
+
version: 2.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|