gocardless_pro 2.27.0 → 2.30.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -1
  3. data/lib/gocardless_pro/api_service.rb +4 -0
  4. data/lib/gocardless_pro/client.rb +11 -1
  5. data/lib/gocardless_pro/error/authentication_error.rb +4 -0
  6. data/lib/gocardless_pro/error/permission_error.rb +4 -0
  7. data/lib/gocardless_pro/error/rate_limit_error.rb +4 -0
  8. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +12 -1
  9. data/lib/gocardless_pro/resources/bank_authorisation.rb +3 -9
  10. data/lib/gocardless_pro/resources/billing_request.rb +31 -7
  11. data/lib/gocardless_pro/resources/billing_request_flow.rb +14 -0
  12. data/lib/gocardless_pro/resources/billing_request_template.rb +68 -0
  13. data/lib/gocardless_pro/resources/block.rb +76 -0
  14. data/lib/gocardless_pro/resources/event.rb +20 -0
  15. data/lib/gocardless_pro/resources/institution.rb +7 -1
  16. data/lib/gocardless_pro/resources/payer_authorisation.rb +9 -0
  17. data/lib/gocardless_pro/resources/redirect_flow.rb +6 -0
  18. data/lib/gocardless_pro/services/bank_authorisations_service.rb +0 -2
  19. data/lib/gocardless_pro/services/billing_request_flows_service.rb +23 -0
  20. data/lib/gocardless_pro/services/billing_request_templates_service.rb +131 -0
  21. data/lib/gocardless_pro/services/billing_requests_service.rb +89 -24
  22. data/lib/gocardless_pro/services/blocks_service.rb +223 -0
  23. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +1 -5
  24. data/lib/gocardless_pro/services/creditors_service.rb +1 -3
  25. data/lib/gocardless_pro/services/currency_exchange_rates_service.rb +1 -1
  26. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +1 -5
  27. data/lib/gocardless_pro/services/customers_service.rb +1 -3
  28. data/lib/gocardless_pro/services/events_service.rb +1 -1
  29. data/lib/gocardless_pro/services/instalment_schedules_service.rb +1 -7
  30. data/lib/gocardless_pro/services/institutions_service.rb +2 -2
  31. data/lib/gocardless_pro/services/mandate_import_entries_service.rb +1 -1
  32. data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -6
  33. data/lib/gocardless_pro/services/mandates_service.rb +1 -7
  34. data/lib/gocardless_pro/services/payer_authorisations_service.rb +0 -6
  35. data/lib/gocardless_pro/services/payments_service.rb +1 -7
  36. data/lib/gocardless_pro/services/payout_items_service.rb +1 -1
  37. data/lib/gocardless_pro/services/payouts_service.rb +1 -1
  38. data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -4
  39. data/lib/gocardless_pro/services/refunds_service.rb +1 -3
  40. data/lib/gocardless_pro/services/scenario_simulators_service.rb +28 -6
  41. data/lib/gocardless_pro/services/subscriptions_service.rb +3 -11
  42. data/lib/gocardless_pro/services/tax_rates_service.rb +1 -1
  43. data/lib/gocardless_pro/services/webhooks_service.rb +1 -3
  44. data/lib/gocardless_pro/version.rb +1 -1
  45. data/lib/gocardless_pro.rb +9 -0
  46. data/spec/api_service_spec.rb +12 -1
  47. data/spec/middlewares/raise_gocardless_errors_spec.rb +30 -0
  48. data/spec/resources/bank_authorisation_spec.rb +7 -7
  49. data/spec/resources/billing_request_flow_spec.rb +104 -0
  50. data/spec/resources/billing_request_spec.rb +183 -29
  51. data/spec/resources/billing_request_template_spec.rb +502 -0
  52. data/spec/resources/block_spec.rb +577 -0
  53. data/spec/resources/creditor_bank_account_spec.rb +2 -0
  54. data/spec/resources/customer_bank_account_spec.rb +2 -0
  55. data/spec/resources/customer_notification_spec.rb +2 -0
  56. data/spec/resources/customer_spec.rb +2 -0
  57. data/spec/resources/instalment_schedule_spec.rb +2 -0
  58. data/spec/resources/institution_spec.rb +5 -0
  59. data/spec/resources/mandate_import_spec.rb +4 -0
  60. data/spec/resources/mandate_spec.rb +4 -0
  61. data/spec/resources/payer_authorisation_spec.rb +4 -0
  62. data/spec/resources/payment_spec.rb +4 -0
  63. data/spec/resources/redirect_flow_spec.rb +11 -0
  64. data/spec/resources/scenario_simulator_spec.rb +2 -0
  65. data/spec/resources/subscription_spec.rb +6 -0
  66. data/spec/resources/webhook_spec.rb +2 -0
  67. data/spec/services/bank_authorisations_service_spec.rb +7 -20
  68. data/spec/services/billing_request_flows_service_spec.rb +115 -0
  69. data/spec/services/billing_request_templates_service_spec.rb +789 -0
  70. data/spec/services/billing_requests_service_spec.rb +210 -47
  71. data/spec/services/blocks_service_spec.rb +840 -0
  72. data/spec/services/creditor_bank_accounts_service_spec.rb +2 -13
  73. data/spec/services/creditors_service_spec.rb +0 -13
  74. data/spec/services/customer_bank_accounts_service_spec.rb +2 -13
  75. data/spec/services/customer_notifications_service_spec.rb +2 -0
  76. data/spec/services/customers_service_spec.rb +2 -13
  77. data/spec/services/instalment_schedules_service_spec.rb +2 -26
  78. data/spec/services/institutions_service_spec.rb +9 -0
  79. data/spec/services/mandate_imports_service_spec.rb +4 -13
  80. data/spec/services/mandates_service_spec.rb +4 -13
  81. data/spec/services/payer_authorisations_service_spec.rb +4 -13
  82. data/spec/services/payments_service_spec.rb +4 -13
  83. data/spec/services/redirect_flows_service_spec.rb +11 -13
  84. data/spec/services/refunds_service_spec.rb +0 -13
  85. data/spec/services/scenario_simulators_service_spec.rb +2 -0
  86. data/spec/services/subscriptions_service_spec.rb +6 -13
  87. data/spec/services/webhooks_service_spec.rb +2 -0
  88. metadata +18 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36f326b7d949867117fd93ecbe9074fcdb54ee3b690f046c2e48e16ce92281dc
