gocardless_pro 2.18.1 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +25 -43
  3. data/Gemfile +7 -0
  4. data/gocardless_pro.gemspec +2 -2
  5. data/lib/gocardless_pro/api_service.rb +1 -1
  6. data/lib/gocardless_pro/client.rb +1 -1
  7. data/lib/gocardless_pro/resources/payout.rb +2 -0
  8. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +0 -10
  9. data/lib/gocardless_pro/services/base_service.rb +11 -0
  10. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +0 -10
  11. data/lib/gocardless_pro/services/creditors_service.rb +0 -10
  12. data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +0 -10
  13. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +0 -10
  14. data/lib/gocardless_pro/services/customer_notifications_service.rb +0 -10
  15. data/lib/gocardless_pro/services/customers_service.rb +0 -10
  16. data/lib/gocardless_pro/services/events_service.rb +0 -10
  17. data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -10
  18. data/lib/gocardless_pro/services/mandate_import_entries_service.rb +0 -10
  19. data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -10
  20. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +0 -10
  21. data/lib/gocardless_pro/services/mandates_service.rb +0 -10
  22. data/lib/gocardless_pro/services/payments_service.rb +0 -10
  23. data/lib/gocardless_pro/services/payout_items_service.rb +0 -10
  24. data/lib/gocardless_pro/services/payouts_service.rb +21 -10
  25. data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -10
  26. data/lib/gocardless_pro/services/refunds_service.rb +6 -11
  27. data/lib/gocardless_pro/services/subscriptions_service.rb +21 -16
  28. data/lib/gocardless_pro/version.rb +1 -1
  29. data/spec/resources/instalment_schedule_spec.rb +35 -0
  30. data/spec/resources/payout_spec.rb +45 -0
  31. data/spec/services/creditor_bank_accounts_service_spec.rb +1 -1
  32. data/spec/services/customer_bank_accounts_service_spec.rb +1 -1
  33. data/spec/services/customer_notifications_service_spec.rb +1 -1
  34. data/spec/services/customers_service_spec.rb +1 -1
  35. data/spec/services/instalment_schedules_service_spec.rb +61 -1
  36. data/spec/services/mandate_imports_service_spec.rb +2 -2
  37. data/spec/services/mandates_service_spec.rb +2 -2
  38. data/spec/services/payments_service_spec.rb +2 -2
  39. data/spec/services/payouts_service_spec.rb +74 -0
  40. data/spec/services/redirect_flows_service_spec.rb +1 -1
  41. data/spec/services/subscriptions_service_spec.rb +3 -3
  42. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56e422f17e5916ab4eac449f5d12f138bac13589a481b1da75ca70e2da1ceae6
4
- data.tar.gz: 9df2ae977e5988ab8660062884644b8fdd14051d1866d940a3bd61957cd3436f
3
+ metadata.gz: 2380802da7e32b788d03eb0ce5965cb79b27f310c7643bf40078880823dcb2f7
4
+ data.tar.gz: ad1ebf6cbec94675df50e0b4a0154fb2eea77f659993625c5d8a9bcb8bd9f7df
5
5
  SHA512:
6
- metadata.gz: 99e3c28948e6b35328daf3744b44ea934644ed64666f2e2887c44057e03b6fb4e66475c97b53a2ace80f41558864142dcbaee49f07f44217a8224360bd47b13f
7
- data.tar.gz: 1451294c75349cb5342388b69d2676ab61785fe6d4bf5b8b8df88c91295e30e67c209c0c24e9e997e2fb4ef808b97fa3b576f92c4509b2b8132929320cb2f9ac
6
+ metadata.gz: 54622b040fa474ef16f0431e439bef3603d45cdf74c6001bc175fc638057db41231eae81cd9c502e5d16f3a796d6c1e068d27907aeacc1b0bfceb15186bcce0b
7
+ data.tar.gz: e89435ce6a6da8761c8b113e93f34fe1c7268e462aeda83fe8183620334c35f939c362efc1027b7bf0e3bef1a0ab9d56bb1eacf09e3ab64fd6596f1cc0055ad1
@@ -1,50 +1,32 @@
1
- version: 2
2
- references:
3
- test_library: &test_library
1
+ version: 2.1
2
+
3
+ jobs:
4
+ test: &test
4
5
  parallelism: 1
