gocardless_pro 2.23.0 → 2.28.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +23 -4
  3. data/lib/gocardless_pro.rb +27 -0
  4. data/lib/gocardless_pro/api_service.rb +4 -0
  5. data/lib/gocardless_pro/client.rb +41 -1
  6. data/lib/gocardless_pro/error/authentication_error.rb +4 -0
  7. data/lib/gocardless_pro/error/permission_error.rb +4 -0
  8. data/lib/gocardless_pro/error/rate_limit_error.rb +4 -0
  9. data/lib/gocardless_pro/middlewares/raise_gocardless_errors.rb +12 -1
  10. data/lib/gocardless_pro/resources/bank_authorisation.rb +85 -0
  11. data/lib/gocardless_pro/resources/billing_request.rb +108 -0
  12. data/lib/gocardless_pro/resources/billing_request_flow.rb +72 -0
  13. data/lib/gocardless_pro/resources/billing_request_template.rb +68 -0
  14. data/lib/gocardless_pro/resources/creditor.rb +2 -3
  15. data/lib/gocardless_pro/resources/event.rb +12 -0
  16. data/lib/gocardless_pro/resources/institution.rb +45 -0
  17. data/lib/gocardless_pro/resources/payer_authorisation.rb +131 -0
  18. data/lib/gocardless_pro/resources/payout_item.rb +4 -0
  19. data/lib/gocardless_pro/resources/scenario_simulator.rb +42 -0
  20. data/lib/gocardless_pro/resources/tax_rate.rb +3 -0
  21. data/lib/gocardless_pro/resources/webhook.rb +62 -0
  22. data/lib/gocardless_pro/services/bank_authorisations_service.rb +80 -0
  23. data/lib/gocardless_pro/services/billing_request_flows_service.rb +70 -0
  24. data/lib/gocardless_pro/services/billing_request_templates_service.rb +131 -0
  25. data/lib/gocardless_pro/services/billing_requests_service.rb +352 -0
  26. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +0 -4
  27. data/lib/gocardless_pro/services/creditors_service.rb +0 -2
  28. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +0 -4
  29. data/lib/gocardless_pro/services/customers_service.rb +0 -2
  30. data/lib/gocardless_pro/services/instalment_schedules_service.rb +0 -6
  31. data/lib/gocardless_pro/services/institutions_service.rb +56 -0
  32. data/lib/gocardless_pro/services/mandate_imports_service.rb +0 -6
  33. data/lib/gocardless_pro/services/mandates_service.rb +0 -6
  34. data/lib/gocardless_pro/services/payer_authorisations_service.rb +202 -0
  35. data/lib/gocardless_pro/services/payments_service.rb +0 -6
  36. data/lib/gocardless_pro/services/redirect_flows_service.rb +0 -4
  37. data/lib/gocardless_pro/services/refunds_service.rb +0 -2
  38. data/lib/gocardless_pro/services/scenario_simulators_service.rb +170 -0
  39. data/lib/gocardless_pro/services/subscriptions_service.rb +10 -13
  40. data/lib/gocardless_pro/services/webhooks_service.rb +111 -0
  41. data/lib/gocardless_pro/version.rb +1 -1
  42. data/spec/api_service_spec.rb +12 -1
  43. data/spec/middlewares/raise_gocardless_errors_spec.rb +30 -0
  44. data/spec/resources/bank_authorisation_spec.rb +259 -0
  45. data/spec/resources/billing_request_flow_spec.rb +219 -0
  46. data/spec/resources/billing_request_spec.rb +782 -0
  47. data/spec/resources/billing_request_template_spec.rb +502 -0
  48. data/spec/resources/institution_spec.rb +103 -0
  49. data/spec/resources/payer_authorisation_spec.rb +418 -0
  50. data/spec/resources/scenario_simulator_spec.rb +63 -0
  51. data/spec/resources/webhook_spec.rb +323 -0
  52. data/spec/services/bank_authorisations_service_spec.rb +353 -0
  53. data/spec/services/billing_request_flows_service_spec.rb +253 -0
  54. data/spec/services/billing_request_templates_service_spec.rb +789 -0
  55. data/spec/services/billing_requests_service_spec.rb +1082 -0
  56. data/spec/services/creditor_bank_accounts_service_spec.rb +0 -13
  57. data/spec/services/creditors_service_spec.rb +0 -13
  58. data/spec/services/customer_bank_accounts_service_spec.rb +0 -13
  59. data/spec/services/customers_service_spec.rb +0 -13
  60. data/spec/services/instalment_schedules_service_spec.rb +0 -26
  61. data/spec/services/institutions_service_spec.rb +223 -0
  62. data/spec/services/mandate_imports_service_spec.rb +0 -13
  63. data/spec/services/mandates_service_spec.rb +0 -13
  64. data/spec/services/payer_authorisations_service_spec.rb +559 -0
  65. data/spec/services/payments_service_spec.rb +0 -13
  66. data/spec/services/redirect_flows_service_spec.rb +0 -13
  67. data/spec/services/refunds_service_spec.rb +0 -13
  68. data/spec/services/scenario_simulators_service_spec.rb +74 -0
  69. data/spec/services/subscriptions_service_spec.rb +0 -13
  70. data/spec/services/webhooks_service_spec.rb +545 -0
  71. metadata +54 -3
