gocardless_pro 2.1.0 → 2.2.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/circle.yml +11 -3
  4. data/demo.rb +3 -3
  5. data/gocardless_pro.gemspec +6 -6
  6. data/lib/gocardless_pro.rb +2 -1
  7. data/lib/gocardless_pro/api_service.rb +3 -2
  8. data/lib/gocardless_pro/client.rb +6 -6
  9. data/lib/gocardless_pro/error.rb +4 -4
  10. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +4 -4
  11. data/lib/gocardless_pro/request.rb +2 -2
  12. data/lib/gocardless_pro/resources/bank_details_lookup.rb +1 -0
  13. data/lib/gocardless_pro/resources/creditor.rb +1 -0
  14. data/lib/gocardless_pro/resources/creditor_bank_account.rb +1 -0
  15. data/lib/gocardless_pro/resources/customer.rb +1 -0
  16. data/lib/gocardless_pro/resources/customer_bank_account.rb +1 -0
  17. data/lib/gocardless_pro/resources/event.rb +1 -0
  18. data/lib/gocardless_pro/resources/mandate.rb +1 -0
  19. data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -0
  20. data/lib/gocardless_pro/resources/payment.rb +1 -0
  21. data/lib/gocardless_pro/resources/payout.rb +1 -0
  22. data/lib/gocardless_pro/resources/redirect_flow.rb +1 -0
  23. data/lib/gocardless_pro/resources/refund.rb +1 -0
  24. data/lib/gocardless_pro/resources/subscription.rb +1 -0
  25. data/lib/gocardless_pro/services/base_service.rb +1 -1
  26. data/lib/gocardless_pro/version.rb +1 -1
  27. data/spec/api_service_spec.rb +49 -49
  28. data/spec/client_spec.rb +1 -1
  29. data/spec/error_spec.rb +13 -13
  30. data/spec/middlewares/raise_gocardless_errors_spec.rb +15 -16
  31. data/spec/resources/bank_details_lookup_spec.rb +18 -18
  32. data/spec/resources/creditor_bank_account_spec.rb +46 -46
  33. data/spec/resources/creditor_spec.rb +42 -42
  34. data/spec/resources/customer_bank_account_spec.rb +48 -48
  35. data/spec/resources/customer_spec.rb +42 -42
  36. data/spec/resources/event_spec.rb +18 -18
  37. data/spec/resources/mandate_pdf_spec.rb +18 -18
  38. data/spec/resources/mandate_spec.rb +54 -54
  39. data/spec/resources/payment_spec.rb +54 -54
  40. data/spec/resources/payout_spec.rb +18 -18
  41. data/spec/resources/redirect_flow_spec.rb +36 -36
  42. data/spec/resources/refund_spec.rb +42 -42
  43. data/spec/resources/subscription_spec.rb +48 -48
  44. data/spec/response_spec.rb +1 -2
  45. data/spec/services/bank_details_lookups_service_spec.rb +25 -25
  46. data/spec/services/creditor_bank_accounts_service_spec.rb +86 -86
  47. data/spec/services/creditors_service_spec.rb +87 -87
  48. data/spec/services/customer_bank_accounts_service_spec.rb +95 -95
  49. data/spec/services/customers_service_spec.rb +87 -87
  50. data/spec/services/events_service_spec.rb +49 -49
  51. data/spec/services/mandate_pdfs_service_spec.rb +25 -25
  52. data/spec/services/mandates_service_spec.rb +103 -103
  53. data/spec/services/payments_service_spec.rb +103 -103
  54. data/spec/services/payouts_service_spec.rb +49 -49
  55. data/spec/services/redirect_flows_service_spec.rb +52 -52
  56. data/spec/services/refunds_service_spec.rb +87 -87
  57. data/spec/services/subscriptions_service_spec.rb +95 -95
  58. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8c9ec530e509727543e6ab0142302f928749b00
4
- data.tar.gz: 9d034d961ac65edaff460c30812fafeae80f8568
3
+ metadata.gz: 39c5c4f0dcfab5cebeeba56aa2e1801e9775a6d0
4
+ data.tar.gz: c1cc2f6d595d13011d219282b08fe37301e7e0c2
5
5
  SHA512:
6
- metadata.gz: 5758970f6680e461020c00ecf0a4df121da2bffec487d203ba4a2338def6856bd8fda4ce376ec320f1b4decb0cbac751826d054d5da9b42295deed02cc8e60ed
7
- data.tar.gz: 0ea10725022cef83ba659d5df6d2db1ac7b9ecbad6671846114185205da20baf987a96da26fcb0c6539624b246a8d12d245713c66dc26e622ab23bcf3ab6a290
6
+ metadata.gz: 3180f056a519890bea499e2daf2c983e296709432c63fb4de98df96ffa446217c5bf595e3df4ffe8e06bf3b1b0204647d377aebfb4ff675113ac1650b0bfdc31
7
+ data.tar.gz: 85bb043efad721d43dc239865411f3ba5ce962841153ec92fcdf590cb2ee068ce4f19bca397385415e6c5599786e8bf1b29975ca1be323fd8e81a8a4d3c515c8
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Layout/DotPosition:
2
+ EnforcedStyle: trailing
3
+
4
+ Style/TrailingCommaInLiteral:
5
+ EnforcedStyleForMultiline: comma
data/circle.yml CHANGED
@@ -1,3 +1,11 @@
1
- machine:
2
- ruby:
3
- version: 2.0.0-p353
1
+ dependencies:
2
+ override:
3
+ - 'rvm-exec 2.2.7 bundle install'
4
+ - 'rvm-exec 2.3.4 bundle install'
5
+ - 'rvm-exec 2.4.1 bundle install'
6
+
7
+ test:
8
+ override:
9
+ - 'rvm-exec 2.2.7 bundle exec rspec'
10
+ - 'rvm-exec 2.3.4 bundle exec rspec'
11
+ - 'rvm-exec 2.4.1 bundle exec rspec'
data/demo.rb CHANGED
@@ -1,9 +1,9 @@
1
- require_relative 'lib/gocardless_pro'
1
+ require_relative 'lib/gocardless_pro'
2
2
 
3
3
  @client = GoCardlessPro::Client.new(
4
- access_token: ENV["GOCARDLESS_TOKEN"],
4
+ access_token: ENV['GOCARDLESS_TOKEN'],
5
5
  environment: :sandbox
6
6
  )
7
7
 
8
- puts "Your first customer:"
8
+ puts 'Your first customer:'
9
9
  puts "-> #{@client.customers.list.records.first.inspect}"
@@ -4,23 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'gocardless_pro/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "gocardless_pro"
7
+ spec.name = 'gocardless_pro'
8
8
  spec.version = GoCardlessPro::VERSION
9
9
  spec.authors = %w(GoCardless)
10
10
  spec.email = %w(engineering@gocardless.com)
11
11
  spec.summary = %q{A gem for calling the GoCardless Pro API}
12
- spec.homepage = "https://github.com/gocardless/gocardless-pro-ruby"
13
- spec.license = "MIT"
12
+ spec.homepage = 'https://github.com/gocardless/gocardless-pro-ruby'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_development_dependency 'rspec', '~> 3.1'
21
21
  spec.add_development_dependency 'webmock', '~> 1.18'
22
- spec.add_development_dependency 'rubocop', '~> 0.35.1'
22
+ spec.add_development_dependency 'rubocop', '~> 0.49.1'
23
23
  spec.add_development_dependency 'yard', '~> 0.8.7.6'
24
24
 
25
- spec.add_dependency 'faraday', ['>= 0.8.9', '< 0.10']
25
+ spec.add_dependency 'faraday', ['>= 0.9.2', '< 1.0']
26
26
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -19,7 +20,7 @@ version_file = 'gocardless_pro/version'
19
20
  if File.file? File.expand_path("#{version_file}.rb", File.dirname(__FILE__))
20
21
  require_relative version_file
21
22
  else
22
- GoCardlessPro::VERSION = ''
23
+ GoCardlessPro::VERSION = ''.freeze
23
24
  end