6
+ parameters:
7
+ faraday-version: { type: string }
8
+ ruby-version: { type: string }
9
+ docker:
10
+ - image: ruby:<<parameters.ruby-version>>
11
+ environment:
12
+ - FARADAY_VERSION=<<parameters.faraday-version>>
5
13
  steps:
6
14
  - checkout
7
- - run: |
8
- bundle install
9
- bundle exec rspec
10
- jobs:
11
- test_ruby_2_5:
12
- <<: *test_library
13
- docker:
14
- - image: ruby:2.5
15
-
16
- test_ruby_2_4:
17
- <<: *test_library
18
- docker:
19
- - image: ruby:2.4
20
-
21
- test_ruby_2_3:
22
- <<: *test_library
23
- docker:
24
- - image: ruby:2.3
25
-
26
- test_ruby_2_2:
27
- <<: *test_library
28
- docker:
29
- - image: ruby:2.2
30
-
31
- test_ruby_2_1:
32
- <<: *test_library
33
- docker:
34
- - image: ruby:2.1
35
-
36
- test_ruby_2_0:
37
- <<: *test_library
38
- docker:
39
- - image: ruby:2.0
15
+ - run: bundle install && bundle exec rspec
40
16
 
41
17
  workflows:
42
18
  version: 2
43
- build:
19
+ tests:
44
20
  jobs:
45
- - test_ruby_2_5
46
- - test_ruby_2_4
47
- - test_ruby_2_3
48
- - test_ruby_2_2
49
- - test_ruby_2_1
50
- - test_ruby_2_0
21
+ - test:
22
+ matrix:
23
+ parameters:
24
+ faraday-version: ["0.9.2", "1.0"]
25
+ ruby-version: ["2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]
26
+ exclude:
27
+ - faraday-version: "1.0"
28
+ ruby-version: "2.0"
29
+ - faraday-version: "1.0"
30
+ ruby-version: "2.1"
31
+ - faraday-version: "1.0"
32
+ ruby-version: "2.2"
data/Gemfile CHANGED
@@ -1,2 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
+
4
+ # We support both pre-1.x and post-1.x Faraday versions, but to ensure compatibility we
5
+ # pin this gem against each in separate runs of CI, using the FARADAY_VERSION env var. For
6
+ # more details on the values, see .circleci/config.yml.
7
+ if ENV.key?("FARADAY_VERSION")
8
+ gem 'faraday', "~> #{ENV["FARADAY_VERSION"]}"
9
+ end
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'faraday', ['>= 0.9.2', '< 1.0']
20
+ spec.add_dependency 'faraday', ['>= 0.9.2', '< 2']
21
21
 
22
22
  spec.add_development_dependency 'rspec', '~> 3.7.0'
23
- spec.add_development_dependency 'webmock', '~> 1.18'
23
+ spec.add_development_dependency 'webmock', '~> 3.8.3'
24
24
  spec.add_development_dependency 'rubocop', '~> 0.49.1'
25
25
  spec.add_development_dependency 'yard', '~> 0.9.11'
26
26
 
@@ -23,7 +23,7 @@ module GoCardlessPro
23
23
  @url = url
24
24
  root_url, @path_prefix = unpack_url(url)
25
25
  http_adapter = options[:http_adapter] || [:net_http]
26
- connection_options = options[:connection_options]
26
+ connection_options = options.fetch(:connection_options, {})
27
27
 
28
28
  @connection = Faraday.new(root_url, connection_options) do |faraday|
29
29
  faraday.response :raise_gocardless_errors
@@ -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.18.1',
151
+ 'GoCardless-Client-Version' => '2.22.1',
152
152
  },
153
153
  }
154
154
  end
@@ -26,6 +26,7 @@ module GoCardlessPro
26
26
  attr_reader :deducted_fees
27
27
  attr_reader :fx
28
28
  attr_reader :id
29
+ attr_reader :metadata
29
30
  attr_reader :payout_type
30
31
  attr_reader :reference
31
32
  attr_reader :status
@@ -43,6 +44,7 @@ module GoCardlessPro
43
44
  @fx = object['fx']
44
45
  @id = object['id']
45
46
  @links = object['links']
