gocardless_pro 1.0.5 → 1.1.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -2
  3. data/lib/gocardless_pro/api_service.rb +3 -3
  4. data/lib/gocardless_pro/resources/bank_details_lookup.rb +8 -10
  5. data/lib/gocardless_pro/resources/creditor.rb +36 -42
  6. data/lib/gocardless_pro/resources/creditor_bank_account.rb +24 -38
  7. data/lib/gocardless_pro/resources/customer.rb +12 -27
  8. data/lib/gocardless_pro/resources/customer_bank_account.rb +26 -39
  9. data/lib/gocardless_pro/resources/event.rb +49 -40
  10. data/lib/gocardless_pro/resources/mandate.rb +33 -35
  11. data/lib/gocardless_pro/resources/mandate_pdf.rb +10 -11
  12. data/lib/gocardless_pro/resources/payment.rb +34 -42
  13. data/lib/gocardless_pro/resources/payout.rb +23 -34
  14. data/lib/gocardless_pro/resources/redirect_flow.rb +49 -54
  15. data/lib/gocardless_pro/resources/refund.rb +24 -39
  16. data/lib/gocardless_pro/resources/subscription.rb +65 -84
  17. data/lib/gocardless_pro/services/bank_details_lookups_service.rb +6 -5
  18. data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +7 -6
  19. data/lib/gocardless_pro/services/creditors_service.rb +7 -6
  20. data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +11 -10
  21. data/lib/gocardless_pro/services/customers_service.rb +7 -6
  22. data/lib/gocardless_pro/services/events_service.rb +8 -6
  23. data/lib/gocardless_pro/services/mandate_pdfs_service.rb +6 -5
  24. data/lib/gocardless_pro/services/mandates_service.rb +7 -6
  25. data/lib/gocardless_pro/services/payments_service.rb +7 -6
  26. data/lib/gocardless_pro/services/payouts_service.rb +7 -6
  27. data/lib/gocardless_pro/services/redirect_flows_service.rb +6 -5
  28. data/lib/gocardless_pro/services/refunds_service.rb +7 -6
  29. data/lib/gocardless_pro/services/subscriptions_service.rb +7 -6
  30. data/lib/gocardless_pro/version.rb +1 -1
  31. data/lib/gocardless_pro.rb +2 -3
  32. data/spec/resources/creditor_spec.rb +9 -1
  33. data/spec/resources/event_spec.rb +4 -0
  34. data/spec/resources/mandate_spec.rb +9 -1
  35. data/spec/resources/subscription_spec.rb +0 -4
  36. data/spec/services/creditor_bank_accounts_service_spec.rb +8 -0
  37. data/spec/services/creditors_service_spec.rb +39 -9
  38. data/spec/services/customer_bank_accounts_service_spec.rb +8 -0
  39. data/spec/services/customers_service_spec.rb +8 -0
  40. data/spec/services/events_service_spec.rb +8 -0
  41. data/spec/services/mandates_service_spec.rb +8 -0
  42. data/spec/services/payments_service_spec.rb +8 -0
  43. data/spec/services/payouts_service_spec.rb +8 -0
  44. data/spec/services/redirect_flows_service_spec.rb +8 -0
  45. data/spec/services/refunds_service_spec.rb +8 -0
  46. data/spec/services/subscriptions_service_spec.rb +8 -13
  47. metadata +19 -19
@@ -1,39 +1,33 @@
1
-
2
-
3
1
  # encoding: utf-8
4
2
  #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
3
+ # This client is automatically generated from a template and JSON schema definition.
4
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
8
5
  #
6
+
9
7
  require 'uri'
10
8
 
11
9
  module GoCardlessPro
12
10
  # A module containing classes for each of the resources in the GC Api
13
11
  module Resources
12
+ # Represents an instance of a mandate resource returned from the API
13
+
14
14
  # Mandates represent the Direct Debit mandate with a
15
15
  # [customer](#core-endpoints-customers).
16
16
  #
17
- # GoCardless will notify you
18
- # via a [webhook](#webhooks) whenever the status of a mandate changes.
19
- # Represents an instance of a mandate resource returned from the API
17
+ # GoCardless will notify
18
+ # you via a [webhook](#appendix-webhooks) whenever the status of a mandate
19
+ # changes.
20
20
  class Mandate
21
21
  attr_reader :created_at
22
-
23
22
  attr_reader :id
24
-
25
23
  attr_reader :metadata
26
-
27
24
  attr_reader :next_possible_charge_date
28
-
29
25
  attr_reader :payments_require_approval