4
- data.tar.gz: dba0ba60c85f16a5d3c87f311ea6b4b73d93a438441a2ff96c962669c56f7630
3
+ metadata.gz: 1591576f071daabb20a04e9e91a7e802be0efed1b3e71910e33c35335589cdf4
4
+ data.tar.gz: 763c87329cc80eba691ae417c58b3344abbc7ffc48fe554be85fedcc24c1e80d
5
5
  SHA512:
6
- metadata.gz: 5e5939895e083285066011907aad6a992fbb1f65b86392482964a4c856f64bf2834d9a63bb20faf2e7d3c00d5fa27e32ec0c2a9c4770f805ef2db2ba2983c79f
7
- data.tar.gz: da519896309a48029ff7d5fb47f2747234b119fb7b539a8701892fe19ea2c921d3606cd66dc9ed4ce70f891a408a979176de5806881a44ce6a82b600aa8cb91b
6
+ metadata.gz: 7b8552085fb1ec811f6398ed9f52990853a48c4836e8f6092273366dcd0a9e1f27e4399cc8489322a726e94153dd221e1a4cd20b68f72a0c371d4b62984ac0bb
7
+ data.tar.gz: ec4ab730899aad19e7a670b5da2378e651db3bb1e88734e9794967ef33ac764e973b70e7c2a61613065a8284a1cf8afbf6879e8c7eaa13cda53a3176527be200
data/.circleci/config.yml CHANGED
@@ -13,7 +13,19 @@ jobs:
13
13
  steps:
14
14
  - checkout
15
15
  - run: bundle install && bundle exec rspec
16
-
16
+ publish: &publish
17
+ docker:
18
+ - image: ruby:2.6
19
+ steps:
20
+ - checkout
21
+ - run: |
22
+ mkdir -p $HOME/.gem
23
+ touch $HOME/.gem/credentials
24
+ chmod 0600 $HOME/.gem/credentials
25
+ printf -- "---\n:rubygems_api_key: $RUBYGEM_PUBLISH_API_KEY\n" > $HOME/.gem/credentials
26
+ gem build *.gemspec
27
+ gem push *.gem
28
+
17
29
  workflows:
18
30
  version: 2
19
31
  tests:
@@ -30,3 +42,10 @@ workflows:
30
42
  ruby-version: "2.2"
31
43
  - faraday-version: "0.9.2"
32
44
  ruby-version: "3.0"
45
+ - publish:
46
+ filters:
47
+ branches:
48
+ only:
49
+ - master
50
+ requires:
51
+ - test
@@ -34,6 +34,10 @@ module GoCardlessPro
34
34
  @headers = options[:default_headers] || {}
35
35
  @headers['Authorization'] = "Bearer #{token}"
36
36
  @on_idempotency_conflict = options[:on_idempotency_conflict] || :fetch
37
+
38
+ unless %i[fetch raise].include?(@on_idempotency_conflict)
39
+ raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
40
+ end
37
41
  end
38
42
 
39
43
  # Make a request to the API
@@ -23,6 +23,16 @@ module GoCardlessPro
23
23
  @billing_request_flows ||= Services::BillingRequestFlowsService.new(@api_service)
24
24
  end
25
25
 
26
+ # Access to the service for billing_request_template to make API calls
27
+ def billing_request_templates
28
+ @billing_request_templates ||= Services::BillingRequestTemplatesService.new(@api_service)
29
+ end
30
+
31
+ # Access to the service for block to make API calls
32
+ def blocks
33
+ @blocks ||= Services::BlocksService.new(@api_service)
34
+ end
35
+
26
36
  # Access to the service for creditor to make API calls
27
37
  def creditors
28
38
  @creditors ||= Services::CreditorsService.new(@api_service)
@@ -188,7 +198,7 @@ module GoCardlessPro
188
198
  'User-Agent' => user_agent.to_s,
189
199
  'Content-Type' => 'application/json',
190
200
  'GoCardless-Client-Library' => 'gocardless-pro-ruby',
191
- 'GoCardless-Client-Version' => '2.27.0',
201
+ 'GoCardless-Client-Version' => '2.30.0',
192
202
  },
193
203
  }
194
204
  end
@@ -0,0 +1,4 @@
1
+ module GoCardlessPro
2
+ class AuthenticationError < InvalidApiUsageError
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module GoCardlessPro
2
+ class PermissionError < InvalidApiUsageError
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module GoCardlessPro
2
+ class RateLimitError < InvalidApiUsageError
3
+ end
4
+ end
@@ -12,12 +12,23 @@ module GoCardlessPro
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
- raise(error_class_for_type(error_type), json_body['error'])
15
+
16
+ error_class = error_class_for_status(env.status) || error_class_for_type(error_type)
17
+
18
+ raise(error_class, json_body['error'])
16
19
  end
17
20
  end
18
21
 
19
22
  private
20
23
 
24
+ def error_class_for_status(code)
25
+ {
26
+ 401 => GoCardlessPro::AuthenticationError,
27
+ 403 => GoCardlessPro::PermissionError,
28
+ 429 => GoCardlessPro::RateLimitError,
29
+ }.fetch(code, nil)
30
+ end
31
+
21
32
  def error_class_for_type(type)