24
25
 
25
26
  require_relative 'gocardless_pro/api_service'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -38,7 +39,7 @@ module GoCardlessPro
38
39
  # @param path [String] the URL (without the base domain) to make the request to
39
40
  # @param options [Hash] the options hash
40
41
  def make_request(method, path, options = {})
41
- fail ArgumentError, 'options must be a hash' unless options.is_a?(Hash)
42
+ raise ArgumentError, 'options must be a hash' unless options.is_a?(Hash)
42
43
  options[:headers] ||= {}
43
44
  options[:headers] = @headers.merge(options[:headers])
44
45
  Request.new(@connection, method, @path_prefix + path, options).request
@@ -50,7 +51,7 @@ module GoCardlessPro
50
51
  url.password = 'REDACTED' unless url.password.nil?
51
52
  "#<GoCardlessPro::Client url=\"#{url}\">"
52
53
  end
53
- alias_method :to_s, :inspect
54
+ alias to_s inspect
54
55
 
55
56
  private
56
57
 
@@ -79,7 +79,7 @@ module GoCardlessPro
79
79
  # authentication.
80
80
  #
81
81
  def initialize(options)
82
- access_token = options.delete(:access_token) || fail('No Access Token given to GoCardless Client')
82
+ access_token = options.delete(:access_token) || raise('No Access Token given to GoCardless Client')
83
83
  environment = options.delete(:environment) || :live
84
84
  url = options.delete(:url) || url_for_environment(environment)
85
85
  options = custom_options(options)
@@ -94,7 +94,7 @@ module GoCardlessPro
94
94
  elsif environment === :sandbox
95
95
  'https://api-sandbox.gocardless.com'
96
96
  else
97
- fail "Unknown environment key: #{environment}"
97
+ raise "Unknown environment key: #{environment}"
98
98
  end
99
99
  end
100
100
 
@@ -115,11 +115,11 @@ module GoCardlessPro
115
115
  {
116
116
  default_headers: {
117
117
  'GoCardless-Version' => '2015-07-06',
118
- 'User-Agent' => "#{user_agent}",
118
+ 'User-Agent' => user_agent.to_s,
119
119
  'Content-Type' => 'application/json',
120
120
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
121
- 'GoCardless-Client-Version' => '2.1.0'
122
- }
121
+ 'GoCardless-Client-Version' => '2.2.0',
122
+ },
123
123
  }
124
124
  end
125
125
 
@@ -139,7 +139,7 @@ module GoCardlessPro
139
139
  comment = [
140
140
  "#{ruby_engine}/#{ruby_version}",
141
141
  "#{RUBY_ENGINE}/#{interpreter_version}",
142
- "#{RUBY_PLATFORM}"
142
+ RUBY_PLATFORM.to_s,
143
143
  ]
144
144
  comment << "faraday/#{Faraday::VERSION}"
145
145
  "#{gem_info} #{comment.join(' ')}"
@@ -6,7 +6,7 @@ module GoCardlessPro
6
6
  # intialize a new error
7
7
  #  @param error the error from the API
8
8
  def initialize(error)
9
- fail ArgumentError, 'GoCardless errors expect a hash' unless error.is_a?(Hash)
9
+ raise ArgumentError, 'GoCardless errors expect a hash' unless error.is_a?(Hash)
10
10
  @error = error
11
11
  end
12
12
 
@@ -22,9 +22,9 @@ module GoCardlessPro
22
22
 
23
23
  def to_s
24
24
  if errors.any?
25
- errors
26
- .map { |err| "#{err['field']} #{err['message']}" }
27
- .join(', ')
25
+ errors.
26
+ map { |err| "#{err['field']} #{err['message']}" }.
27
+ join(', ')
28
28
  else
29
29
  @error['message']
30
30
  end
@@ -6,13 +6,13 @@ module GoCardlessPro
6
6
 
7
7
  def on_complete(env)
8
8
  if !json?(env) || API_ERROR_STATUSES.include?(env.status)
9
- fail ApiError, generate_error_data(env)
9
+ raise ApiError, generate_error_data(env)
10
10
  end