30
-
31
26
  attr_reader :reference
32
-
33
27
  attr_reader :scheme
34
-
35
28
  attr_reader :status
36
- # initialize a resource instance
29
+
30
+ # Initialize a mandate resource instance
37
31
  # @param object [Hash] an object returned from the API
38
32
  def initialize(object, response = nil)
39
33
  @object = object
@@ -54,32 +48,36 @@ module GoCardlessPro
54
48
  ApiResponse.new(@response)
55
49
  end
56
50
 
57
- # return the links that the resource has
51
+ # Return the links that the resource has
58
52
  def links
59
- valid_link_keys = %w(creditor customer_bank_account )
60
- valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
53
+ @links_links ||= Links.new(@links)
54
+ end
61
55
 
62
- links_class = Struct.new(
63
- *{
56
+ # Provides the mandate resource as a hash of all its readable attributes
57
+ def to_h
58
+ @object
59
+ end
64
60
 
65
- creditor: '',
61
+ class Links
62
+ def initialize(links)
63
+ @links = links
64
+ end
66
65
 
67
- customer_bank_account: ''
66
+ def creditor
67
+ @links['creditor']
68
+ end
68
69
 
69
- }.keys
70
- ) do
71
- def initialize(hash)
72
- hash.each do |key, val|
73
- send("#{key}=", val)
74
- end
75
- end
70
+ def customer
71
+ @links['customer']
76
72
  end
77
- links_class.new(valid_links)
78
- end
79
73
 
80
- # Provides the resource as a hash of all it's readable attributes
81
- def to_h
82
- @object
74
+ def customer_bank_account
75
+ @links['customer_bank_account']
76
+ end
77
+
78
+ def new_mandate
79
+ @links['new_mandate']
80
+ end
83
81
  end
84
82
  end
85
83
  end
@@ -1,25 +1,24 @@
1
-
2
-
3
1
  # encoding: utf-8
4
2
  #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
3
+ # This client is automatically generated from a template and JSON schema definition.
4
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
8
5
  #
6
+
9
7
  require 'uri'
10
8
 
11
9
  module GoCardlessPro
12
10
  # A module containing classes for each of the resources in the GC Api
13
11
  module Resources
14
- # Mandate PDFs allow you to easily display [scheme-rules
15
- # compliant](#appendix-compliance-requirements) Direct Debit mandates to your
16
- # customers.
17
12
  # Represents an instance of a mandate_pdf resource returned from the API
13
+
14
+ # Mandate PDFs allow you to easily display [scheme-rules
15
+ # compliant](#appendix-compliance-requirements) Direct Debit mandates to
16
+ # your customers.
18
17
  class MandatePdf
19
18
  attr_reader :expires_at
20
-
21
19
  attr_reader :url
22
- # initialize a resource instance
20
+
21
+ # Initialize a mandate_pdf resource instance
23
22
  # @param object [Hash] an object returned from the API
24
23
  def initialize(object, response = nil)
25
24
  @object = object
@@ -33,7 +32,7 @@ module GoCardlessPro
33
32
  ApiResponse.new(@response)
34
33
  end
35
34
 
36
- # Provides the resource as a hash of all it's readable attributes
35
+ # Provides the mandate_pdf resource as a hash of all its readable attributes
37
36
  def to_h
38
37
  @object
39
38
  end
@@ -1,45 +1,37 @@
1
-
2
-
3
1
  # encoding: utf-8
4
2
  #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
3
+ # This client is automatically generated from a template and JSON schema definition.
4
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
8
5
  #
6
+
9
7
  require 'uri'
10
8
 
11
9
  module GoCardlessPro
12
10
  # A module containing classes for each of the resources in the GC Api
13
11
  module Resources
12
+ # Represents an instance of a payment resource returned from the API
13
+
14
14
  # Payment objects represent payments from a
15
15
  # [customer](#core-endpoints-customers) to a
16
- # [creditor](#whitelabel-partner-endpoints-creditors), taken against a Direct
17
- # Debit [mandate](#core-endpoints-mandates).
16
+ # [creditor](#whitelabel-partner-endpoints-creditors), taken against a
17
+ # Direct Debit [mandate](#core-endpoints-mandates).
18
18
  #
19
- # GoCardless will notify
20
- # you via a [webhook](#webhooks) whenever the state of a payment changes.
21
- # Represents an instance of a payment resource returned from the API
19
+ # GoCardless
20
+ # will notify you via a [webhook](#appendix-webhooks) whenever the state of
21
+ # a payment changes.
22
22
  class Payment