22
33
  {
23
34
  validation_failed: GoCardlessPro::ValidationError,
@@ -21,17 +21,15 @@ module GoCardlessPro
21
21
  # Creation of Bank Authorisations is only permitted from GoCardless hosted
22
22
  # UIs
23
23
  # (see Billing Request Flows) to ensure we meet regulatory requirements for
24
- # checkout flows. The exceptions are integrators with the custom payment
25
- # pages
26
- # upgrade, who have been audited to check their flows meet requirements.
24
+ # checkout flows.
27
25
  class BankAuthorisation
28
26
  attr_reader :authorisation_type
27
+ attr_reader :authorised_at
29
28
  attr_reader :created_at
30
29
  attr_reader :expires_at
31
30
  attr_reader :id
32
31
  attr_reader :last_visited_at
33
32
  attr_reader :redirect_uri
34
- attr_reader :short_url
35
33
  attr_reader :url
36
34
 
37
35
  # Initialize a bank_authorisation resource instance
@@ -40,13 +38,13 @@ module GoCardlessPro
40
38
  @object = object
41
39
 
42
40
  @authorisation_type = object['authorisation_type']
41
+ @authorised_at = object['authorised_at']
43
42
  @created_at = object['created_at']
44
43
  @expires_at = object['expires_at']
45
44
  @id = object['id']
46
45
  @last_visited_at = object['last_visited_at']
47
46
  @links = object['links']
48
47
  @redirect_uri = object['redirect_uri']
49
- @short_url = object['short_url']
50
48
  @url = object['url']
51
49
  @response = response
52
50
  end
@@ -77,10 +75,6 @@ module GoCardlessPro
77
75
  def institution
78
76
  @links['institution']
79
77
  end
80
-
81
- def payment_request
82
- @links['payment_request']
83
- end
84
78
  end
85
79
  end
86
80
  end
@@ -12,11 +12,19 @@ module GoCardlessPro
12
12
  module Resources
13
13
  # Represents an instance of a billing_request resource returned from the API
14
14
 
15
- # Billing Requests
15
+ # Billing Requests help create resources that require input or action from a
16
+ # customer. An example of required input might be additional customer
17
+ # billing
18
+ # details, while an action would be asking a customer to authorise a payment
19
+ # using their mobile banking app.
20
+ #
21
+ # See [Billing Requests:
22
+ # Overview](https://developer.gocardless.com/getting-started/billing-requests/overview/)
23
+ # for how-to's, explanations and tutorials.
16
24
  class BillingRequest
17
25
  attr_reader :actions
18
- attr_reader :auto_fulfil
19
26
  attr_reader :created_at
27
+ attr_reader :fallback_enabled
20
28
  attr_reader :id
21
29
  attr_reader :mandate_request
22
30
  attr_reader :metadata
@@ -30,8 +38,8 @@ module GoCardlessPro
30
38
  @object = object
31
39
 
32
40
  @actions = object['actions']
33
- @auto_fulfil = object['auto_fulfil']
34
41
  @created_at = object['created_at']
42
+ @fallback_enabled = object['fallback_enabled']
35
43
  @id = object['id']
36
44
  @links = object['links']
37
45
  @mandate_request = object['mandate_request']
@@ -61,6 +69,14 @@ module GoCardlessPro
61
69
  @links = links || {}
62
70
  end
63
71
 
72
+ def bank_authorisation
73
+ @links['bank_authorisation']
74
+ end
75
+
76
+ def creditor
77
+ @links['creditor']
78
+ end
79
+
64
80
  def customer
65
81
  @links['customer']
66
82
  end
@@ -73,12 +89,20 @@ module GoCardlessPro
73
89
  @links['customer_billing_detail']
74
90
  end
75
91
 
76
- def mandate_bank_authorisation
77
- @links['mandate_bank_authorisation']
92
+ def mandate_request
93
+ @links['mandate_request']
94
+ end
95
+
96
+ def mandate_request_mandate
97
+ @links['mandate_request_mandate']
98
+ end
99
+
100
+ def payment_request
101
+ @links['payment_request']
78
102
  end
79
103
 
80
- def payment_bank_authorisation
81
- @links['payment_bank_authorisation']
104
+ def payment_request_payment
105
+ @links['payment_request_payment']
82
106
  end
83
107
  end
84
108
  end
@@ -17,9 +17,16 @@ module GoCardlessPro
17
17
  # authorisation (such as open banking single payments).
18
18
  class BillingRequestFlow
19
19
  attr_reader :authorisation_url
20
+ attr_reader :auto_fulfil
20
21
  attr_reader :created_at
22
+ attr_reader :exit_uri
21
23
  attr_reader :expires_at
24
+ attr_reader :id
25
+ attr_reader :lock_bank_account
26
+ attr_reader :lock_customer_details
22
27
  attr_reader :redirect_uri
28
+ attr_reader :session_token
29
+ attr_reader :show_redirect_buttons
23
30
 
24
31
  # Initialize a billing_request_flow resource instance
25
32
  # @param object [Hash] an object returned from the API
@@ -27,10 +34,17 @@ module GoCardlessPro
27
34
  @object = object
28
35
 
29
36
  @authorisation_url = object['authorisation_url']
37
+ @auto_fulfil = object['auto_fulfil']
30
38
  @created_at = object['created_at']
39
+ @exit_uri = object['exit_uri']
31
40
  @expires_at = object['expires_at']
41
+ @id = object['id']
32
42
  @links = object['links']
43
+ @lock_bank_account = object['lock_bank_account']
44
+ @lock_customer_details = object['lock_customer_details']
33
45
  @redirect_uri = object['redirect_uri']
46
+ @session_token = object['session_token']
47
+ @show_redirect_buttons = object['show_redirect_buttons']
34
48
  @response = response
35
49
  end
36
50
 
@@ -0,0 +1,68 @@
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 billing_request_template resource returned from the API
14
+
15
+ # Billing Request Templates
16
+ class BillingRequestTemplate
17
+ attr_reader :authorisation_url
18
+ attr_reader :created_at
19
+ attr_reader :id
20
+ attr_reader :mandate_request_currency
21
+ attr_reader :mandate_request_metadata
22
+ attr_reader :mandate_request_scheme
23
+ attr_reader :mandate_request_verify
24
+ attr_reader :metadata
25
+ attr_reader :name
26
+ attr_reader :payment_request_amount
27
+ attr_reader :payment_request_currency
28
+ attr_reader :payment_request_description
29
+ attr_reader :payment_request_metadata
30
+ attr_reader :payment_request_scheme
31
+ attr_reader :redirect_uri
32
+ attr_reader :updated_at
33
+
34
+ # Initialize a billing_request_template resource instance
35
+ # @param object [Hash] an object returned from the API
36
+ def initialize(object, response = nil)
37
+ @object = object
38
+
39
+ @authorisation_url = object['authorisation_url']
40
+ @created_at = object['created_at']
41
+ @id = object['id']
42
+ @mandate_request_currency = object['mandate_request_currency']
43
+ @mandate_request_metadata = object['mandate_request_metadata']
44
+ @mandate_request_scheme = object['mandate_request_scheme']
45
+ @mandate_request_verify = object['mandate_request_verify']
46
+ @metadata = object['metadata']
47
+ @name = object['name']
48
+ @payment_request_amount = object['payment_request_amount']
49
+ @payment_request_currency = object['payment_request_currency']
50
+ @payment_request_description = object['payment_request_description']
51
+ @payment_request_metadata = object['payment_request_metadata']
52
+ @payment_request_scheme = object['payment_request_scheme']
53
+ @redirect_uri = object['redirect_uri']
54
+ @updated_at = object['updated_at']
55
+ @response = response
56
+ end
57
+
58
+ def api_response
59
+ ApiResponse.new(@response)
60
+ end
61
+
62
+ # Provides the billing_request_template resource as a hash of all its readable attributes
63
+ def to_h
64
+ @object
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,76 @@
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 block resource returned from the API
14
+
15
+ # Blocks are created to prevent certain customer details from being used
16
+ # when creating
17
+ # mandates.
18
+ #
19
+ # The details used to create blocks can be exact matches, like a bank
20
+ # account or an email,
21
+ # or a more generic match such as an email domain. New block types may be
22
+ # added over time.
23
+ #
24
+ # A block object is in essence a simple rule that is used to match against
25
+ # details in a
26
+ # newly created mandate. If there is a successful match then the mandate is
27
+ # transitioned
28
+ # to a "blocked" state.
29
+ #
30
+ # Payments and subscriptions cannot be created against a mandate in blocked
31
+ # state.
32
+ #
33
+ # A mandate can never be transitioned out of the blocked state.
34
+ #
35
+ # <p class="notice">
36
+ # This API is currently only available for approved integrators - please
37
+ # <a href="mailto:help@gocardless.com">get in touch</a> if you would like to
38
+ # use this API.
39
+ # </p>
40
+ class Block
41
+ attr_reader :active
42
+ attr_reader :block_type
43
+ attr_reader :created_at
44
+ attr_reader :id
45
+ attr_reader :reason_description
46
+ attr_reader :reason_type
47
+ attr_reader :resource_reference
48
+ attr_reader :updated_at
49
+
50
+ # Initialize a block resource instance
51
+ # @param object [Hash] an object returned from the API
52
+ def initialize(object, response = nil)
53
+ @object = object
54
+
55
+ @active = object['active']
56
+ @block_type = object['block_type']
57
+ @created_at = object['created_at']
58
+ @id = object['id']
59
+ @reason_description = object['reason_description']
60
+ @reason_type = object['reason_type']
61
+ @resource_reference = object['resource_reference']
62
+ @updated_at = object['updated_at']
63
+ @response = response
64
+ end
65
+
66
+ def api_response
67
+ ApiResponse.new(@response)
68
+ end
69
+
70
+ # Provides the block resource as a hash of all its readable attributes
71
+ def to_h
72
+ @object
73
+ end
74
+ end
75
+ end
76
+ end
@@ -60,6 +60,18 @@ module GoCardlessPro
60
60
  @links = links || {}
61
61
  end
62
62
 
63
+ def bank_authorisation
64
+ @links['bank_authorisation']
65
+ end
66
+
67
+ def billing_request
68
+ @links['billing_request']
69
+ end
70
+
71
+ def billing_request_flow
72
+ @links['billing_request_flow']
73
+ end
74
+
63
75
  def creditor
64
76
  @links['creditor']
65
77
  end
@@ -80,6 +92,10 @@ module GoCardlessPro
80
92
  @links['mandate']
81
93
  end
82
94
 
95
+ def mandate_request_mandate
96
+ @links['mandate_request_mandate']
97
+ end
98
+
83
99
  def new_customer_bank_account
84
100
  @links['new_customer_bank_account']
85
101
  end
@@ -104,6 +120,10 @@ module GoCardlessPro
104
120
  @links['payment']
105
121
  end
106
122
 
123
+ def payment_request_payment
124
+ @links['payment_request_payment']
125
+ end
126
+
107
127
  def payout
108
128
  @links['payout']
109
129
  end
@@ -13,8 +13,13 @@ module GoCardlessPro
13
13
  # Represents an instance of a institution resource returned from the API
14
14
 
15
15
  # Institutions that are supported when creating [Bank
16
- # Authorisations](#billing-requests-bank-authorisations).
16
+ # Authorisations](#billing-requests-bank-authorisations) for a particular
17
+ # country or purpose.
18
+ #
19
+ # Not all institutions support both Payment Initiation (PIS) and Account
20
+ # Information (AIS) services.
17
21
  class Institution
22
+ attr_reader :country_code
18
23
  attr_reader :icon_url
19
24
  attr_reader :id
20
25
  attr_reader :logo_url
@@ -25,6 +30,7 @@ module GoCardlessPro
25
30
  def initialize(object, response = nil)
26
31
  @object = object
27
32
 
33
+ @country_code = object['country_code']
28
34
  @icon_url = object['icon_url']
29
35
  @id = object['id']
30
36
  @logo_url = object['logo_url']
@@ -12,6 +12,15 @@ module GoCardlessPro
12
12
  module Resources
13
13
  # Represents an instance of a payer_authorisation resource returned from the API
14
14
 
15
+ # <p class="restricted-notice">
16
+ # Don't use Payer Authorisations for new integrations.
17
+ # It is deprecated in favour of
18
+ # <a
19
+ # href="https://developer.gocardless.com/getting-started/billing-requests/overview/">
20
+ # Billing Requests</a>. Use Billing Requests to build any future
21
+ # integrations.
22
+ # </p>
23
+ #
15
24
  # Payer Authorisation resource acts as a wrapper for creating customer, bank
16
25
  # account and mandate details in a single request.
17
26
  # PayerAuthorisation API enables the integrators to build their own custom
@@ -49,6 +49,7 @@ module GoCardlessPro
49
49
  attr_reader :created_at
50
50
  attr_reader :description
51
51
  attr_reader :id
52
+ attr_reader :mandate_reference
52
53
  attr_reader :metadata
53
54
  attr_reader :redirect_url
54
55
  attr_reader :scheme
@@ -65,6 +66,7 @@ module GoCardlessPro
65
66
  @description = object['description']
66
67
  @id = object['id']
67
68
  @links = object['links']
69
+ @mandate_reference = object['mandate_reference']
68
70
  @metadata = object['metadata']
69
71
  @redirect_url = object['redirect_url']
70
72
  @scheme = object['scheme']
@@ -92,6 +94,10 @@ module GoCardlessPro
92
94
  @links = links || {}
93
95
  end
94
96
 
97
+ def billing_request
98
+ @links['billing_request']
99
+ end
100
+
95
101
  def creditor
96
102
  @links['creditor']
97
103
  end
@@ -51,8 +51,6 @@ module GoCardlessPro
51
51
  raise IdempotencyConflict, e.error
52
52
  when :fetch
53
53
  return get(e.conflicting_resource_id)
54
- else
55
- raise ArgumentError, 'Unknown mode for :on_idempotency_conflict'
56
54
  end
57
55
  end
58
56
 
@@ -29,6 +29,29 @@ module GoCardlessPro
29
29
  Resources::BillingRequestFlow.new(unenvelope_body(response.body), response)
30
30
  end
31
31
 
32
+ # Returns the flow having generated a fresh session token which can be used to
33
+ # power
34
+ # integrations that manipulate the flow.
35
+ # Example URL: /billing_request_flows/:identity/actions/initialise
36
+ #
37
+ # @param identity # Unique identifier, beginning with "BRF".
38
+ # @param options [Hash] parameters as a hash, under a params key.
39
+ def initialise(identity, options = {})
40
+ path = sub_url('/billing_request_flows/:identity/actions/initialise', 'identity' => identity)
41
+
42
+ params = options.delete(:params) || {}
43
+ options[:params] = {}
44
+ options[:params]['data'] = params
45
+
46
+ options[:retry_failures] = false
47
+
48
+ response = make_request(:post, path, options)
49
+
50
+ return if response.body.nil?
51
+
52
+ Resources::BillingRequestFlow.new(unenvelope_body(response.body), response)
53
+ end
54
+
32
55
  private
33
56
 
34
57
  # Unenvelope the response of the body using the service's `envelope_key`