11
11
 
12
12
  if CLIENT_ERROR_STATUSES.include?(env.status)
13
13
  json_body ||= JSON.parse(env.body) unless env.body.empty?
14
14
  error_type = json_body['error']['type']
15
- fail(error_class_for_type(error_type), json_body['error'])
15
+ raise(error_class_for_type(error_type), json_body['error'])
16
16
  end
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module GoCardlessPro
23
23
  validation_failed: GoCardlessPro::ValidationError,
24
24
  gocardless: GoCardlessPro::GoCardlessError,
25
25
  invalid_api_usage: GoCardlessPro::InvalidApiUsageError,
26
- invalid_state: GoCardlessPro::InvalidStateError
26
+ invalid_state: GoCardlessPro::InvalidStateError,
27
27
  }.fetch(type.to_sym)
28
28
  end
29
29
 
@@ -33,7 +33,7 @@ module GoCardlessPro
33
33
  "code: #{env.status}\n" \
34
34
  "headers: #{env.response_headers}\n" \
35
35
  "body: #{env.body}",
36
- 'code' => env.status
36
+ 'code' => env.status,
37
37
  }
38
38
  end
39
39
 
@@ -71,10 +71,10 @@ module GoCardlessPro
71
71
  def request_body
72
72
  if @method == :get
73
73
  nil
74
- elsif [:post, :put, :delete].include?(@method)
74
+ elsif %i[post put delete].include?(@method)
75
75
  @given_options.fetch(:params, {})
76
76
  else
77
- fail "Unknown request method #{@method}"
77
+ raise "Unknown request method #{@method}"
78
78
  end
79
79
  end
80
80
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  #
3
4
  # This client is automatically generated from a template and JSON schema definition.
4
5
  # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
@@ -21,7 +21,7 @@ module GoCardlessPro
21
21
 
22
22
  # Get the envelope key for the given service. Children are expected to implement this method.
23
23
  def envelope_key
24
- fail NotImplementedError
24
+ raise NotImplementedError
25
25
  end
26
26
  end
27
27
  end
@@ -4,5 +4,5 @@ end
4
4
 
5
5
  module GoCardlessPro
6
6
  # Current version of the GC gem
7
- VERSION = '2.1.0'
7
+ VERSION = '2.2.0'.freeze
8
8
  end
@@ -7,14 +7,14 @@ describe GoCardlessPro::ApiService do
7
7
  {
8
8
  status: 200,
9
9
  body: '{}',
10
- headers: { 'Content-Type' => 'application/json' }
10
+ headers: { 'Content-Type' => 'application/json' },
11
11
  }
12
12
  end
13
13
 
14
14
  it 'uses basic auth' do
15
- stub = stub_request(:get, 'https://api.example.com/customers')
16
- .with(headers: { 'Authorization' => 'Bearer secret_token' })
17
- .to_return(default_response)
15
+ stub = stub_request(:get, 'https://api.example.com/customers').
16
+ with(headers: { 'Authorization' => 'Bearer secret_token' }).
17
+ to_return(default_response)
18
18
 
19
19
  service.make_request(:get, '/customers')
20
20
  expect(stub).to have_been_requested
@@ -22,17 +22,17 @@ describe GoCardlessPro::ApiService do
22
22
 
23
23
  describe 'making a get request without any parameters' do
24
24
  it 'is expected to call the correct stub' do
25
- stub = stub_request(:get, /.*api.example.com\/customers/)
26
- .to_return(default_response)
25
+ stub = stub_request(:get, /.*api.example.com\/customers/).
26
+ to_return(default_response)
27
27
 
28
28
  service.make_request(:get, '/customers')
29
29
  expect(stub).to have_been_requested
30
30
  end
31
31
 
32
32
  it "doesn't include an idempotency key" do
33
- stub = stub_request(:get, /.*api.example.com\/customers/)
34
- .with { |request| !request.headers.key?('Idempotency-Key') }
35
- .to_return(default_response)
33
+ stub = stub_request(:get, /.*api.example.com\/customers/).
34
+ with { |request| !request.headers.key?('Idempotency-Key') }.
35
+ to_return(default_response)
36
36
 