23
23
  attr_reader :amount
24
-
25
24
  attr_reader :amount_refunded
26
-
27
25
  attr_reader :charge_date
28
-
29
26
  attr_reader :created_at
30
-
31
27
  attr_reader :currency
32
-
33
28
  attr_reader :description
34
-
35
29
  attr_reader :id
36
-
37
30
  attr_reader :metadata
38
-
39
31
  attr_reader :reference
40
-
41
32
  attr_reader :status
42
- # initialize a resource instance
33
+
34
+ # Initialize a payment resource instance
43
35
  # @param object [Hash] an object returned from the API
44
36
  def initialize(object, response = nil)
45
37
  @object = object
@@ -62,36 +54,36 @@ module GoCardlessPro
62
54
  ApiResponse.new(@response)
63
55
  end
64
56
 
65
- # return the links that the resource has
57
+ # Return the links that the resource has
66
58
  def links
67
- valid_link_keys = %w(creditor mandate payout subscription )
68
- valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
69
-
70
- links_class = Struct.new(
71
- *{
59
+ @links_links ||= Links.new(@links)
60
+ end
72
61
 
73
- creditor: '',
62
+ # Provides the payment resource as a hash of all its readable attributes
63
+ def to_h
64
+ @object
65
+ end
74
66
 
75
- mandate: '',
67
+ class Links
68
+ def initialize(links)
69
+ @links = links
70
+ end
76
71
 
77
- payout: '',
72
+ def creditor
73
+ @links['creditor']
74
+ end
78
75
 
79
- subscription: ''
76
+ def mandate
77
+ @links['mandate']
78
+ end
80
79
 
81
- }.keys
82
- ) do
83
- def initialize(hash)
84
- hash.each do |key, val|
85
- send("#{key}=", val)
86
- end
87
- end
80
+ def payout
81
+ @links['payout']
88
82
  end
89
- links_class.new(valid_links)
90
- end
91
83
 
92
- # Provides the resource as a hash of all it's readable attributes
93
- def to_h
94
- @object
84
+ def subscription
85
+ @links['subscription']
86
+ end
95
87
  end
96
88
  end
97
89
  end
@@ -1,39 +1,32 @@
1
-
2
-
3
1
  # encoding: utf-8
4
2
  #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
3
+ # This client is automatically generated from a template and JSON schema definition.
4
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
8
5
  #
6
+
9
7
  require 'uri'
10
8
 
11
9
  module GoCardlessPro
12
10
  # A module containing classes for each of the resources in the GC Api
13
11
  module Resources
12
+ # Represents an instance of a payout resource returned from the API
13
+
14
14
  # Payouts represent transfers from GoCardless to a
15
15
  # [creditor](#whitelabel-partner-endpoints-creditors). Each payout contains
16
16
  # the funds collected from one or many [payments](#core-endpoints-payments).
17
17
  # Payouts are created automatically after a payment has been successfully
18
18
  # collected.
19
- # Represents an instance of a payout resource returned from the API
20
19
  class Payout
21
20
  attr_reader :amount
22
-
23
21
  attr_reader :arrival_date
24
-
25
22
  attr_reader :created_at
26
-
27
23
  attr_reader :currency
28
-
29
24
  attr_reader :deducted_fees
30
-
31
25
  attr_reader :id
32
-
33
26
  attr_reader :reference
34
-
35
27
  attr_reader :status
36
- # initialize a resource instance
28
+
29
+ # Initialize a payout resource instance
37
30
  # @param object [Hash] an object returned from the API
38
31
  def initialize(object, response = nil)
39
32
  @object = object
@@ -54,32 +47,28 @@ module GoCardlessPro
54
47
  ApiResponse.new(@response)
55
48
  end
56
49
 
57
- # return the links that the resource has
50
+ # Return the links that the resource has
58
51
  def links
59
- valid_link_keys = %w(creditor creditor_bank_account )
60
- valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
61
-
62
- links_class = Struct.new(
63
- *{
52
+ @links_links ||= Links.new(@links)
53
+ end
64
54
 
65
- creditor: '',
55
+ # Provides the payout resource as a hash of all its readable attributes
56
+ def to_h
57
+ @object
58
+ end
66
59
 
67
- creditor_bank_account: ''
60
+ class Links
61
+ def initialize(links)
62
+ @links = links
63
+ end
68
64
 
69
- }.keys
70
- ) do
71
- def initialize(hash)
72
- hash.each do |key, val|
73
- send("#{key}=", val)
74
- end
75
- end
65
+ def creditor
66
+ @links['creditor']
76
67
  end