@@ -0,0 +1,72 @@
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_flow resource returned from the API
14
+
15
+ # Billing Request Flows can be created to enable a payer to authorise a
16
+ # payment created for a scheme with strong payer
17
+ # authorisation (such as open banking single payments).
18
+ class BillingRequestFlow
19
+ attr_reader :authorisation_url
20
+ attr_reader :auto_fulfil
21
+ attr_reader :created_at
22
+ attr_reader :expires_at
23
+ attr_reader :id
24
+ attr_reader :lock_bank_account
25
+ attr_reader :lock_customer_details
26
+ attr_reader :redirect_uri
27
+ attr_reader :session_token
28
+
29
+ # Initialize a billing_request_flow resource instance
30
+ # @param object [Hash] an object returned from the API
31
+ def initialize(object, response = nil)
32
+ @object = object
33
+
34
+ @authorisation_url = object['authorisation_url']
35
+ @auto_fulfil = object['auto_fulfil']
36
+ @created_at = object['created_at']
37
+ @expires_at = object['expires_at']
38
+ @id = object['id']
39
+ @links = object['links']
40
+ @lock_bank_account = object['lock_bank_account']
41
+ @lock_customer_details = object['lock_customer_details']
42
+ @redirect_uri = object['redirect_uri']
43
+ @session_token = object['session_token']
44
+ @response = response
45
+ end
46
+
47
+ def api_response
48
+ ApiResponse.new(@response)
49
+ end
50
+
51
+ # Return the links that the resource has
52
+ def links
53
+ @billing_request_flow_links ||= Links.new(@links)
54
+ end
55
+
56
+ # Provides the billing_request_flow resource as a hash of all its readable attributes
57
+ def to_h
58
+ @object
59
+ end
60
+
61
+ class Links
62
+ def initialize(links)
63
+ @links = links || {}
64
+ end
65
+
66
+ def billing_request
67
+ @links['billing_request']
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -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
@@ -17,9 +17,8 @@ module GoCardlessPro
17
17
  # organisation will have a single "creditor", but the API also supports
18
18
  # collecting payments on behalf of others.
19
19
  #
20
- # Please get in touch if you wish to use this endpoint. Currently, for Anti
21
- # Money Laundering reasons, any creditors you add must be directly related
22
- # to your organisation.
20
+ # Currently, for Anti Money Laundering reasons, any creditors you add must
21
+ # be directly related to your organisation.
23
22
  class Creditor
24
23
  attr_reader :address_line1
25
24
  attr_reader :address_line2
@@ -64,6 +64,14 @@ module GoCardlessPro
64
64
  @links['creditor']
65
65
  end
66
66
 
67
+ def customer
68
+ @links['customer']
69
+ end
70
+
71
+ def customer_bank_account
72
+ @links['customer_bank_account']
73
+ end
74
+
67
75
  def instalment_schedule
68
76
  @links['instalment_schedule']
69
77
  end
@@ -88,6 +96,10 @@ module GoCardlessPro
88
96
  @links['parent_event']
89
97
  end
90
98
 
99
+ def payer_authorisation
100
+ @links['payer_authorisation']
101
+ end
102
+
91
103
  def payment
92
104
  @links['payment']
93
105
  end
