gocardless_pro 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9bf930f0861c969e5518b00a10e9751691b4505
|
4
|
+
data.tar.gz: 3ca0cd94ef9b840cacf9e5aa3ddd7fb843404ed3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86b8b85b3e57c6b199d8dbea5591bb3a393f339e2e506a939a82a2bdc22cb8df5361f1f4e4288604b29d3debdfde3b2a7ebb1d8895c640a456e4d795c3b5477
|
7
|
+
data.tar.gz: 2bf60b407e6fdc07d2e582274197bff176b03f9fc4d30f25591943ab0479121ab9ea388c56c931d0bfe6d14aa5276d1e7e983faaa06fd212ed900ca84d83e4b3
|
data/README.md
CHANGED
@@ -5,11 +5,13 @@ A Ruby client for the GoCardless API. For full details of the GoCardless API, se
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/statesman.png)](http://badge.fury.io/rb/gocardless_pro)
|
6
6
|
[![Build Status](https://travis-ci.org/gocardless/gocardless-pro-ruby.svg?branch=master)](https://travis-ci.org/gocardless/gocardless-pro-ruby)
|
7
7
|
|
8
|
+
- ["Getting started" guide](https://developer.gocardless.com/getting-started/api/introduction/?lang=ruby) with copy and paste Ruby code samples
|
9
|
+
- [API Reference](https://developer.gocardless.com/api-reference/2015-07-06)
|
8
10
|
|
9
11
|
## Usage Examples
|
10
12
|
|
11
13
|
This README will use `customers` throughout but each of the resources in the
|
12
|
-
[API](https://developer.gocardless.com/
|
14
|
+
[API](https://developer.gocardless.com/api-reference/) is available in this library.
|
13
15
|
|
14
16
|
### Installation
|
15
17
|
|
@@ -147,7 +149,7 @@ When the API returns an error, the client will raise a corresponding one. There
|
|
147
149
|
- `GoCardlessPro::InvalidStateError`
|
148
150
|
- `GoCardlessPro::ValidationError`
|
149
151
|
|
150
|
-
These errors are fully documented in the [API documentation](https://developer.gocardless.com/
|
152
|
+
These errors are fully documented in the [API documentation](https://developer.gocardless.com/api-reference/#overview-errors).
|
151
153
|
|
152
154
|
All errors have the following methods to facilitate access to information in the API response:
|
153
155
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# 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.
|
6
5
|
#
|
6
|
+
|
7
7
|
require 'uri'
|
8
8
|
require 'base64'
|
9
9
|
|
@@ -1,25 +1,23 @@
|
|
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
|
-
# Look up the name and reachability of a bank.
|
15
12
|
# Represents an instance of a bank_details_lookup resource returned from the API
|
13
|
+
|
14
|
+
# Look up the name and reachability of a bank.
|
16
15
|
class BankDetailsLookup
|
17
16
|
attr_reader :available_debit_schemes
|
18
|
-
|
19
17
|
attr_reader :bank_name
|
20
|
-
|
21
18
|
attr_reader :bic
|
22
|
-
|
19
|
+
|
20
|
+
# Initialize a bank_details_lookup resource instance
|
23
21
|
# @param object [Hash] an object returned from the API
|
24
22
|
def initialize(object, response = nil)
|
25
23
|
@object = object
|
@@ -34,7 +32,7 @@ module GoCardlessPro
|
|
34
32
|
ApiResponse.new(@response)
|
35
33
|
end
|
36
34
|
|
37
|
-
# Provides the resource as a hash of all
|
35
|
+
# Provides the bank_details_lookup resource as a hash of all its readable attributes
|
38
36
|
def to_h
|
39
37
|
@object
|
40
38
|
end
|
@@ -1,46 +1,40 @@
|
|
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
|
-
#
|
15
|
-
|
12
|
+
# Represents an instance of a creditor resource returned from the API
|
13
|
+
|
14
|
+
# Each [payment](#core-endpoints-payments) taken through the API is linked
|
15
|
+
# to a "creditor", to whom the payment is then paid out. In most cases your
|
16
16
|
# organisation will have a single "creditor", but the API also supports
|
17
17
|
# collecting payments on behalf of others.
|
18
18
|
#
|
19
|
-
# Please get in touch
|
20
|
-
# wish to use this endpoint. Currently, for Anti Money Laundering
|
21
|
-
# creditors you add must be directly related to your
|
22
|
-
#
|
19
|
+
# Please get in touch
|
20
|
+
# if you wish to use this endpoint. Currently, for Anti Money Laundering
|
21
|
+
# reasons, any creditors you add must be directly related to your
|
22
|
+
# organisation.
|
23
23
|
class Creditor
|
24
24
|
attr_reader :address_line1
|
25
|
-
|
26
25
|
attr_reader :address_line2
|
27
|
-
|
28
26
|
attr_reader :address_line3
|
29
|
-
|
30
27
|
attr_reader :city
|
31
|
-
|
32
28
|
attr_reader :country_code
|
33
|
-
|
34
29
|
attr_reader :created_at
|
35
|
-
|
36
30
|
attr_reader :id
|
37
|
-
|
31
|
+
attr_reader :logo_url
|
38
32
|
attr_reader :name
|
39
|
-
|
40
33
|
attr_reader :postal_code
|
41
|
-
|
42
34
|
attr_reader :region
|
43
|
-
|
35
|
+
attr_reader :scheme_identifiers
|
36
|
+
|
37
|
+
# Initialize a creditor resource instance
|
44
38
|
# @param object [Hash] an object returned from the API
|
45
39
|
def initialize(object, response = nil)
|
46
40
|
@object = object
|
@@ -53,9 +47,11 @@ module GoCardlessPro
|
|
53
47
|
@created_at = object['created_at']
|
54
48
|
@id = object['id']
|
55
49
|
@links = object['links']
|
50
|
+
@logo_url = object['logo_url']
|
56
51
|
@name = object['name']
|
57
52
|
@postal_code = object['postal_code']
|
58
53
|
@region = object['region']
|
54
|
+
@scheme_identifiers = object['scheme_identifiers']
|
59
55
|
@response = response
|
60
56
|
end
|
61
57
|
|
@@ -63,34 +59,32 @@ module GoCardlessPro
|
|
63
59
|
ApiResponse.new(@response)
|
64
60
|
end
|
65
61
|
|
66
|
-
#
|
62
|
+
# Return the links that the resource has
|
67
63
|
def links
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
links_class = Struct.new(
|
72
|
-
*{
|
64
|
+
@links_links ||= Links.new(@links)
|
65
|
+
end
|
73
66
|
|
74
|
-
|
67
|
+
# Provides the creditor resource as a hash of all its readable attributes
|
68
|
+
def to_h
|
69
|
+
@object
|
70
|
+
end
|
75
71
|
|
76
|
-
|
72
|
+
class Links
|
73
|
+
def initialize(links)
|
74
|
+
@links = links
|
75
|
+
end
|
77
76
|
|
78
|
-
|
77
|
+
def default_eur_payout_account
|
78
|
+
@links['default_eur_payout_account']
|
79
|
+
end
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
def initialize(hash)
|
83
|
-
hash.each do |key, val|
|
84
|
-
send("#{key}=", val)
|
85
|
-
end
|
86
|
-
end
|
81
|
+
def default_gbp_payout_account
|
82
|
+
@links['default_gbp_payout_account']
|
87
83
|
end
|
88
|
-
links_class.new(valid_links)
|
89
|
-
end
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
def default_sek_payout_account
|
86
|
+
@links['default_sek_payout_account']
|
87
|
+
end
|
94
88
|
end
|
95
89
|
end
|
96
90
|
end
|
@@ -1,46 +1,38 @@
|
|
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 creditor_bank_account resource returned from the API
|
13
|
+
|
14
14
|
# Creditor Bank Accounts hold the bank details of a
|
15
15
|
# [creditor](#whitelabel-partner-endpoints-creditors). These are the bank
|
16
16
|
# accounts which your [payouts](#core-endpoints-payouts) will be sent to.
|
17
|
-
|
18
|
-
#
|
17
|
+
|
18
|
+
# #
|
19
19
|
# Note that creditor bank accounts must be unique, and so you will
|
20
20
|
# encounter a `bank_account_exists` error if you try to create a duplicate
|
21
21
|
# bank account. You may wish to handle this by updating the existing record
|
22
|
-
# instead, the ID of which will be provided as
|
23
|
-
# in the error response.
|
24
|
-
# Represents an instance of a creditor_bank_account resource returned from the API
|
22
|
+
# instead, the ID of which will be provided as
|
23
|
+
# `links[creditor_bank_account]` in the error response.
|
25
24
|
class CreditorBankAccount
|
26
25
|
attr_reader :account_holder_name
|
27
|
-
|
28
26
|
attr_reader :account_number_ending
|
29
|
-
|
30
27
|
attr_reader :bank_name
|
31
|
-
|
32
28
|
attr_reader :country_code
|
33
|
-
|
34
29
|
attr_reader :created_at
|
35
|
-
|
36
30
|
attr_reader :currency
|
37
|
-
|
38
31
|
attr_reader :enabled
|
39
|
-
|
40
32
|
attr_reader :id
|
41
|
-
|
42
33
|
attr_reader :metadata
|
43
|
-
|
34
|
+
|
35
|
+
# Initialize a creditor_bank_account resource instance
|
44
36
|
# @param object [Hash] an object returned from the API
|
45
37
|
def initialize(object, response = nil)
|
46
38
|
@object = object
|
@@ -62,31 +54,25 @@ 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
|
-
valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
|
69
|
-
|
70
|
-
links_class = Struct.new(
|
71
|
-
*{
|
72
|
-
|
73
|
-
creditor: ''
|
74
|
-
|
75
|
-
}.keys
|
76
|
-
) do
|
77
|
-
def initialize(hash)
|
78
|
-
hash.each do |key, val|
|
79
|
-
send("#{key}=", val)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
links_class.new(valid_links)
|
59
|
+
@links_links ||= Links.new(@links)
|
84
60
|
end
|
85
61
|
|
86
|
-
# Provides the resource as a hash of all
|
62
|
+
# Provides the creditor_bank_account resource as a hash of all its readable attributes
|
87
63
|
def to_h
|
88
64
|
@object
|
89
65
|
end
|
66
|
+
|
67
|
+
class Links
|
68
|
+
def initialize(links)
|
69
|
+
@links = links
|
70
|
+
end
|
71
|
+
|
72
|
+
def creditor
|
73
|
+
@links['creditor']
|
74
|
+
end
|
75
|
+
end
|
90
76
|
end
|
91
77
|
end
|
92
78
|
end
|
@@ -1,59 +1,44 @@
|
|
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 customer resource returned from the API
|
13
|
+
|
14
14
|
# Customer objects hold the contact details for a customer. A customer can
|
15
15
|
# have several [customer bank
|
16
16
|
# accounts](#core-endpoints-customer-bank-accounts), which in turn can have
|
17
17
|
# several Direct Debit [mandates](#core-endpoints-mandates).
|
18
18
|
#
|
19
|
-
#
|
20
|
-
# the `swedish_identity_number` field may only be supplied for Swedish
|
21
|
-
# customers, and must be supplied if you intend to set up an Autogiro
|
22
|
-
# with the customer.
|
23
|
-
# Represents an instance of a customer resource returned from the API
|
19
|
+
#
|
20
|
+
# Note: the `swedish_identity_number` field may only be supplied for Swedish
|
21
|
+
# customers, and must be supplied if you intend to set up an Autogiro
|
22
|
+
# mandate with the customer.
|
24
23
|
class Customer
|
25
24
|
attr_reader :address_line1
|
26
|
-
|
27
25
|
attr_reader :address_line2
|
28
|
-
|
29
26
|
attr_reader :address_line3
|
30
|
-
|
31
27
|
attr_reader :city
|
32
|
-
|
33
28
|
attr_reader :company_name
|
34
|
-
|
35
29
|
attr_reader :country_code
|
36
|
-
|
37
30
|
attr_reader :created_at
|
38
|
-
|
39
31
|
attr_reader :email
|
40
|
-
|
41
32
|
attr_reader :family_name
|
42
|
-
|
43
33
|
attr_reader :given_name
|
44
|
-
|
45
34
|
attr_reader :id
|
46
|
-
|
47
35
|
attr_reader :language
|
48
|
-
|
49
36
|
attr_reader :metadata
|
50
|
-
|
51
37
|
attr_reader :postal_code
|
52
|
-
|
53
38
|
attr_reader :region
|
54
|
-
|
55
39
|
attr_reader :swedish_identity_number
|
56
|
-
|
40
|
+
|
41
|
+
# Initialize a customer resource instance
|
57
42
|
# @param object [Hash] an object returned from the API
|
58
43
|
def initialize(object, response = nil)
|
59
44
|
@object = object
|
@@ -81,7 +66,7 @@ module GoCardlessPro
|
|
81
66
|
ApiResponse.new(@response)
|
82
67
|
end
|
83
68
|
|
84
|
-
# Provides the resource as a hash of all
|
69
|
+
# Provides the customer resource as a hash of all its readable attributes
|
85
70
|
def to_h
|
86
71
|
@object
|
87
72
|
end
|
@@ -1,46 +1,39 @@
|
|
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 customer_bank_account resource returned from the API
|
13
|
+
|
14
14
|
# Customer Bank Accounts hold the bank details of a
|
15
15
|
# [customer](#core-endpoints-customers). They always belong to a
|
16
16
|
# [customer](#core-endpoints-customers), and may be linked to several Direct
|
17
17
|
# Debit [mandates](#core-endpoints-mandates).
|
18
18
|
#
|
19
|
-
# Note that
|
20
|
-
# accounts must be unique, and so you will encounter a
|
21
|
-
# error if you try to create a duplicate bank account.
|
22
|
-
# this by updating the existing record instead, the
|
23
|
-
# provided as links[customer_bank_account] in the
|
24
|
-
#
|
19
|
+
# Note that
|
20
|
+
# customer bank accounts must be unique, and so you will encounter a
|
21
|
+
# `bank_account_exists` error if you try to create a duplicate bank account.
|
22
|
+
# You may wish to handle this by updating the existing record instead, the
|
23
|
+
# ID of which will be provided as `links[customer_bank_account]` in the
|
24
|
+
# error response.
|
25
25
|
class CustomerBankAccount
|
26
26
|
attr_reader :account_holder_name
|
27
|
-
|
28
27
|
attr_reader :account_number_ending
|
29
|
-
|
30
28
|
attr_reader :bank_name
|
31
|
-
|
32
29
|
attr_reader :country_code
|
33
|
-
|
34
30
|
attr_reader :created_at
|
35
|
-
|
36
31
|
attr_reader :currency
|
37
|
-
|
38
32
|
attr_reader :enabled
|
39
|
-
|
40
33
|
attr_reader :id
|
41
|
-
|
42
34
|
attr_reader :metadata
|
43
|
-
|
35
|
+
|
36
|
+
# Initialize a customer_bank_account resource instance
|
44
37
|
# @param object [Hash] an object returned from the API
|
45
38
|
def initialize(object, response = nil)
|
46
39
|
@object = object
|
@@ -62,31 +55,25 @@ module GoCardlessPro
|
|
62
55
|
ApiResponse.new(@response)
|
63
56
|
end
|
64
57
|
|
65
|
-
#
|
58
|
+
# Return the links that the resource has
|
66
59
|
def links
|
67
|
-
|
68
|
-
valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }
|
69
|
-
|
70
|
-
links_class = Struct.new(
|
71
|
-
*{
|
72
|
-
|
73
|
-
customer: ''
|
74
|
-
|
75
|
-
}.keys
|
76
|
-
) do
|
77
|
-
def initialize(hash)
|
78
|
-
hash.each do |key, val|
|
79
|
-
send("#{key}=", val)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
links_class.new(valid_links)
|
60
|
+
@links_links ||= Links.new(@links)
|
84
61
|
end
|
85
62
|
|
86
|
-
# Provides the resource as a hash of all
|
63
|
+
# Provides the customer_bank_account resource as a hash of all its readable attributes
|
87
64
|
def to_h
|
88
65
|
@object
|
89
66
|
end
|
67
|
+
|
68
|
+
class Links
|
69
|
+
def initialize(links)
|
70
|
+
@links = links
|
71
|
+
end
|
72
|
+
|
73
|
+
def customer
|
74
|
+
@links['customer']
|
75
|
+
end
|
76
|
+
end
|
90
77
|
end
|
91
78
|
end
|
92
79
|
end
|
@@ -1,33 +1,28 @@
|
|
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
|
-
# Events are stored for all webhooks. An event refers to a resource which has
|
15
|
-
# been updated, for example a payment which has been collected, or a mandate
|
16
|
-
# which has been transferred.
|
17
12
|
# Represents an instance of a event resource returned from the API
|
13
|
+
|
14
|
+
# Events are stored for all webhooks. An event refers to a resource which
|
15
|
+
# has been updated, for example a payment which has been collected, or a
|
16
|
+
# mandate which has been transferred.
|
18
17
|
class Event
|
19
18
|
attr_reader :action
|
20
|
-
|
21
19
|
attr_reader :created_at
|
22
|
-
|
23
20
|
attr_reader :details
|
24
|
-
|
25
21
|
attr_reader :id
|
26
|
-
|
27
22
|
attr_reader :metadata
|
28
|
-
|
29
23
|
attr_reader :resource_type
|
30
|
-
|
24
|
+
|
25
|
+
# Initialize a event resource instance
|
31
26
|
# @param object [Hash] an object returned from the API
|
32
27
|
def initialize(object, response = nil)
|
33
28
|
@object = object
|
@@ -46,46 +41,60 @@ module GoCardlessPro
|
|
46
41
|
ApiResponse.new(@response)
|
47
42
|
end
|
48
43
|
|
49
|
-
#
|
44
|
+
# Return the links that the resource has
|
50
45
|
def links
|
51
|
-
|
52
|
-
|
46
|
+
@links_links ||= Links.new(@links)
|
47
|
+
end
|
53
48
|
|
54
|
-
|
55
|
-
|
49
|
+
# Provides the event resource as a hash of all its readable attributes
|
50
|
+
def to_h
|
51
|
+
@object
|
52
|
+
end
|
56
53
|
|
57
|
-
|
54
|
+
class Links
|
55
|
+
def initialize(links)
|
56
|
+
@links = links
|
57
|
+
end
|
58
58
|
|
59
|
-
|
59
|
+
def mandate
|
60
|
+
@links['mandate']
|
61
|
+
end
|
60
62
|
|
61
|
-
|
63
|
+
def new_customer_bank_account
|
64
|
+
@links['new_customer_bank_account']
|
65
|
+
end
|
62
66
|
|
63
|
-
|
67
|
+
def new_mandate
|
68
|
+
@links['new_mandate']
|
69
|
+
end
|
64
70
|
|
65
|
-
|
71
|
+
def organisation
|
72
|
+
@links['organisation']
|
73
|
+
end
|
66
74
|
|
67
|
-
|
75
|
+
def parent_event
|
76
|
+
@links['parent_event']
|
77
|
+
end
|
68
78
|
|
69
|
-
|
79
|
+
def payment
|
80
|
+
@links['payment']
|
81
|
+
end
|
70
82
|
|
71
|
-
|
83
|
+
def payout
|
84
|
+
@links['payout']
|
85
|
+
end
|
72
86
|
|
73
|
-
|
87
|
+
def previous_customer_bank_account
|
88
|
+
@links['previous_customer_bank_account']
|
89
|
+
end
|
74
90
|
|
75
|
-
|
76
|
-
|
77
|
-
def initialize(hash)
|
78
|
-
hash.each do |key, val|
|
79
|
-
send("#{key}=", val)
|
80
|
-
end
|
81
|
-
end
|
91
|
+
def refund
|
92
|
+
@links['refund']
|
82
93
|
end
|
83
|
-
links_class.new(valid_links)
|
84
|
-
end
|
85
94
|
|
86
|
-
|
87
|
-
|
88
|
-
|
95
|
+
def subscription
|
96
|
+
@links['subscription']
|
97
|
+
end
|
89
98
|
end
|
90
99
|
end
|
91
100
|
end
|