gocardless_pro 2.19.0 → 2.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) 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.rb +3 -0
  6. data/lib/gocardless_pro/api_service.rb +1 -1
  7. data/lib/gocardless_pro/client.rb +6 -1
  8. data/lib/gocardless_pro/resources/payout.rb +2 -0
  9. data/lib/gocardless_pro/resources/payout_item.rb +2 -0
  10. data/lib/gocardless_pro/resources/tax_rate.rb +48 -0
  11. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +0 -10
  12. data/lib/gocardless_pro/services/base_service.rb +11 -0
  13. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +0 -10
  14. data/lib/gocardless_pro/services/creditors_service.rb +0 -10
  15. data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +0 -10
  16. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +0 -10
  17. data/lib/gocardless_pro/services/customer_notifications_service.rb +0 -10
  18. data/lib/gocardless_pro/services/customers_service.rb +0 -10
  19. data/lib/gocardless_pro/services/events_service.rb +0 -10
  20. data/lib/gocardless_pro/services/instalment_schedules_service.rb +21 -10
  21. data/lib/gocardless_pro/services/mandate_import_entries_service.rb +0 -10
  22. data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -10
  23. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +0 -10
  24. data/lib/gocardless_pro/services/mandates_service.rb +0 -10
  25. data/lib/gocardless_pro/services/payments_service.rb +0 -10
  26. data/lib/gocardless_pro/services/payout_items_service.rb +0 -10
  27. data/lib/gocardless_pro/services/payouts_service.rb +0 -10
  28. data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -10
  29. data/lib/gocardless_pro/services/refunds_service.rb +6 -11
  30. data/lib/gocardless_pro/services/subscriptions_service.rb +0 -10
  31. data/lib/gocardless_pro/services/tax_rates_service.rb +74 -0
  32. data/lib/gocardless_pro/version.rb +1 -1
  33. data/spec/resources/instalment_schedule_spec.rb +35 -0
  34. data/spec/resources/payout_item_spec.rb +5 -0
  35. data/spec/resources/payout_spec.rb +8 -0
  36. data/spec/resources/tax_rate_spec.rb +198 -0
  37. data/spec/services/creditor_bank_accounts_service_spec.rb +1 -1
  38. data/spec/services/customer_bank_accounts_service_spec.rb +1 -1
  39. data/spec/services/customer_notifications_service_spec.rb +1 -1
  40. data/spec/services/customers_service_spec.rb +1 -1
  41. data/spec/services/instalment_schedules_service_spec.rb +61 -1
  42. data/spec/services/mandate_imports_service_spec.rb +2 -2
  43. data/spec/services/mandates_service_spec.rb +2 -2
  44. data/spec/services/payments_service_spec.rb +2 -2
  45. data/spec/services/payout_items_service_spec.rb +9 -0
  46. data/spec/services/payouts_service_spec.rb +12 -0
  47. data/spec/services/redirect_flows_service_spec.rb +1 -1
  48. data/spec/services/subscriptions_service_spec.rb +3 -3
  49. data/spec/services/tax_rates_service_spec.rb +381 -0
  50. metadata +17 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7e71f4726525b3ce899c9f4ce10cb6f957805c654f1025a5aad542c6181aa60
4
- data.tar.gz: 9501e18394e43ab7d541712fd3130f2184d6f4caede7916abf01c24add413160
3
+ metadata.gz: 380e86ab83d0876327222f7966dbae08687e51cec34c468f2f57b9064a6de49b
4
+ data.tar.gz: 92a6001ee0d724bb218d3d4ef6e245389842391b8d251e7b79afe6210432367a
5
5
  SHA512:
6
- metadata.gz: a8015fa41e3a0b6c5bd62810ff5f00438d880313d3a0051f756af8ba4d3c6eccd3f71c7b56452fcf9981a52a265feb692caf2deca77cf8705b094e24bb1e3a25
7
- data.tar.gz: 972c8baa19abfbe69390010d4350788b04263c4af0665f19f35161f6b899cc32c3d5a073b36bb0596a010f9c8f34442dac56fe643e27588edfbd800ddbd6414e
6
+ metadata.gz: 6241d24b24dcf35224c87bf2c559c3a0c6f543ef4f3e2c73885e8aee1a4cccc9e8fb748d323df5768c9acd01510b0ae78cf8182d2d684a7feb119bd91ad0c5ac
7
+ data.tar.gz: 2981ece7e5ad7cef1056ed51a02dc805c5a4c3d41ec483604e2b0ae2a552ca6cd2d2da1e7a92fa1740c9ce61b55e3fecd27c9138817bcf87a8d830047acdd552
@@ -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
 