47
+ @metadata = object['metadata']
46
48
  @payout_type = object['payout_type']
47
49
  @reference = object['reference']
48
50
  @status = object['status']
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -59,15 +58,6 @@ module GoCardlessPro
59
58
  def envelope_key
60
59
  'bank_details_lookups'
61
60
  end
62
-
63
- # take a URL with placeholder params and substitute them out for the actual value
64
- # @param url [String] the URL with placeholders in
65
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
66
- def sub_url(url, param_map)
67
- param_map.reduce(url) do |new_url, (param, value)|
68
- new_url.gsub(":#{param}", URI.escape(value))
69
- end
70
- end
71
61
  end
72
62
  end
73
63
  end
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  module GoCardlessPro
2
4
  # Module that contains all services for making requests to the API.
3
5
  module Services
@@ -23,6 +25,15 @@ module GoCardlessPro
23
25
  def envelope_key
24
26
  raise NotImplementedError
25
27
  end
28
+
29
+ # take a URL with placeholder params and substitute them out for the actual value
30
+ # @param url [String] the URL with placeholders in
31
+ # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
32
+ def sub_url(url, param_map)
33
+ param_map.reduce(url) do |new_url, (param, value)|
34
+ new_url.gsub(":#{param}", CGI.escape(value))
35
+ end
36
+ end
26
37
  end
27
38
  end
28
39
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -153,15 +152,6 @@ module GoCardlessPro
153
152
  def envelope_key
154
153
  'creditor_bank_accounts'
155
154
  end
156
-
157
- # take a URL with placeholder params and substitute them out for the actual value
158
- # @param url [String] the URL with placeholders in
159
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
160
- def sub_url(url, param_map)
161
- param_map.reduce(url) do |new_url, (param, value)|
162
- new_url.gsub(":#{param}", URI.escape(value))
163
- end
164
- end
165
155
  end
166
156
  end
167
157
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -129,15 +128,6 @@ module GoCardlessPro
129
128
  def envelope_key
130
129
  'creditors'
131
130
  end
132
-
133
- # take a URL with placeholder params and substitute them out for the actual value
134
- # @param url [String] the URL with placeholders in
135
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
136
- def sub_url(url, param_map)
137
- param_map.reduce(url) do |new_url, (param, value)|
138
- new_url.gsub(":#{param}", URI.escape(value))
139
- end
140
- end
141
131
  end
142
132
  end
143
133
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -53,15 +52,6 @@ module GoCardlessPro
53
52
  def envelope_key
54
53
  'currency_exchange_rates'
55
54
  end
56
-
57
- # take a URL with placeholder params and substitute them out for the actual value
58
- # @param url [String] the URL with placeholders in
59
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
60
- def sub_url(url, param_map)
61
- param_map.reduce(url) do |new_url, (param, value)|
62
- new_url.gsub(":#{param}", URI.escape(value))
63
- end
64
- end
65
55
  end
66
56
  end
67
57
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -186,15 +185,6 @@ module GoCardlessPro
186
185
  def envelope_key
187
186
  'customer_bank_accounts'
188
187
  end
189
-
190
- # take a URL with placeholder params and substitute them out for the actual value
191
- # @param url [String] the URL with placeholders in
192
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
193
- def sub_url(url, param_map)
194
- param_map.reduce(url) do |new_url, (param, value)|
195
- new_url.gsub(":#{param}", URI.escape(value))
196
- end
197
- end
198
188
  end
199
189
  end
200
190
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -52,15 +51,6 @@ module GoCardlessPro
52
51
  def envelope_key
53
52
  'customer_notifications'
54
53
  end
55
-
56
- # take a URL with placeholder params and substitute them out for the actual value
57
- # @param url [String] the URL with placeholders in
58
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
59
- def sub_url(url, param_map)
60
- param_map.reduce(url) do |new_url, (param, value)|
61
- new_url.gsub(":#{param}", URI.escape(value))
62
- end
63
- end
64
54
  end
65
55
  end
66
56
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -153,15 +152,6 @@ module GoCardlessPro
153
152
  def envelope_key
154
153
  'customers'
155
154
  end