77
- links_class.new(valid_links)
78
- end
79
68
 
80
- # Provides the resource as a hash of all it's readable attributes
81
- def to_h
82
- @object
69
+ def creditor_bank_account
70
+ @links['creditor_bank_account']
71
+ end
83
72
  end
84
73
  end
85
74
  end
@@ -1,65 +1,60 @@
1
-
2
-
3
1
  # encoding: utf-8
4
2
  #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
3
+ # This client is automatically generated from a template and JSON schema definition.
4
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
8
5
  #
6
+
9
7
  require 'uri'
10
8
 
11
9
  module GoCardlessPro
12
10
  # A module containing classes for each of the resources in the GC Api
13
11
  module Resources
12
+ # Represents an instance of a redirect_flow resource returned from the API
13
+
14
14
  # Redirect flows enable you to use GoCardless' [hosted payment
15
- # pages](https://pay-sandbox.gocardless.com/AL000000AKFPFF) to set up mandates
16
- # with your customers. These pages are fully compliant and have been
17
- # translated into Dutch, French, German, Italian, Portuguese, Spanish and
18
- # Swedish.
15
+ # pages](https://pay-sandbox.gocardless.com/AL000000AKFPFF) to set up
16
+ # mandates with your customers. These pages are fully compliant and have
17
+ # been translated into Dutch, French, German, Italian, Portuguese, Spanish
18
+ # and Swedish.
19
19
  #
20
20
  # The overall flow is:
21
21
  #
22
22
  # 1. You
23
- # [create](#create-a-redirect-flow) a redirect flow for your customer, and
24
- # redirect them to the returned redirect url, e.g.
23
+ # [create](#redirect-flows-create-a-redirect-flow) a redirect flow for your
24
+ # customer, and redirect them to the returned redirect url, e.g.
25
25
  # `https://pay.gocardless.com/flow/RE123`.
26
26
  #
27
- # 2. Your customer supplies
28
- # their name, email, address, and bank account details, and submits the form.
29
- # This securely stores their details, and redirects them back to your
30
- # `success_redirect_url` with `redirect_flow_id=RE123` in the querystring.
31
- #
27
+ # 2. Your customer
28
+ # supplies their name, email, address, and bank account details, and submits
29
+ # the form. This securely stores their details, and redirects them back to
30
+ # your `success_redirect_url` with `redirect_flow_id=RE123` in the
31
+ # querystring.
32
32
  #
33
- # 3. You [complete](#complete-a-redirect-flow) the redirect flow, which
34
- # creates a [customer](#core-endpoints-customers), [customer bank
33
+ # 3. You
34
+ # [complete](#redirect-flows-complete-a-redirect-flow) the redirect flow,
35
+ # which creates a [customer](#core-endpoints-customers), [customer bank
35
36
  # account](#core-endpoints-customer-bank-accounts), and
36
- # [mandate](#core-endpoints-mandates), and returns the ID of the mandate. You
37
- # may wish to create a [subscription](#core-endpoints-subscriptions) or
37
+ # [mandate](#core-endpoints-mandates), and returns the ID of the mandate.
38
+ # You may wish to create a [subscription](#core-endpoints-subscriptions) or
38
39
  # [payment](#core-endpoints-payments) at this point.
39
40
  #
40
41
  # It is
41
42
  # recommended that you link the redirect flow to your user object as soon as
42
- # it is created, and attach the created resources to that user in the complete
43
- # step.
43
+ # it is created, and attach the created resources to that user in the
44
+ # complete step.
44
45
  #
45
- # Redirect flows expire 30 minutes after they are first
46
- # created. You cannot complete an expired redirect flow.
47
- # Represents an instance of a redirect_flow resource returned from the API
46
+ # Redirect flows expire 30 minutes after they
47
+ # are first created. You cannot complete an expired redirect flow.
48
48
  class RedirectFlow
49
49
  attr_reader :created_at
50
-
51
50
  attr_reader :description
52
-
53
51
  attr_reader :id
54
-
55
52
  attr_reader :redirect_url
56
-
57
53
  attr_reader :scheme
58
-
59
54
  attr_reader :session_token
60
-
61
55
  attr_reader :success_redirect_url
62
- # initialize a resource instance
56
+
57
+ # Initialize a redirect_flow resource instance
63
58
  # @param object [Hash] an object returned from the API
64
59
  def initialize(object, response = nil)
65
60
  @object = object