@@ -0,0 +1,45 @@
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 institution resource returned from the API
14
+
15
+ # Institutions that are supported when creating [Bank
16
+ # Authorisations](#billing-requests-bank-authorisations).
17
+ class Institution
18
+ attr_reader :icon_url
19
+ attr_reader :id
20
+ attr_reader :logo_url
21
+ attr_reader :name
22
+
23
+ # Initialize a institution resource instance
24
+ # @param object [Hash] an object returned from the API
25
+ def initialize(object, response = nil)
26
+ @object = object
27
+
28
+ @icon_url = object['icon_url']
29
+ @id = object['id']
30
+ @logo_url = object['logo_url']
31
+ @name = object['name']
32
+ @response = response
33
+ end
34
+
35
+ def api_response
36
+ ApiResponse.new(@response)
37
+ end
38
+
39
+ # Provides the institution resource as a hash of all its readable attributes
40
+ def to_h
41
+ @object
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,131 @@
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 payer_authorisation resource returned from the API
14
+
15
+ # <p class="restricted-notice">
16
+ # Payer Authorisations is deprecated in favour of
17
+ # <a
18
+ # href="https://developer.gocardless.com/getting-started/billing-requests/overview/">
19
+ # Billing Requests</a>. Please consider using Billing Requests to build
20
+ # any
21
+ # future integrations.
22
+ # </p>
23
+ #
24
+ # Payer Authorisation resource acts as a wrapper for creating customer, bank
25
+ # account and mandate details in a single request.
26
+ # PayerAuthorisation API enables the integrators to build their own custom
27
+ # payment pages.
28
+ #
29
+ # The process to use the Payer Authorisation API is as follows:
30
+ #
31
+ # 1. Create a Payer Authorisation, either empty or with already available
32
+ # information
33
+ # 2. Update the authorisation with additional information or fix any
34
+ # mistakes
35
+ # 3. Submit the authorisation, after the payer has reviewed their
36
+ # information
37
+ # 4. [coming soon] Redirect the payer to the verification mechanisms from
38
+ # the response of the Submit request (this will be introduced as a
39
+ # non-breaking change)
40
+ # 5. Confirm the authorisation to indicate that the resources can be
41
+ # created
42
+ #
43
+ # After the Payer Authorisation is confirmed, resources will eventually be
44
+ # created as it's an asynchronous process.
45
+ #
46
+ # To retrieve the status and ID of the linked resources you can do one of
47
+ # the following:
48
+ # <ol>
49
+ # <li> Listen to <code> payer_authorisation_completed </code> <a
50
+ # href="#appendix-webhooks"> webhook</a> (recommended)</li>
51
+ # <li> Poll the GET <a
52
+ # href="#payer-authorisations-get-a-single-payer-authorisation">
53
+ # endpoint</a></li>
54
+ # <li> Poll the GET events API
55
+ # <code>https://api.gocardless.com/events?payer_authorisation={id}&action=completed</code>
56
+ # </li>
57
+ # </ol>
58
+ #
59
+ # <p class="notice">
60
+ # Note that the `create` and `update` endpoints behave differently than
61
+ # other existing `create` and `update` endpoints. The Payer Authorisation
62
+ # is still saved if incomplete data is provided.
63
+ # We return the list of incomplete data in the `incomplete_fields` along
64
+ # with the resources in the body of the response.
65
+ # The bank account details(account_number, bank_code & branch_code) must
66
+ # be sent together rather than splitting across different request for both
67
+ # `create` and `update` endpoints.
68
+ # <br><br>
69
+ # The API is designed to be flexible and allows you to collect information
70
+ # in multiple steps without storing any sensitive data in the browser or in
71
+ # your servers.
72
+ # </p>
73
+ class PayerAuthorisation
74
+ attr_reader :bank_account
75
+ attr_reader :created_at
76
+ attr_reader :customer
77
+ attr_reader :id
78
+ attr_reader :incomplete_fields
79
+ attr_reader :mandate
80
+ attr_reader :status
81
+
82
+ # Initialize a payer_authorisation resource instance
83
+ # @param object [Hash] an object returned from the API
84
+ def initialize(object, response = nil)
85
+ @object = object
86
+
87
+ @bank_account = object['bank_account']
88
+ @created_at = object['created_at']
89
+ @customer = object['customer']
90
+ @id = object['id']
91
+ @incomplete_fields = object['incomplete_fields']
92
+ @links = object['links']
93
+ @mandate = object['mandate']
94
+ @status = object['status']
95
+ @response = response
96
+ end
97
+
98
+ def api_response
99
+ ApiResponse.new(@response)
100
+ end
101
+
102
+ # Return the links that the resource has
103
+ def links
104
+ @payer_authorisation_links ||= Links.new(@links)
105
+ end
106
+
107
+ # Provides the payer_authorisation resource as a hash of all its readable attributes
108
+ def to_h
109
+ @object
110
+ end
111
+
112
+ class Links
113
+ def initialize(links)
114
+ @links = links || {}
115
+ end
116
+
117
+ def bank_account
118
+ @links['bank_account']
119
+ end
120
+
121
+ def customer
122
+ @links['customer']
123
+ end
124
+
125
+ def mandate
126
+ @links['mandate']
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -73,6 +73,10 @@ module GoCardlessPro
73
73
  def payment
