gocardless-pro 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +132 -0
- data/circle.yml +18 -0
- data/demo.rb +10 -0
- data/gocardless-pro.gemspec +27 -0
- data/lib/gocardless-pro.rb +243 -0
- data/lib/gocardless-pro/api_service.rb +57 -0
- data/lib/gocardless-pro/error.rb +42 -0
- data/lib/gocardless-pro/error/gocardless_error.rb +5 -0
- data/lib/gocardless-pro/error/invalid_api_usage_error.rb +5 -0
- data/lib/gocardless-pro/error/invalid_state_error.rb +5 -0
- data/lib/gocardless-pro/error/validation_error.rb +5 -0
- data/lib/gocardless-pro/list_response.rb +34 -0
- data/lib/gocardless-pro/paginator.rb +37 -0
- data/lib/gocardless-pro/request.rb +69 -0
- data/lib/gocardless-pro/resources/api_key.rb +62 -0
- data/lib/gocardless-pro/resources/creditor.rb +83 -0
- data/lib/gocardless-pro/resources/creditor_bank_account.rb +78 -0
- data/lib/gocardless-pro/resources/customer.rb +72 -0
- data/lib/gocardless-pro/resources/customer_bank_account.rb +80 -0
- data/lib/gocardless-pro/resources/event.rb +75 -0
- data/lib/gocardless-pro/resources/helper.rb +29 -0
- data/lib/gocardless-pro/resources/mandate.rb +70 -0
- data/lib/gocardless-pro/resources/payment.rb +86 -0
- data/lib/gocardless-pro/resources/payout.rb +66 -0
- data/lib/gocardless-pro/resources/publishable_api_key.rb +51 -0
- data/lib/gocardless-pro/resources/redirect_flow.rb +104 -0
- data/lib/gocardless-pro/resources/refund.rb +70 -0
- data/lib/gocardless-pro/resources/role.rb +101 -0
- data/lib/gocardless-pro/resources/subscription.rb +152 -0
- data/lib/gocardless-pro/resources/user.rb +60 -0
- data/lib/gocardless-pro/response.rb +77 -0
- data/lib/gocardless-pro/services/api_key_service.rb +130 -0
- data/lib/gocardless-pro/services/base_service.rb +29 -0
- data/lib/gocardless-pro/services/creditor_bank_account_service.rb +122 -0
- data/lib/gocardless-pro/services/creditor_service.rb +112 -0
- data/lib/gocardless-pro/services/customer_bank_account_service.rb +153 -0
- data/lib/gocardless-pro/services/customer_service.rb +112 -0
- data/lib/gocardless-pro/services/event_service.rb +80 -0
- data/lib/gocardless-pro/services/helper_service.rb +97 -0
- data/lib/gocardless-pro/services/mandate_service.rb +170 -0
- data/lib/gocardless-pro/services/payment_service.rb +164 -0
- data/lib/gocardless-pro/services/payout_service.rb +80 -0
- data/lib/gocardless-pro/services/publishable_api_key_service.rb +130 -0
- data/lib/gocardless-pro/services/redirect_flow_service.rb +96 -0
- data/lib/gocardless-pro/services/refund_service.rb +126 -0
- data/lib/gocardless-pro/services/role_service.rb +127 -0
- data/lib/gocardless-pro/services/subscription_service.rb +133 -0
- data/lib/gocardless-pro/services/user_service.rb +148 -0
- data/lib/gocardless-pro/version.rb +8 -0
- data/spec/api_service_spec.rb +69 -0
- data/spec/client_spec.rb +29 -0
- data/spec/error_spec.rb +44 -0
- data/spec/resources/api_key_spec.rb +85 -0
- data/spec/resources/creditor_bank_account_spec.rb +109 -0
- data/spec/resources/creditor_spec.rb +125 -0
- data/spec/resources/customer_bank_account_spec.rb +109 -0
- data/spec/resources/customer_spec.rb +127 -0
- data/spec/resources/event_spec.rb +113 -0
- data/spec/resources/helper_spec.rb +23 -0
- data/spec/resources/mandate_spec.rb +97 -0
- data/spec/resources/payment_spec.rb +129 -0
- data/spec/resources/payout_spec.rb +89 -0
- data/spec/resources/publishable_api_key_spec.rb +63 -0
- data/spec/resources/redirect_flow_spec.rb +97 -0
- data/spec/resources/refund_spec.rb +77 -0
- data/spec/resources/role_spec.rb +63 -0
- data/spec/resources/subscription_spec.rb +157 -0
- data/spec/resources/user_spec.rb +85 -0
- data/spec/response_spec.rb +79 -0
- data/spec/services/api_key_service_spec.rb +362 -0
- data/spec/services/creditor_bank_account_service_spec.rb +365 -0
- data/spec/services/creditor_service_spec.rb +339 -0
- data/spec/services/customer_bank_account_service_spec.rb +404 -0
- data/spec/services/customer_service_spec.rb +365 -0
- data/spec/services/event_service_spec.rb +172 -0
- data/spec/services/helper_service_spec.rb +123 -0
- data/spec/services/mandate_service_spec.rb +449 -0
- data/spec/services/payment_service_spec.rb +497 -0
- data/spec/services/payout_service_spec.rb +172 -0
- data/spec/services/publishable_api_key_service_spec.rb +336 -0
- data/spec/services/redirect_flow_service_spec.rb +208 -0
- data/spec/services/refund_service_spec.rb +279 -0
- data/spec/services/role_service_spec.rb +336 -0
- data/spec/services/subscription_service_spec.rb +488 -0
- data/spec/services/user_service_spec.rb +433 -0
- data/spec/spec_helper.rb +91 -0
- metadata +255 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
module Resources
|
14
|
+
# Customer objects hold the contact details for a customer. A customer can
|
15
|
+
# have several [customer bank
|
16
|
+
# accounts](https://developer.gocardless.com/pro/#api-endpoints-customer-bank-accounts),
|
17
|
+
# which in turn can have several Direct Debit
|
18
|
+
# [mandates](https://developer.gocardless.com/pro/#api-endpoints-mandates).
|
19
|
+
# Represents an instance of a customer resource returned from the API
|
20
|
+
class Customer
|
21
|
+
attr_reader :address_line1
|
22
|
+
|
23
|
+
attr_reader :address_line2
|
24
|
+
|
25
|
+
attr_reader :address_line3
|
26
|
+
|
27
|
+
attr_reader :city
|
28
|
+
|
29
|
+
attr_reader :country_code
|
30
|
+
|
31
|
+
attr_reader :created_at
|
32
|
+
|
33
|
+
attr_reader :email
|
34
|
+
|
35
|
+
attr_reader :family_name
|
36
|
+
|
37
|
+
attr_reader :given_name
|
38
|
+
|
39
|
+
attr_reader :id
|
40
|
+
|
41
|
+
attr_reader :metadata
|
42
|
+
|
43
|
+
attr_reader :postal_code
|
44
|
+
|
45
|
+
attr_reader :region
|
46
|
+
# initialize a resource instance
|
47
|
+
# @param object [Hash] an object returned from the API
|
48
|
+
def initialize(object)
|
49
|
+
@object = object
|
50
|
+
|
51
|
+
@address_line1 = object['address_line1']
|
52
|
+
@address_line2 = object['address_line2']
|
53
|
+
@address_line3 = object['address_line3']
|
54
|
+
@city = object['city']
|
55
|
+
@country_code = object['country_code']
|
56
|
+
@created_at = object['created_at']
|
57
|
+
@email = object['email']
|
58
|
+
@family_name = object['family_name']
|
59
|
+
@given_name = object['given_name']
|
60
|
+
@id = object['id']
|
61
|
+
@metadata = object['metadata']
|
62
|
+
@postal_code = object['postal_code']
|
63
|
+
@region = object['region']
|
64
|
+
end
|
65
|
+
|
66
|
+
# Provides the resource as a hash of all it's readable attributes
|
67
|
+
def to_h
|
68
|
+
@object
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
module Resources
|
14
|
+
# Customer Bank Accounts hold the bank details of a
|
15
|
+
# [customer](https://developer.gocardless.com/pro/#api-endpoints-customers).
|
16
|
+
# They always belong to a
|
17
|
+
# [customer](https://developer.gocardless.com/pro/#api-endpoints-customers),
|
18
|
+
# and may be linked to several Direct Debit
|
19
|
+
# [mandates](https://developer.gocardless.com/pro/#api-endpoints-mandates).
|
20
|
+
|
21
|
+
# #
|
22
|
+
# Note that customer bank accounts must be unique, and so you will
|
23
|
+
# encounter a `bank_account_exists` error if you try to create a duplicate
|
24
|
+
# bank account. You may wish to handle this by updating the existing record
|
25
|
+
# instead, the ID of which will be provided as links[customer_bank_account] in
|
26
|
+
# the error response.
|
27
|
+
# Represents an instance of a customer_bank_account resource returned from the API
|
28
|
+
class CustomerBankAccount
|
29
|
+
attr_reader :account_holder_name
|
30
|
+
|
31
|
+
attr_reader :account_number_ending
|
32
|
+
|
33
|
+
attr_reader :bank_name
|
34
|
+
|
35
|
+
attr_reader :country_code
|
36
|
+
|
37
|
+
attr_reader :created_at
|
38
|
+
|
39
|
+
attr_reader :currency
|
40
|
+
|
41
|
+
attr_reader :enabled
|
42
|
+
|
43
|
+
attr_reader :id
|
44
|
+
|
45
|
+
attr_reader :metadata
|
46
|
+
# initialize a resource instance
|
47
|
+
# @param object [Hash] an object returned from the API
|
48
|
+
def initialize(object)
|
49
|
+
@object = object
|
50
|
+
|
51
|
+
@account_holder_name = object['account_holder_name']
|
52
|
+
@account_number_ending = object['account_number_ending']
|
53
|
+
@bank_name = object['bank_name']
|
54
|
+
@country_code = object['country_code']
|
55
|
+
@created_at = object['created_at']
|
56
|
+
@currency = object['currency']
|
57
|
+
@enabled = object['enabled']
|
58
|
+
@id = object['id']
|
59
|
+
@links = object['links']
|
60
|
+
@metadata = object['metadata']
|
61
|
+
end
|
62
|
+
|
63
|
+
# return the links that the resource has
|
64
|
+
def links
|
65
|
+
Struct.new(
|
66
|
+
*{
|
67
|
+
|
68
|
+
customer: ''
|
69
|
+
|
70
|
+
}.keys.sort
|
71
|
+
).new(*@links.sort.map(&:last))
|
72
|
+
end
|
73
|
+
|
74
|
+
# Provides the resource as a hash of all it's readable attributes
|
75
|
+
def to_h
|
76
|
+
@object
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
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
|
+
# Represents an instance of a event resource returned from the API
|
18
|
+
class Event
|
19
|
+
attr_reader :action
|
20
|
+
|
21
|
+
attr_reader :created_at
|
22
|
+
|
23
|
+
attr_reader :details
|
24
|
+
|
25
|
+
attr_reader :id
|
26
|
+
|
27
|
+
attr_reader :metadata
|
28
|
+
|
29
|
+
attr_reader :resource_type
|
30
|
+
# initialize a resource instance
|
31
|
+
# @param object [Hash] an object returned from the API
|
32
|
+
def initialize(object)
|
33
|
+
@object = object
|
34
|
+
|
35
|
+
@action = object['action']
|
36
|
+
@created_at = object['created_at']
|
37
|
+
@details = object['details']
|
38
|
+
@id = object['id']
|
39
|
+
@links = object['links']
|
40
|
+
@metadata = object['metadata']
|
41
|
+
@resource_type = object['resource_type']
|
42
|
+
end
|
43
|
+
|
44
|
+
# return the links that the resource has
|
45
|
+
def links
|
46
|
+
Struct.new(
|
47
|
+
*{
|
48
|
+
|
49
|
+
mandate: '',
|
50
|
+
|
51
|
+
new_customer_bank_account: '',
|
52
|
+
|
53
|
+
parent_event: '',
|
54
|
+
|
55
|
+
payment: '',
|
56
|
+
|
57
|
+
payout: '',
|
58
|
+
|
59
|
+
previous_customer_bank_account: '',
|
60
|
+
|
61
|
+
refund: '',
|
62
|
+
|
63
|
+
subscription: ''
|
64
|
+
|
65
|
+
}.keys.sort
|
66
|
+
).new(*@links.sort.map(&:last))
|
67
|
+
end
|
68
|
+
|
69
|
+
# Provides the resource as a hash of all it's readable attributes
|
70
|
+
def to_h
|
71
|
+
@object
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
module Resources
|
14
|
+
#
|
15
|
+
# Represents an instance of a helper resource returned from the API
|
16
|
+
class Helper
|
17
|
+
# initialize a resource instance
|
18
|
+
# @param object [Hash] an object returned from the API
|
19
|
+
def initialize(object)
|
20
|
+
@object = object
|
21
|
+
end
|
22
|
+
|
23
|
+
# Provides the resource as a hash of all it's readable attributes
|
24
|
+
def to_h
|
25
|
+
@object
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
module Resources
|
14
|
+
# Mandates represent the Direct Debit mandate with a
|
15
|
+
# [customer](https://developer.gocardless.com/pro/#api-endpoints-customers).
|
16
|
+
|
17
|
+
# #
|
18
|
+
# GoCardless will notify you via a
|
19
|
+
# [webhook](https://developer.gocardless.com/pro/#webhooks) whenever the
|
20
|
+
# status of a mandate changes.
|
21
|
+
# Represents an instance of a mandate resource returned from the API
|
22
|
+
class Mandate
|
23
|
+
attr_reader :created_at
|
24
|
+
|
25
|
+
attr_reader :id
|
26
|
+
|
27
|
+
attr_reader :metadata
|
28
|
+
|
29
|
+
attr_reader :next_possible_charge_date
|
30
|
+
|
31
|
+
attr_reader :reference
|
32
|
+
|
33
|
+
attr_reader :scheme
|
34
|
+
|
35
|
+
attr_reader :status
|
36
|
+
# initialize a resource instance
|
37
|
+
# @param object [Hash] an object returned from the API
|
38
|
+
def initialize(object)
|
39
|
+
@object = object
|
40
|
+
|
41
|
+
@created_at = object['created_at']
|
42
|
+
@id = object['id']
|
43
|
+
@links = object['links']
|
44
|
+
@metadata = object['metadata']
|
45
|
+
@next_possible_charge_date = object['next_possible_charge_date']
|
46
|
+
@reference = object['reference']
|
47
|
+
@scheme = object['scheme']
|
48
|
+
@status = object['status']
|
49
|
+
end
|
50
|
+
|
51
|
+
# return the links that the resource has
|
52
|
+
def links
|
53
|
+
Struct.new(
|
54
|
+
*{
|
55
|
+
|
56
|
+
creditor: '',
|
57
|
+
|
58
|
+
customer_bank_account: ''
|
59
|
+
|
60
|
+
}.keys.sort
|
61
|
+
).new(*@links.sort.map(&:last))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Provides the resource as a hash of all it's readable attributes
|
65
|
+
def to_h
|
66
|
+
@object
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
module Resources
|
14
|
+
# Payment objects represent payments from a
|
15
|
+
# [customer](https://developer.gocardless.com/pro/#api-endpoints-customers) to
|
16
|
+
# a [creditor](https://developer.gocardless.com/pro/#api-endpoints-creditors),
|
17
|
+
# taken against a Direct Debit
|
18
|
+
# [mandate](https://developer.gocardless.com/pro/#api-endpoints-mandates).
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# GoCardless will notify you via a
|
22
|
+
# [webhook](https://developer.gocardless.com/pro/#webhooks) whenever the state
|
23
|
+
# of a payment changes.
|
24
|
+
# Represents an instance of a payment resource returned from the API
|
25
|
+
class Payment
|
26
|
+
attr_reader :amount
|
27
|
+
|
28
|
+
attr_reader :amount_refunded
|
29
|
+
|
30
|
+
attr_reader :charge_date
|
31
|
+
|
32
|
+
attr_reader :created_at
|
33
|
+
|
34
|
+
attr_reader :currency
|
35
|
+
|
36
|
+
attr_reader :description
|
37
|
+
|
38
|
+
attr_reader :id
|
39
|
+
|
40
|
+
attr_reader :metadata
|
41
|
+
|
42
|
+
attr_reader :reference
|
43
|
+
|
44
|
+
attr_reader :status
|
45
|
+
# initialize a resource instance
|
46
|
+
# @param object [Hash] an object returned from the API
|
47
|
+
def initialize(object)
|
48
|
+
@object = object
|
49
|
+
|
50
|
+
@amount = object['amount']
|
51
|
+
@amount_refunded = object['amount_refunded']
|
52
|
+
@charge_date = object['charge_date']
|
53
|
+
@created_at = object['created_at']
|
54
|
+
@currency = object['currency']
|
55
|
+
@description = object['description']
|
56
|
+
@id = object['id']
|
57
|
+
@links = object['links']
|
58
|
+
@metadata = object['metadata']
|
59
|
+
@reference = object['reference']
|
60
|
+
@status = object['status']
|
61
|
+
end
|
62
|
+
|
63
|
+
# return the links that the resource has
|
64
|
+
def links
|
65
|
+
Struct.new(
|
66
|
+
*{
|
67
|
+
|
68
|
+
creditor: '',
|
69
|
+
|
70
|
+
mandate: '',
|
71
|
+
|
72
|
+
payout: '',
|
73
|
+
|
74
|
+
subscription: ''
|
75
|
+
|
76
|
+
}.keys.sort
|
77
|
+
).new(*@links.sort.map(&:last))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Provides the resource as a hash of all it's readable attributes
|
81
|
+
def to_h
|
82
|
+
@object
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
#
|
5
|
+
# WARNING: Do not edit by hand, this file was generated by Crank:
|
6
|
+
#
|
7
|
+
# https://github.com/gocardless/crank
|
8
|
+
#
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
module GoCardless
|
12
|
+
# A module containing classes for each of the resources in the GC Api
|
13
|
+
module Resources
|
14
|
+
# Payouts represent transfers from GoCardless to a
|
15
|
+
# [creditor](https://developer.gocardless.com/pro/#api-endpoints-creditors).
|
16
|
+
# Each payout contains the funds collected from one or many
|
17
|
+
# [payments](https://developer.gocardless.com/pro/#api-endpoints-payments).
|
18
|
+
# Payouts are created automatically after a payment has been successfully
|
19
|
+
# collected.
|
20
|
+
# Represents an instance of a payout resource returned from the API
|
21
|
+
class Payout
|
22
|
+
attr_reader :amount
|
23
|
+
|
24
|
+
attr_reader :created_at
|
25
|
+
|
26
|
+
attr_reader :currency
|
27
|
+
|
28
|
+
attr_reader :id
|
29
|
+
|
30
|
+
attr_reader :reference
|
31
|
+
|
32
|
+
attr_reader :status
|
33
|
+
# initialize a resource instance
|
34
|
+
# @param object [Hash] an object returned from the API
|
35
|
+
def initialize(object)
|
36
|
+
@object = object
|
37
|
+
|
38
|
+
@amount = object['amount']
|
39
|
+
@created_at = object['created_at']
|
40
|
+
@currency = object['currency']
|
41
|
+
@id = object['id']
|
42
|
+
@links = object['links']
|
43
|
+
@reference = object['reference']
|
44
|
+
@status = object['status']
|
45
|
+
end
|
46
|
+
|
47
|
+
# return the links that the resource has
|
48
|
+
def links
|
49
|
+
Struct.new(
|
50
|
+
*{
|
51
|
+
|
52
|
+
creditor: '',
|
53
|
+
|
54
|
+
creditor_bank_account: ''
|
55
|
+
|
56
|
+
}.keys.sort
|
57
|
+
).new(*@links.sort.map(&:last))
|
58
|
+
end
|
59
|
+
|
60
|
+
# Provides the resource as a hash of all it's readable attributes
|
61
|
+
def to_h
|
62
|
+
@object
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|