@@ -79,36 +74,36 @@ module GoCardlessPro
79
74
  ApiResponse.new(@response)
80
75
  end
81
76
 
82
- # return the links that the resource has
77
+ # Return the links that the resource has
83
78
  def links
84
- valid_link_keys = %w(creditor customer customer_bank_account mandate )
85
- valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
86
-
87
- links_class = Struct.new(
88
- *{
79
+ @links_links ||= Links.new(@links)
80
+ end
89
81
 
90
- creditor: '',
82
+ # Provides the redirect_flow resource as a hash of all its readable attributes
83
+ def to_h
84
+ @object
85
+ end
91
86
 
92
- customer: '',
87
+ class Links
88
+ def initialize(links)
89
+ @links = links
90
+ end
93
91
 
94
- customer_bank_account: '',
92
+ def creditor
93
+ @links['creditor']
94
+ end
95
95
 
96
- mandate: ''
96
+ def customer
97
+ @links['customer']
98
+ end
97
99
 
98
- }.keys
99
- ) do
100
- def initialize(hash)
101
- hash.each do |key, val|
102
- send("#{key}=", val)
103
- end
104
- end
100
+ def customer_bank_account
101
+ @links['customer_bank_account']
105
102
  end
106
- links_class.new(valid_links)
107
- end
108
103
 
109
- # Provides the resource as a hash of all it's readable attributes
110
- def to_h
111
- @object
104
+ def mandate
105
+ @links['mandate']
106
+ end
112
107
  end
113
108
  end
114
109
  end
@@ -1,41 +1,32 @@
1
-
2
-
3
1
  # encoding: utf-8
4
2
  #
5
- # WARNING: Do not edit by hand, this file was generated by Crank:
6
- #
7
- # https://github.com/gocardless/crank
3
+ # This client is automatically generated from a template and JSON schema definition.
4
+ # See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
8
5
  #
6
+
9
7
  require 'uri'
10
8
 
11
9
  module GoCardlessPro
12
10
  # A module containing classes for each of the resources in the GC Api
13
11
  module Resources
12
+ # Represents an instance of a refund resource returned from the API
13
+
14
14
  # Refund objects represent (partial) refunds of a
15
- # [payment](#core-endpoints-payment) back to the
15
+ # [payment](#core-endpoints-payments) back to the
16
16
  # [customer](#core-endpoints-customers).
17
17
  #
18
- # GoCardless will notify you
19
- # via a [webhook](#webhooks) whenever a refund is created, and will update the
20
- # `amount_refunded` property of the payment.
21
- #
22
- # _Note:_ A payment that
23
- # has been (partially) refunded can still receive a late failure or chargeback
24
- # from the banks.
25
- # Represents an instance of a refund resource returned from the API
18
+ # GoCardless will notify
19
+ # you via a [webhook](#appendix-webhooks) whenever a refund is created, and
20
+ # will update the `amount_refunded` property of the payment.
26
21
  class Refund
27
22
  attr_reader :amount
28
-
29
23
  attr_reader :created_at
30
-
31
24
  attr_reader :currency
32
-
33
25
  attr_reader :id
34
-
35
26
  attr_reader :metadata
36
-
37
27
  attr_reader :reference
38
- # initialize a resource instance
28
+
29
+ # Initialize a refund resource instance
39
30
  # @param object [Hash] an object returned from the API
40
31
  def initialize(object, response = nil)
41
32
  @object = object
@@ -54,31 +45,25 @@ module GoCardlessPro
54
45
  ApiResponse.new(@response)
55
46
  end
56
47
 
57
- # return the links that the resource has
48
+ # Return the links that the resource has
58
49
  def links
59
- valid_link_keys = %w(payment )
60
- valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
61
-
62
- links_class = Struct.new(
63
- *{
64
-
65
- payment: ''
66
-
67
- }.keys
68
- ) do
69
- def initialize(hash)
70
- hash.each do |key, val|
71
- send("#{key}=", val)
72
- end
73
- end
74
- end
75
- links_class.new(valid_links)
50
+ @links_links ||= Links.new(@links)
76
51
  end
77
52
 
78
- # Provides the resource as a hash of all it's readable attributes
53
+ # Provides the refund resource as a hash of all its readable attributes
79
54
  def to_h
80
55
  @object
81
56
  end
57
+
58
+ class Links
59
+ def initialize(links)
60
+ @links = links
61
+ end
62
+
63
+ def payment
64
+ @links['payment']
65
+ end
66
+ end
82
67
  end
83
68
  end
84
69
  end