74
74
  @links['payment']
75
75
  end
76
+
77
+ def refund
78
+ @links['refund']
79
+ end
76
80
  end
77
81
  end
78
82
  end
@@ -0,0 +1,42 @@
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 scenario_simulator resource returned from the API
14
+
15
+ # Scenario Simulators allow you to manually trigger and test certain paths
16
+ # that your
17
+ # integration will encounter in the real world. These endpoints are only
18
+ # active in the
19
+ # sandbox environment.
20
+ class ScenarioSimulator
21
+ attr_reader :id
22
+
23
+ # Initialize a scenario_simulator resource instance
24
+ # @param object [Hash] an object returned from the API
25
+ def initialize(object, response = nil)
26
+ @object = object
27
+
28
+ @id = object['id']
29
+ @response = response
30
+ end
31
+
32
+ def api_response
33
+ ApiResponse.new(@response)
34
+ end
35
+
36
+ # Provides the scenario_simulator resource as a hash of all its readable attributes
37
+ def to_h
38
+ @object
39
+ end
40
+ end
41
+ end
42
+ end
@@ -13,6 +13,9 @@ module GoCardlessPro
13
13
  # Represents an instance of a tax_rate resource returned from the API
14
14
 
15
15
  # Tax rates from tax authority.
16
+ #
17
+ # We also maintain a [static list of the tax rates for each
18
+ # jurisdiction](#appendix-tax-rates).
16
19
  class TaxRate
17
20
  attr_reader :end_date
18
21
  attr_reader :id
@@ -0,0 +1,62 @@
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 webhook resource returned from the API
14
+
15
+ # Basic description of a webhook
16
+ class Webhook
17
+ attr_reader :created_at
18
+ attr_reader :id
19
+ attr_reader :is_test
20
+ attr_reader :request_body
21
+ attr_reader :request_headers
22
+ attr_reader :response_body
23
+ attr_reader :response_body_truncated
24
+ attr_reader :response_code
25
+ attr_reader :response_headers
26
+ attr_reader :response_headers_content_truncated
27
+ attr_reader :response_headers_count_truncated
28
+ attr_reader :successful
29
+ attr_reader :url
30
+
31
+ # Initialize a webhook resource instance
32
+ # @param object [Hash] an object returned from the API
33
+ def initialize(object, response = nil)
34
+ @object = object
35
+
36
+ @created_at = object['created_at']
37
+ @id = object['id']
38
+ @is_test = object['is_test']
39
+ @request_body = object['request_body']
40
+ @request_headers = object['request_headers']
41
+ @response_body = object['response_body']
42
+ @response_body_truncated = object['response_body_truncated']
43
+ @response_code = object['response_code']
44
+ @response_headers = object['response_headers']
45
+ @response_headers_content_truncated = object['response_headers_content_truncated']
46
+ @response_headers_count_truncated = object['response_headers_count_truncated']
47
+ @successful = object['successful']
48
+ @url = object['url']
49
+ @response = response
50
+ end
51
+
52
+ def api_response
53
+ ApiResponse.new(@response)
54
+ end
55
+
56
+ # Provides the webhook resource as a hash of all its readable attributes
57
+ def to_h
58
+ @object
59
+ end
60
+ end
61
+ end
62
+ end