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.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/gocardless_pro/api_service.rb +3 -3
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +8 -10
- data/lib/gocardless_pro/resources/creditor.rb +36 -42
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +24 -38
- data/lib/gocardless_pro/resources/customer.rb +12 -27
- data/lib/gocardless_pro/resources/customer_bank_account.rb +26 -39
- data/lib/gocardless_pro/resources/event.rb +49 -40
- data/lib/gocardless_pro/resources/mandate.rb +33 -35
- data/lib/gocardless_pro/resources/mandate_pdf.rb +10 -11
- data/lib/gocardless_pro/resources/payment.rb +34 -42
- data/lib/gocardless_pro/resources/payout.rb +23 -34
- data/lib/gocardless_pro/resources/redirect_flow.rb +49 -54
- data/lib/gocardless_pro/resources/refund.rb +24 -39
- data/lib/gocardless_pro/resources/subscription.rb +65 -84
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +6 -5
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +7 -6
- data/lib/gocardless_pro/services/creditors_service.rb +7 -6
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +11 -10
- data/lib/gocardless_pro/services/customers_service.rb +7 -6
- data/lib/gocardless_pro/services/events_service.rb +8 -6
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +6 -5
- data/lib/gocardless_pro/services/mandates_service.rb +7 -6
- data/lib/gocardless_pro/services/payments_service.rb +7 -6
- data/lib/gocardless_pro/services/payouts_service.rb +7 -6
- data/lib/gocardless_pro/services/redirect_flows_service.rb +6 -5
- data/lib/gocardless_pro/services/refunds_service.rb +7 -6
- data/lib/gocardless_pro/services/subscriptions_service.rb +7 -6
- data/lib/gocardless_pro/version.rb +1 -1
- data/lib/gocardless_pro.rb +2 -3
- data/spec/resources/creditor_spec.rb +9 -1
- data/spec/resources/event_spec.rb +4 -0
- data/spec/resources/mandate_spec.rb +9 -1
- data/spec/resources/subscription_spec.rb +0 -4
- data/spec/services/creditor_bank_accounts_service_spec.rb +8 -0
- data/spec/services/creditors_service_spec.rb +39 -9
- data/spec/services/customer_bank_accounts_service_spec.rb +8 -0
- data/spec/services/customers_service_spec.rb +8 -0
- data/spec/services/events_service_spec.rb +8 -0
- data/spec/services/mandates_service_spec.rb +8 -0
- data/spec/services/payments_service_spec.rb +8 -0
- data/spec/services/payouts_service_spec.rb +8 -0
- data/spec/services/redirect_flows_service_spec.rb +8 -0
- data/spec/services/refunds_service_spec.rb +8 -0
- data/spec/services/subscriptions_service_spec.rb +8 -13
- metadata +19 -19
@@ -1,39 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
# encoding: utf-8
|
4
2
|
#
|
5
|
-
#
|
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
|
18
|
-
# via a [webhook](#webhooks) whenever the status of a mandate
|
19
|
-
#
|
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
|
-
|
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
|
-
#
|
51
|
+
# Return the links that the resource has
|
58
52
|
def links
|
59
|
-
|
60
|
-
|
53
|
+
@links_links ||= Links.new(@links)
|
54
|
+
end
|
61
55
|
|
62
|
-
|
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
|
-
|
61
|
+
class Links
|
62
|
+
def initialize(links)
|
63
|
+
@links = links
|
64
|
+
end
|
66
65
|
|
67
|
-
|
66
|
+
def creditor
|
67
|
+
@links['creditor']
|
68
|
+
end
|
68
69
|
|
69
|
-
|
70
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
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
|
-
#
|
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
|
-
|
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
|
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
|
-
#
|
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
|
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
|
20
|
-
# you via a [webhook](#webhooks) whenever the state of
|
21
|
-
#
|
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
|
-
|
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
|
-
#
|
57
|
+
# Return the links that the resource has
|
66
58
|
def links
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
links_class = Struct.new(
|
71
|
-
*{
|
59
|
+
@links_links ||= Links.new(@links)
|
60
|
+
end
|
72
61
|
|
73
|
-
|
62
|
+
# Provides the payment resource as a hash of all its readable attributes
|
63
|
+
def to_h
|
64
|
+
@object
|
65
|
+
end
|
74
66
|
|
75
|
-
|
67
|
+
class Links
|
68
|
+
def initialize(links)
|
69
|
+
@links = links
|
70
|
+
end
|
76
71
|
|
77
|
-
|
72
|
+
def creditor
|
73
|
+
@links['creditor']
|
74
|
+
end
|
78
75
|
|
79
|
-
|
76
|
+
def mandate
|
77
|
+
@links['mandate']
|
78
|
+
end
|
80
79
|
|
81
|
-
|
82
|
-
|
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
|
-
|
93
|
-
|
94
|
-
|
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
|
-
#
|
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
|
-
|
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
|
-
#
|
50
|
+
# Return the links that the resource has
|
58
51
|
def links
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
links_class = Struct.new(
|
63
|
-
*{
|
52
|
+
@links_links ||= Links.new(@links)
|
53
|
+
end
|
64
54
|
|
65
|
-
|
55
|
+
# Provides the payout resource as a hash of all its readable attributes
|
56
|
+
def to_h
|
57
|
+
@object
|
58
|
+
end
|
66
59
|
|
67
|
-
|
60
|
+
class Links
|
61
|
+
def initialize(links)
|
62
|
+
@links = links
|
63
|
+
end
|
68
64
|
|
69
|
-
|
70
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
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
|
-
#
|
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
|
16
|
-
# with your customers. These pages are fully compliant and have
|
17
|
-
# translated into Dutch, French, German, Italian, Portuguese, Spanish
|
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
|
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
|
28
|
-
# their name, email, address, and bank account details, and submits
|
29
|
-
# This securely stores their details, and redirects them back to
|
30
|
-
# `success_redirect_url` with `redirect_flow_id=RE123` in the
|
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
|
34
|
-
#
|
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.
|
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
|
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
|
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
|
-
|
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
|
-
#
|
77
|
+
# Return the links that the resource has
|
83
78
|
def links
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
links_class = Struct.new(
|
88
|
-
*{
|
79
|
+
@links_links ||= Links.new(@links)
|
80
|
+
end
|
89
81
|
|
90
|
-
|
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
|
-
|
87
|
+
class Links
|
88
|
+
def initialize(links)
|
89
|
+
@links = links
|
90
|
+
end
|
93
91
|
|
94
|
-
|
92
|
+
def creditor
|
93
|
+
@links['creditor']
|
94
|
+
end
|
95
95
|
|
96
|
-
|
96
|
+
def customer
|
97
|
+
@links['customer']
|
98
|
+
end
|
97
99
|
|
98
|
-
|
99
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
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
|
-
#
|
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-
|
15
|
+
# [payment](#core-endpoints-payments) back to the
|
16
16
|
# [customer](#core-endpoints-customers).
|
17
17
|
#
|
18
|
-
# GoCardless will notify
|
19
|
-
# via a [webhook](#webhooks) whenever a refund is created, and
|
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
|
-
|
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
|
-
#
|
48
|
+
# Return the links that the resource has
|
58
49
|
def links
|
59
|
-
|
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
|
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
|