156
-
157
- # take a URL with placeholder params and substitute them out for the actual value
158
- # @param url [String] the URL with placeholders in
159
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
160
- def sub_url(url, param_map)
161
- param_map.reduce(url) do |new_url, (param, value)|
162
- new_url.gsub(":#{param}", URI.escape(value))
163
- end
164
- end
165
155
  end
166
156
  end
167
157
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -70,15 +69,6 @@ module GoCardlessPro
70
69
  def envelope_key
71
70
  'events'
72
71
  end
73
-
74
- # take a URL with placeholder params and substitute them out for the actual value
75
- # @param url [String] the URL with placeholders in
76
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
77
- def sub_url(url, param_map)
78
- param_map.reduce(url) do |new_url, (param, value)|
79
- new_url.gsub(":#{param}", URI.escape(value))
80
- end
81
- end
82
72
  end
83
73
  end
84
74
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -162,6 +161,27 @@ module GoCardlessPro
162
161
  Resources::InstalmentSchedule.new(unenvelope_body(response.body), response)
163
162
  end
164
163
 
164
+ # Updates an instalment schedule. This accepts only the metadata parameter.
165
+ # Example URL: /instalment_schedules/:identity
166
+ #
167
+ # @param identity # Unique identifier, beginning with "IS".
168
+ # @param options [Hash] parameters as a hash, under a params key.
169
+ def update(identity, options = {})
170
+ path = sub_url('/instalment_schedules/:identity', 'identity' => identity)
171
+
172
+ params = options.delete(:params) || {}
173
+ options[:params] = {}
174
+ options[:params][envelope_key] = params
175
+
176
+ options[:retry_failures] = true
177
+
178
+ response = make_request(:put, path, options)
179
+
180
+ return if response.body.nil?
181
+
182
+ Resources::InstalmentSchedule.new(unenvelope_body(response.body), response)
183
+ end
184
+
165
185
  # Immediately cancels an instalment schedule; no further payments will be
166
186
  # collected for it.
167
187
  #
@@ -218,15 +238,6 @@ module GoCardlessPro
218
238
  def envelope_key
219
239
  'instalment_schedules'
220
240
  end
221
-
222
- # take a URL with placeholder params and substitute them out for the actual value
223
- # @param url [String] the URL with placeholders in
224
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
225
- def sub_url(url, param_map)
226
- param_map.reduce(url) do |new_url, (param, value)|
227
- new_url.gsub(":#{param}", URI.escape(value))
228
- end
229
- end
230
241
  end
231
242
  end
232
243
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -85,15 +84,6 @@ module GoCardlessPro
85
84
  def envelope_key
86
85
  'mandate_import_entries'
87
86
  end
88
-
89
- # take a URL with placeholder params and substitute them out for the actual value
90
- # @param url [String] the URL with placeholders in
91
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
92
- def sub_url(url, param_map)
93
- param_map.reduce(url) do |new_url, (param, value)|
94
- new_url.gsub(":#{param}", URI.escape(value))
95
- end
96
- end
97
87
  end
98
88
  end
99
89
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -176,15 +175,6 @@ module GoCardlessPro
176
175
  def envelope_key
177
176
  'mandate_imports'
178
177
  end
179
-
180
- # take a URL with placeholder params and substitute them out for the actual value
181
- # @param url [String] the URL with placeholders in
182
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
183
- def sub_url(url, param_map)
184
- param_map.reduce(url) do |new_url, (param, value)|
185
- new_url.gsub(":#{param}", URI.escape(value))
186
- end
187
- end
188
178
  end
189
179
  end
190
180
  end
@@ -1,5 +1,4 @@
1
1
  require_relative './base_service'
2
- require 'uri'
3
2
 
4
3
  # encoding: utf-8
5
4
  #
@@ -85,15 +84,6 @@ module GoCardlessPro
85
84
  def envelope_key
86
85
  'mandate_pdfs'
87
86
  end
88
-
89
- # take a URL with placeholder params and substitute them out for the actual value
90
- # @param url [String] the URL with placeholders in
91
- # @param param_map [Hash] a hash of placeholders and their actual values (which will be escaped)
92
- def sub_url(url, param_map)
93
- param_map.reduce(url) do |new_url, (param, value)|
94
- new_url.gsub(":#{param}", URI.escape(value))
95
- end
96
- end
97
87
  end
98
88
  end
99
89
  end