gocardless_pro 1.0.0 → 1.0.1
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 +9 -0
- data/lib/gocardless_pro/resources/bank_details_lookup.rb +3 -0
- data/lib/gocardless_pro/resources/creditor.rb +4 -1
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +12 -9
- data/lib/gocardless_pro/resources/customer_bank_account.rb +4 -1
- data/lib/gocardless_pro/resources/event.rb +4 -1
- data/lib/gocardless_pro/resources/mandate.rb +4 -1
- data/lib/gocardless_pro/resources/mandate_pdf.rb +1 -1
- data/lib/gocardless_pro/resources/payment.rb +8 -5
- data/lib/gocardless_pro/resources/payout.rb +8 -4
- data/lib/gocardless_pro/resources/redirect_flow.rb +8 -1
- data/lib/gocardless_pro/resources/refund.rb +4 -1
- data/lib/gocardless_pro/resources/subscription.rb +4 -1
- data/lib/gocardless_pro/services/payouts_service.rb +1 -1
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/resources/bank_details_lookup_spec.rb +16 -1
- data/spec/resources/creditor_bank_account_spec.rb +13 -1
- data/spec/resources/creditor_spec.rb +13 -1
- data/spec/resources/customer_bank_account_spec.rb +13 -1
- data/spec/resources/customer_spec.rb +8 -1
- data/spec/resources/event_spec.rb +13 -1
- data/spec/resources/mandate_pdf_spec.rb +8 -1
- data/spec/resources/mandate_spec.rb +13 -1
- data/spec/resources/payment_spec.rb +13 -1
- data/spec/resources/payout_spec.rb +13 -1
- data/spec/resources/redirect_flow_spec.rb +21 -1
- data/spec/resources/refund_spec.rb +13 -1
- data/spec/resources/subscription_spec.rb +13 -1
- data/spec/services/bank_details_lookups_service_spec.rb +8 -4
- data/spec/services/creditor_bank_accounts_service_spec.rb +25 -21
- data/spec/services/creditors_service_spec.rb +24 -19
- data/spec/services/customer_bank_accounts_service_spec.rb +28 -23
- data/spec/services/customers_service_spec.rb +24 -19
- data/spec/services/events_service_spec.rb +17 -13
- data/spec/services/mandate_pdfs_service_spec.rb +5 -4
- data/spec/services/mandates_service_spec.rb +32 -27
- data/spec/services/payments_service_spec.rb +32 -27
- data/spec/services/payouts_service_spec.rb +17 -13
- data/spec/services/redirect_flows_service_spec.rb +19 -15
- data/spec/services/refunds_service_spec.rb +24 -19
- data/spec/services/subscriptions_service_spec.rb +28 -23
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 336757aa0c2b6a8259d999fff9b6c47b08a81ac9
|
4
|
+
data.tar.gz: 8a9254232e7c5b5df0f3ff1cd4ee31a3a0e5c8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d06593be915e27b49c3a227492380e92d81b5461a6dc16c4ab094d3c45640bf8405a036890e0cb98ef1194533f05bc74ea92a2c2ac9fdcd07726b0423a09818d
|
7
|
+
data.tar.gz: 6d515b60b723a53c24145fdd55c75fb0de95ab6618977e2055e612ca76da8178e8a570d5da66590ae6793bb7c750ee9389dc3629bfb186b774a4ce8e2a1d69bf
|
data/README.md
CHANGED
@@ -114,7 +114,16 @@ The error has the following methods to allow you to access the information from
|
|
114
114
|
- `#request_id`
|
115
115
|
- `#errors`
|
116
116
|
|
117
|
+
### Using the OAuth API
|
118
|
+
|
119
|
+
The API includes [OAuth](https://developer.gocardless.com/pro/2015-07-06/#guides-oauth) functionality, which allows you to work with other users' GoCardless accounts. Once a user approves you, you can use the GoCardless API on their behalf and receive their webhooks.
|
120
|
+
|
121
|
+
OAuth simply provides a means by which you obtain an access token - once you have this access token, you can use this gem as usual.
|
122
|
+
|
123
|
+
We recommend using the [oauth2](https://github.com/intridea/oauth2) gem to handle the authorisation process and gain a token. For an example of this in action, see our [open-source OAuth demo app](https://github.com/gocardless/oauth-demo/blob/master/app.rb#L46).
|
124
|
+
|
117
125
|
## Supporting Ruby < 2.0.0
|
126
|
+
|
118
127
|
The client only supports Ruby >= 2.0.0 out of the box due to our use of
|
119
128
|
Enumerable::Lazy for lazy loading of paginated API resources.
|
120
129
|
|
@@ -17,6 +17,8 @@ module GoCardlessPro
|
|
17
17
|
attr_reader :available_debit_schemes
|
18
18
|
|
19
19
|
attr_reader :bank_name
|
20
|
+
|
21
|
+
attr_reader :bic
|
20
22
|
# initialize a resource instance
|
21
23
|
# @param object [Hash] an object returned from the API
|
22
24
|
def initialize(object, response = nil)
|
@@ -24,6 +26,7 @@ module GoCardlessPro
|
|
24
26
|
|
25
27
|
@available_debit_schemes = object['available_debit_schemes']
|
26
28
|
@bank_name = object['bank_name']
|
29
|
+
@bic = object['bic']
|
27
30
|
@response = response
|
28
31
|
end
|
29
32
|
|
@@ -65,6 +65,9 @@ module GoCardlessPro
|
|
65
65
|
|
66
66
|
# return the links that the resource has
|
67
67
|
def links
|
68
|
+
valid_link_keys = %w(default_eur_payout_account default_gbp_payout_account )
|
69
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
70
|
+
|
68
71
|
Struct.new(
|
69
72
|
*{
|
70
73
|
|
@@ -73,7 +76,7 @@ module GoCardlessPro
|
|
73
76
|
default_gbp_payout_account: ''
|
74
77
|
|
75
78
|
}.keys.sort
|
76
|
-
).new(
|
79
|
+
).new(*valid_links.sort.map(&:last))
|
77
80
|
end
|
78
81
|
|
79
82
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -12,15 +12,15 @@ module GoCardlessPro
|
|
12
12
|
# A module containing classes for each of the resources in the GC Api
|
13
13
|
module Resources
|
14
14
|
# Creditor Bank Accounts hold the bank details of a
|
15
|
-
# [creditor](#
|
16
|
-
# [payouts](#core-endpoints-payouts) will be sent to.
|
15
|
+
# [creditor](#whitelabel-partner-endpoints-creditors). These are the bank
|
16
|
+
# accounts which your [payouts](#core-endpoints-payouts) will be sent to.
|
17
17
|
#
|
18
|
-
#
|
19
|
-
# creditor bank accounts must be unique, and so you will
|
20
|
-
# `bank_account_exists` error if you try to create a duplicate
|
21
|
-
# You may wish to handle this by updating the existing record
|
22
|
-
# of which will be provided as `links[creditor_bank_account]`
|
23
|
-
# response.
|
18
|
+
#
|
19
|
+
# Note that creditor bank accounts must be unique, and so you will
|
20
|
+
# encounter a `bank_account_exists` error if you try to create a duplicate
|
21
|
+
# bank account. You may wish to handle this by updating the existing record
|
22
|
+
# instead, the ID of which will be provided as `links[creditor_bank_account]`
|
23
|
+
# in the error response.
|
24
24
|
# Represents an instance of a creditor_bank_account resource returned from the API
|
25
25
|
class CreditorBankAccount
|
26
26
|
attr_reader :account_holder_name
|
@@ -64,13 +64,16 @@ module GoCardlessPro
|
|
64
64
|
|
65
65
|
# return the links that the resource has
|
66
66
|
def links
|
67
|
+
valid_link_keys = %w(creditor )
|
68
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
69
|
+
|
67
70
|
Struct.new(
|
68
71
|
*{
|
69
72
|
|
70
73
|
creditor: ''
|
71
74
|
|
72
75
|
}.keys.sort
|
73
|
-
).new(
|
76
|
+
).new(*valid_links.sort.map(&:last))
|
74
77
|
end
|
75
78
|
|
76
79
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -64,13 +64,16 @@ module GoCardlessPro
|
|
64
64
|
|
65
65
|
# return the links that the resource has
|
66
66
|
def links
|
67
|
+
valid_link_keys = %w(customer )
|
68
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
69
|
+
|
67
70
|
Struct.new(
|
68
71
|
*{
|
69
72
|
|
70
73
|
customer: ''
|
71
74
|
|
72
75
|
}.keys.sort
|
73
|
-
).new(
|
76
|
+
).new(*valid_links.sort.map(&:last))
|
74
77
|
end
|
75
78
|
|
76
79
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -48,6 +48,9 @@ module GoCardlessPro
|
|
48
48
|
|
49
49
|
# return the links that the resource has
|
50
50
|
def links
|
51
|
+
valid_link_keys = %w(mandate new_customer_bank_account parent_event payment payout previous_customer_bank_account refund subscription )
|
52
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
53
|
+
|
51
54
|
Struct.new(
|
52
55
|
*{
|
53
56
|
|
@@ -68,7 +71,7 @@ module GoCardlessPro
|
|
68
71
|
subscription: ''
|
69
72
|
|
70
73
|
}.keys.sort
|
71
|
-
).new(
|
74
|
+
).new(*valid_links.sort.map(&:last))
|
72
75
|
end
|
73
76
|
|
74
77
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -53,6 +53,9 @@ module GoCardlessPro
|
|
53
53
|
|
54
54
|
# return the links that the resource has
|
55
55
|
def links
|
56
|
+
valid_link_keys = %w(creditor customer_bank_account )
|
57
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
58
|
+
|
56
59
|
Struct.new(
|
57
60
|
*{
|
58
61
|
|
@@ -61,7 +64,7 @@ module GoCardlessPro
|
|
61
64
|
customer_bank_account: ''
|
62
65
|
|
63
66
|
}.keys.sort
|
64
|
-
).new(
|
67
|
+
).new(*valid_links.sort.map(&:last))
|
65
68
|
end
|
66
69
|
|
67
70
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -12,7 +12,7 @@ module GoCardlessPro
|
|
12
12
|
# A module containing classes for each of the resources in the GC Api
|
13
13
|
module Resources
|
14
14
|
# Mandate PDFs allow you to easily display [scheme-rules
|
15
|
-
# compliant](#
|
15
|
+
# compliant](#appendix-compliance-requirements) Direct Debit mandates to your
|
16
16
|
# customers.
|
17
17
|
# Represents an instance of a mandate_pdf resource returned from the API
|
18
18
|
class MandatePdf
|
@@ -13,11 +13,11 @@ module GoCardlessPro
|
|
13
13
|
module Resources
|
14
14
|
# Payment objects represent payments from a
|
15
15
|
# [customer](#core-endpoints-customers) to a
|
16
|
-
# [creditor](#
|
17
|
-
# [mandate](#core-endpoints-mandates).
|
16
|
+
# [creditor](#whitelabel-partner-endpoints-creditors), taken against a Direct
|
17
|
+
# Debit [mandate](#core-endpoints-mandates).
|
18
18
|
#
|
19
|
-
# GoCardless will notify
|
20
|
-
# a [webhook](#webhooks) whenever the state of a payment changes.
|
19
|
+
# GoCardless will notify
|
20
|
+
# you via a [webhook](#webhooks) whenever the state of a payment changes.
|
21
21
|
# Represents an instance of a payment resource returned from the API
|
22
22
|
class Payment
|
23
23
|
attr_reader :amount
|
@@ -64,6 +64,9 @@ module GoCardlessPro
|
|
64
64
|
|
65
65
|
# return the links that the resource has
|
66
66
|
def links
|
67
|
+
valid_link_keys = %w(creditor mandate payout subscription )
|
68
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
69
|
+
|
67
70
|
Struct.new(
|
68
71
|
*{
|
69
72
|
|
@@ -76,7 +79,7 @@ module GoCardlessPro
|
|
76
79
|
subscription: ''
|
77
80
|
|
78
81
|
}.keys.sort
|
79
|
-
).new(
|
82
|
+
).new(*valid_links.sort.map(&:last))
|
80
83
|
end
|
81
84
|
|
82
85
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -12,9 +12,10 @@ module GoCardlessPro
|
|
12
12
|
# A module containing classes for each of the resources in the GC Api
|
13
13
|
module Resources
|
14
14
|
# Payouts represent transfers from GoCardless to a
|
15
|
-
# [creditor](#
|
16
|
-
# collected from one or many [payments](#core-endpoints-payments).
|
17
|
-
# created automatically after a payment has been successfully
|
15
|
+
# [creditor](#whitelabel-partner-endpoints-creditors). Each payout contains
|
16
|
+
# the funds collected from one or many [payments](#core-endpoints-payments).
|
17
|
+
# Payouts are created automatically after a payment has been successfully
|
18
|
+
# collected.
|
18
19
|
# Represents an instance of a payout resource returned from the API
|
19
20
|
class Payout
|
20
21
|
attr_reader :amount
|
@@ -49,6 +50,9 @@ module GoCardlessPro
|
|
49
50
|
|
50
51
|
# return the links that the resource has
|
51
52
|
def links
|
53
|
+
valid_link_keys = %w(creditor creditor_bank_account )
|
54
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
55
|
+
|
52
56
|
Struct.new(
|
53
57
|
*{
|
54
58
|
|
@@ -57,7 +61,7 @@ module GoCardlessPro
|
|
57
61
|
creditor_bank_account: ''
|
58
62
|
|
59
63
|
}.keys.sort
|
60
|
-
).new(
|
64
|
+
).new(*valid_links.sort.map(&:last))
|
61
65
|
end
|
62
66
|
|
63
67
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -80,15 +80,22 @@ module GoCardlessPro
|
|
80
80
|
|
81
81
|
# return the links that the resource has
|
82
82
|
def links
|
83
|
+
valid_link_keys = %w(creditor customer customer_bank_account mandate )
|
84
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
85
|
+
|
83
86
|
Struct.new(
|
84
87
|
*{
|
85
88
|
|
86
89
|
creditor: '',
|
87
90
|
|
91
|
+
customer: '',
|
92
|
+
|
93
|
+
customer_bank_account: '',
|
94
|
+
|
88
95
|
mandate: ''
|
89
96
|
|
90
97
|
}.keys.sort
|
91
|
-
).new(
|
98
|
+
).new(*valid_links.sort.map(&:last))
|
92
99
|
end
|
93
100
|
|
94
101
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -53,13 +53,16 @@ module GoCardlessPro
|
|
53
53
|
|
54
54
|
# return the links that the resource has
|
55
55
|
def links
|
56
|
+
valid_link_keys = %w(payment )
|
57
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
58
|
+
|
56
59
|
Struct.new(
|
57
60
|
*{
|
58
61
|
|
59
62
|
payment: ''
|
60
63
|
|
61
64
|
}.keys.sort
|
62
|
-
).new(
|
65
|
+
).new(*valid_links.sort.map(&:last))
|
63
66
|
end
|
64
67
|
|
65
68
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -141,13 +141,16 @@ module GoCardlessPro
|
|
141
141
|
|
142
142
|
# return the links that the resource has
|
143
143
|
def links
|
144
|
+
valid_link_keys = %w(mandate )
|
145
|
+
valid_links = @links.select { |key, _| valid_link_keys.include?(key) }
|
146
|
+
|
144
147
|
Struct.new(
|
145
148
|
*{
|
146
149
|
|
147
150
|
mandate: ''
|
148
151
|
|
149
152
|
}.keys.sort
|
150
|
-
).new(
|
153
|
+
).new(*valid_links.sort.map(&:last))
|
151
154
|
end
|
152
155
|
|
153
156
|
# Provides the resource as a hash of all it's readable attributes
|
@@ -40,7 +40,7 @@ module GoCardlessPro
|
|
40
40
|
|
41
41
|
# Retrieves the details of a single payout. For an example of how to reconcile
|
42
42
|
# the transactions in a payout, see [this
|
43
|
-
# guide](#events-
|
43
|
+
# guide](#events-reconciling-payouts-with-events).
|
44
44
|
# Example URL: /payouts/:identity
|
45
45
|
#
|
46
46
|
# @param identity # Unique identifier, beginning with "PO".
|
@@ -13,10 +13,14 @@ describe GoCardlessPro::Resources::BankDetailsLookup do
|
|
13
13
|
"bank_name" => "bank_name-input",
|
14
14
|
|
15
15
|
|
16
|
+
|
17
|
+
"bic" => "bic-input",
|
18
|
+
|
19
|
+
|
16
20
|
}
|
17
21
|
end
|
18
22
|
|
19
|
-
it "can be initialized from an
|
23
|
+
it "can be initialized from an unenveloped response" do
|
20
24
|
resource = described_class.new(data)
|
21
25
|
|
22
26
|
|
@@ -27,8 +31,19 @@ describe GoCardlessPro::Resources::BankDetailsLookup do
|
|
27
31
|
expect(resource.bank_name).to eq("bank_name-input")
|
28
32
|
|
29
33
|
|
34
|
+
|
35
|
+
expect(resource.bic).to eq("bic-input")
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can handle new attributes without erroring" do
|
41
|
+
data["foo"] = "bar"
|
42
|
+
expect { described_class.new(data) }.to_not raise_error
|
30
43
|
end
|
31
44
|
|
45
|
+
|
46
|
+
|
32
47
|
describe "#to_h" do
|
33
48
|
it "returns a hash representing the resource" do
|
34
49
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -52,7 +52,7 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
55
|
-
it "can be initialized from an
|
55
|
+
it "can be initialized from an unenveloped response" do
|
56
56
|
resource = described_class.new(data)
|
57
57
|
|
58
58
|
|
@@ -99,6 +99,18 @@ describe GoCardlessPro::Resources::CreditorBankAccount do
|
|
99
99
|
|
100
100
|
end
|
101
101
|
|
102
|
+
it "can handle new attributes without erroring" do
|
103
|
+
data["foo"] = "bar"
|
104
|
+
expect { described_class.new(data) }.to_not raise_error
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
it "can handle new link attributes without erroring" do
|
109
|
+
data["links"]["foo"] = "bar"
|
110
|
+
expect { described_class.new(data) }.to_not raise_error
|
111
|
+
end
|
112
|
+
|
113
|
+
|
102
114
|
describe "#to_h" do
|
103
115
|
it "returns a hash representing the resource" do
|
104
116
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -58,7 +58,7 @@ describe GoCardlessPro::Resources::Creditor do
|
|
58
58
|
}
|
59
59
|
end
|
60
60
|
|
61
|
-
it "can be initialized from an
|
61
|
+
it "can be initialized from an unenveloped response" do
|
62
62
|
resource = described_class.new(data)
|
63
63
|
|
64
64
|
|
@@ -111,6 +111,18 @@ describe GoCardlessPro::Resources::Creditor do
|
|
111
111
|
|
112
112
|
end
|
113
113
|
|
114
|
+
it "can handle new attributes without erroring" do
|
115
|
+
data["foo"] = "bar"
|
116
|
+
expect { described_class.new(data) }.to_not raise_error
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
it "can handle new link attributes without erroring" do
|
121
|
+
data["links"]["foo"] = "bar"
|
122
|
+
expect { described_class.new(data) }.to_not raise_error
|
123
|
+
end
|
124
|
+
|
125
|
+
|
114
126
|
describe "#to_h" do
|
115
127
|
it "returns a hash representing the resource" do
|
116
128
|
expect(described_class.new(data).to_h).to eq(data)
|
@@ -52,7 +52,7 @@ describe GoCardlessPro::Resources::CustomerBankAccount do
|
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
55
|
-
it "can be initialized from an
|
55
|
+
it "can be initialized from an unenveloped response" do
|
56
56
|
resource = described_class.new(data)
|
57
57
|
|
58
58
|
|
@@ -99,6 +99,18 @@ describe GoCardlessPro::Resources::CustomerBankAccount do
|
|
99
99
|
|
100
100
|
end
|
101
101
|
|
102
|
+
it "can handle new attributes without erroring" do
|
103
|
+
data["foo"] = "bar"
|
104
|
+
expect { described_class.new(data) }.to_not raise_error
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
it "can handle new link attributes without erroring" do
|
109
|
+
data["links"]["foo"] = "bar"
|
110
|
+
expect { described_class.new(data) }.to_not raise_error
|
111
|
+
end
|
112
|
+
|
113
|
+
|
102
114
|
describe "#to_h" do
|
103
115
|
it "returns a hash representing the resource" do
|
104
116
|
expect(described_class.new(data).to_h).to eq(data)
|