37
37
  service.make_request(:get, '/customers')
38
38
  expect(stub).to have_been_requested
@@ -41,17 +41,17 @@ describe GoCardlessPro::ApiService do
41
41
 
42
42
  describe 'making a get request with query parameters' do
43
43
  it 'correctly passes the query parameters' do
44
- stub = stub_request(:get, /.*api.example.com\/customers\?a=1&b=2/)
45
- .to_return(default_response)
44
+ stub = stub_request(:get, /.*api.example.com\/customers\?a=1&b=2/).
45
+ to_return(default_response)
46
46
 
47
47
  service.make_request(:get, '/customers', params: { a: 1, b: 2 })
48
48
  expect(stub).to have_been_requested
49
49
  end
50
50
 
51
51
  it "doesn't include an idempotency key" do
52
- stub = stub_request(:get, /.*api.example.com\/customers\?a=1&b=2/)
53
- .with { |request| !request.headers.key?('Idempotency-Key') }
54
- .to_return(default_response)
52
+ stub = stub_request(:get, /.*api.example.com\/customers\?a=1&b=2/).
53
+ with { |request| !request.headers.key?('Idempotency-Key') }.
54
+ to_return(default_response)
55
55
 
56
56
  service.make_request(:get, '/customers', params: { a: 1, b: 2 })
57
57
  expect(stub).to have_been_requested
@@ -60,13 +60,13 @@ describe GoCardlessPro::ApiService do
60
60
 
61
61
  describe 'making a post request with some data' do
62
62
  it 'passes the data in as the post body' do
63
- stub = stub_request(:post, /.*api.example.com\/customers/)
64
- .with(body: { given_name: 'Jack', family_name: 'Franklin' })
65
- .to_return(default_response)
63
+ stub = stub_request(:post, /.*api.example.com\/customers/).
64
+ with(body: { given_name: 'Jack', family_name: 'Franklin' }).
65
+ to_return(default_response)
66
66
 
67
67
  service.make_request(:post, '/customers', params: {
68
68
  given_name: 'Jack',
69
- family_name: 'Franklin'
69
+ family_name: 'Franklin',
70
70
  })
71
71
  expect(stub).to have_been_requested
72
72
  end
@@ -74,16 +74,16 @@ describe GoCardlessPro::ApiService do
74
74
  it 'generates a random idempotency key' do
75
75
  allow(SecureRandom).to receive(:uuid).and_return('random-uuid')
76
76
 
77
- stub = stub_request(:post, /.*api.example.com\/customers/)
78
- .with(
77
+ stub = stub_request(:post, /.*api.example.com\/customers/).
78
+ with(
79
79
  body: { given_name: 'Jack', family_name: 'Franklin' },
80
80
  headers: { 'Idempotency-Key' => 'random-uuid' }
81
- )
82
- .to_return(default_response)
81
+ ).
82
+ to_return(default_response)
83
83
 
84
84
  service.make_request(:post, '/customers', params: {
85
85
  given_name: 'Jack',
86
- family_name: 'Franklin'
86
+ family_name: 'Franklin',
87
87
  })
88
88
  expect(stub).to have_been_requested
89
89
  end
@@ -91,19 +91,19 @@ describe GoCardlessPro::ApiService do
91
91
 
92
92
  describe 'making a post request with data and custom header' do
93
93
  it 'passes the data in as the post body' do
94
- stub = stub_request(:post, /.*api.example.com\/customers/)
95
- .with(
94
+ stub = stub_request(:post, /.*api.example.com\/customers/).
95
+ with(
96
96
  body: { given_name: 'Jack', family_name: 'Franklin' },
97
97
  headers: { 'Foo' => 'Bar' }
98
- )
99
- .to_return(default_response)
98
+ ).
99
+ to_return(default_response)
100
100
 