@@ -95,4 +95,7 @@ require_relative 'gocardless_pro/services/refunds_service'
95
95
  require_relative 'gocardless_pro/resources/subscription'
96
96
  require_relative 'gocardless_pro/services/subscriptions_service'
97
97
 
98
+ require_relative 'gocardless_pro/resources/tax_rate'
99
+ require_relative 'gocardless_pro/services/tax_rates_service'
100
+
98
101
  require_relative 'gocardless_pro/client.rb'
@@ -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
@@ -98,6 +98,11 @@ module GoCardlessPro
98
98
  @subscriptions ||= Services::SubscriptionsService.new(@api_service)
99
99
  end
100
100
 
101
+ # Access to the service for tax_rate to make API calls
102
+ def tax_rates
103
+ @tax_rates ||= Services::TaxRatesService.new(@api_service)
104
+ end
105
+
101
106
  # Get a Client configured to use HTTP Basic authentication with the GC Api
102
107
  #
103
108
  # @param options [Hash<Symbol,String>] configuration for creating the client
@@ -148,7 +153,7 @@ module GoCardlessPro
148
153
  'User-Agent' => user_agent.to_s,
149
154
  'Content-Type' => 'application/json',
150
155
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
151
- 'GoCardless-Client-Version' => '2.19.0',
156
+ 'GoCardless-Client-Version' => '2.23.0',
152
157
  },
153
158
  }
154
159
  end
@@ -30,6 +30,7 @@ module GoCardlessPro
30
30
  attr_reader :payout_type
31
31
  attr_reader :reference
32
32
  attr_reader :status
33
+ attr_reader :tax_currency
33
34
 
34
35
  # Initialize a payout resource instance
35
36
  # @param object [Hash] an object returned from the API
@@ -48,6 +49,7 @@ module GoCardlessPro
48
49
  @payout_type = object['payout_type']
49
50
  @reference = object['reference']
50
51
  @status = object['status']
52
+ @tax_currency = object['tax_currency']
51
53
  @response = response
52
54
  end
53
55
 
@@ -32,6 +32,7 @@ module GoCardlessPro
32
32
  #
33
33
  class PayoutItem
34
34
  attr_reader :amount
35
+ attr_reader :taxes
35
36
  attr_reader :type
36
37
 
37
38
  # Initialize a payout_item resource instance
@@ -41,6 +42,7 @@ module GoCardlessPro
41
42
 
42
43
  @amount = object['amount']
43
44
  @links = object['links']
45
+ @taxes = object['taxes']
44
46
  @type = object['type']
45
47
  @response = response
46
48
  end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ #
4
+ # This client is automatically generated from a template and JSON schema definition.
5
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
6
+ #
7
+
8
+ require 'uri'
9
+
10
+ module GoCardlessPro
11
+ # A module containing classes for each of the resources in the GC Api
12
+ module Resources
13
+ # Represents an instance of a tax_rate resource returned from the API
14
+
15
+ # Tax rates from tax authority.
16
+ class TaxRate
17
+ attr_reader :end_date
18
+ attr_reader :id
19
+ attr_reader :jurisdiction
20
+ attr_reader :percentage
21
+ attr_reader :start_date
22
+ attr_reader :type
23
+
24
+ # Initialize a tax_rate resource instance
25
+ # @param object [Hash] an object returned from the API
26
+ def initialize(object, response = nil)
27
+ @object = object
28
+
29
+ @end_date = object['end_date']
30
+ @id = object['id']
31
+ @jurisdiction = object['jurisdiction']
32
+ @percentage = object['percentage']
33
+ @start_date = object['start_date']
34
+ @type = object['type']
35
+ @response = response
36
+ end
37
+
38
+ def api_response
39
+ ApiResponse.new(@response)
40
+ end
41
+
42
+ # Provides the tax_rate resource as a hash of all its readable attributes
43
+ def to_h
44
+ @object
45
+ end
46
+ end
47
+ end
48
+ end
@@ -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