101
101
  service.make_request(:post, '/customers', params: {
102
102
  given_name: 'Jack',
103
- family_name: 'Franklin'
103
+ family_name: 'Franklin',
104
104
  },
105
105
  headers: {
106
- 'Foo' => 'Bar'
106
+ 'Foo' => 'Bar',
107
107
  })
108
108
  expect(stub).to have_been_requested
109
109
  end
@@ -111,38 +111,38 @@ describe GoCardlessPro::ApiService do
111
111
  it 'merges in a random idempotency key' do
112
112
  allow(SecureRandom).to receive(:uuid).and_return('random-uuid')
113
113
 
114
- stub = stub_request(:post, /.*api.example.com\/customers/)
115
- .with(
114
+ stub = stub_request(:post, /.*api.example.com\/customers/).
115
+ with(
116
116
  body: { given_name: 'Jack', family_name: 'Franklin' },
117
117
  headers: { 'Idempotency-Key' => 'random-uuid', 'Foo' => 'Bar' }
118
- )
119
- .to_return(default_response)
118
+ ).
119
+ to_return(default_response)
120
120
 
121
121
  service.make_request(:post, '/customers', params: {
122
122
  given_name: 'Jack',
123
- family_name: 'Franklin'
123
+ family_name: 'Franklin',
124
124
  },
125
125
  headers: {
126
- 'Foo' => 'Bar'
126
+ 'Foo' => 'Bar',
127
127
  })
128
128
  expect(stub).to have_been_requested
129
129
  end
130
130
 
131
131
  context 'with a custom idempotency key' do
132
132
  it "doesn't replace it with a randomly-generated idempotency key" do
133
- stub = stub_request(:post, /.*api.example.com\/customers/)
134
- .with(
133
+ stub = stub_request(:post, /.*api.example.com\/customers/).
134
+ with(
135
135
  body: { given_name: 'Jack', family_name: 'Franklin' },
136
136
  headers: { 'Idempotency-Key' => 'my-custom-idempotency-key' }
137
- )
138
- .to_return(default_response)
137
+ ).
138
+ to_return(default_response)
139
139
 
140
140
  service.make_request(:post, '/customers', params: {
141
141
  given_name: 'Jack',
142
- family_name: 'Franklin'
142
+ family_name: 'Franklin',
143
143
  },
144
144
  headers: {
145
- 'Idempotency-Key' => 'my-custom-idempotency-key'
145
+ 'Idempotency-Key' => 'my-custom-idempotency-key',
146
146
  })
147
147
  expect(stub).to have_been_requested
148
148
  end
@@ -151,25 +151,25 @@ describe GoCardlessPro::ApiService do
151
151
 
152
152
  describe 'making a put request with some data' do
153
153
  it 'passes the data in as the request body' do
154
- stub = stub_request(:put, /.*api.example.com\/customers\/CU123/)
155
- .with(body: { given_name: 'Jack', family_name: 'Franklin' })
156
- .to_return(default_response)
154
+ stub = stub_request(:put, /.*api.example.com\/customers\/CU123/).
155
+ with(body: { given_name: 'Jack', family_name: 'Franklin' }).
156
+ to_return(default_response)
157
157
 
158
158
  service.make_request(:put, '/customers/CU123', params: {
159
159
  given_name: 'Jack',
160
- family_name: 'Franklin'
160
+ family_name: 'Franklin',
161
161
  })
162
162
  expect(stub).to have_been_requested
163
163
  end
164
164
 
165
165
  it "doesn't include an idempotency key" do
166
- stub = stub_request(:put, /.*api.example.com\/customers\/CU123/)
167
- .with { |request| !request.headers.key?('Idempotency-Key') }
168
- .to_return(default_response)
166
+ stub = stub_request(:put, /.*api.example.com\/customers\/CU123/).
167
+ with { |request| !request.headers.key?('Idempotency-Key') }.
168
+ to_return(default_response)
169
169
 
170
170
  service.make_request(:put, '/customers/CU123', params: {
171
171
  given_name: 'Jack',
172
- family_name: 'Franklin'
172
+ family_name: 'Franklin',
173
173
  })
174
174
  expect(stub).to have_been_requested
175
175
  end