gocardless_pro 0.3.0 → 1.0.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 +14 -29
- data/lib/gocardless_pro.rb +7 -3
- data/lib/gocardless_pro/api_response.rb +14 -0
- data/lib/gocardless_pro/client.rb +24 -12
- data/lib/gocardless_pro/list_response.rb +7 -3
- data/lib/gocardless_pro/request.rb +3 -11
- data/lib/gocardless_pro/resources/{helper.rb → bank_details_lookup.rb} +15 -4
- data/lib/gocardless_pro/resources/creditor.rb +14 -13
- data/lib/gocardless_pro/resources/creditor_bank_account.rb +14 -10
- data/lib/gocardless_pro/resources/customer.rb +8 -4
- data/lib/gocardless_pro/resources/customer_bank_account.rb +15 -13
- data/lib/gocardless_pro/resources/event.rb +6 -1
- data/lib/gocardless_pro/resources/mandate.rb +10 -7
- data/lib/gocardless_pro/resources/mandate_pdf.rb +42 -0
- data/lib/gocardless_pro/resources/payment.rb +12 -11
- data/lib/gocardless_pro/resources/payout.rb +9 -6
- data/lib/gocardless_pro/resources/redirect_flow.rb +24 -30
- data/lib/gocardless_pro/resources/refund.rb +15 -15
- data/lib/gocardless_pro/resources/subscription.rb +26 -22
- data/lib/gocardless_pro/response.rb +5 -0
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +55 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +8 -9
- data/lib/gocardless_pro/services/creditors_service.rb +6 -7
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +15 -18
- data/lib/gocardless_pro/services/customers_service.rb +6 -7
- data/lib/gocardless_pro/services/events_service.rb +4 -6
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +63 -0
- data/lib/gocardless_pro/services/mandates_service.rb +12 -24
- data/lib/gocardless_pro/services/payments_service.rb +15 -16
- data/lib/gocardless_pro/services/payouts_service.rb +5 -6
- data/lib/gocardless_pro/services/redirect_flows_service.rb +13 -17
- data/lib/gocardless_pro/services/refunds_service.rb +16 -19
- data/lib/gocardless_pro/services/subscriptions_service.rb +10 -11
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/api_response_spec.rb +28 -0
- data/spec/resources/bank_details_lookup_spec.rb +39 -0
- data/spec/resources/creditor_spec.rb +0 -4
- data/spec/resources/{helper_spec.rb → mandate_pdf_spec.rb} +17 -1
- data/spec/resources/subscription_spec.rb +4 -4
- data/spec/services/bank_details_lookups_service_spec.rb +80 -0
- data/spec/services/creditor_bank_accounts_service_spec.rb +2 -0
- data/spec/services/creditors_service_spec.rb +2 -0
- data/spec/services/customer_bank_accounts_service_spec.rb +2 -0
- data/spec/services/customers_service_spec.rb +2 -0
- data/spec/services/events_service_spec.rb +2 -0
- data/spec/services/mandate_pdfs_service_spec.rb +80 -0
- data/spec/services/mandates_service_spec.rb +2 -0
- data/spec/services/payments_service_spec.rb +2 -0
- data/spec/services/payouts_service_spec.rb +2 -0
- data/spec/services/refunds_service_spec.rb +2 -0
- data/spec/services/subscriptions_service_spec.rb +26 -24
- metadata +17 -8
- data/lib/gocardless_pro/services/helpers_service.rb +0 -99
- data/spec/services/helpers_service_spec.rb +0 -122
@@ -22,12 +22,11 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
-
Resources::CreditorBankAccount.new(unenvelope_body(response.body))
|
25
|
+
Resources::CreditorBankAccount.new(unenvelope_body(response.body), response)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Returns a
|
29
|
-
#
|
30
|
-
# list of your creditor bank accounts.
|
28
|
+
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your
|
29
|
+
# creditor bank accounts.
|
31
30
|
# Example URL: /creditor_bank_accounts
|
32
31
|
# @param options [Hash] parameters as a hash, under a params key.
|
33
32
|
def list(options = {})
|
@@ -35,7 +34,7 @@ module GoCardlessPro
|
|
35
34
|
|
36
35
|
response = make_request(:get, path, options)
|
37
36
|
ListResponse.new(
|
38
|
-
|
37
|
+
response: response,
|
39
38
|
unenveloped_body: unenvelope_body(response.body),
|
40
39
|
resource_class: Resources::CreditorBankAccount
|
41
40
|
)
|
@@ -57,7 +56,7 @@ module GoCardlessPro
|
|
57
56
|
# Retrieves the details of an existing creditor bank account.
|
58
57
|
# Example URL: /creditor_bank_accounts/:identity
|
59
58
|
#
|
60
|
-
# @param identity # Unique identifier, beginning with "BA"
|
59
|
+
# @param identity # Unique identifier, beginning with "BA".
|
61
60
|
# @param options [Hash] parameters as a hash, under a params key.
|
62
61
|
def get(identity, options = {})
|
63
62
|
path = sub_url('/creditor_bank_accounts/:identity', 'identity' => identity)
|
@@ -65,7 +64,7 @@ module GoCardlessPro
|
|
65
64
|
response = make_request(:get, path, options)
|
66
65
|
|
67
66
|
return if response.body.nil?
|
68
|
-
Resources::CreditorBankAccount.new(unenvelope_body(response.body))
|
67
|
+
Resources::CreditorBankAccount.new(unenvelope_body(response.body), response)
|
69
68
|
end
|
70
69
|
|
71
70
|
# Immediately disables the bank account, no money can be paid out to a disabled
|
@@ -78,7 +77,7 @@ module GoCardlessPro
|
|
78
77
|
# creating a new bank account resource with the same details.
|
79
78
|
# Example URL: /creditor_bank_accounts/:identity/actions/disable
|
80
79
|
#
|
81
|
-
# @param identity # Unique identifier, beginning with "BA"
|
80
|
+
# @param identity # Unique identifier, beginning with "BA".
|
82
81
|
# @param options [Hash] parameters as a hash, under a params key.
|
83
82
|
def disable(identity, options = {})
|
84
83
|
path = sub_url('/creditor_bank_accounts/:identity/actions/disable', 'identity' => identity)
|
@@ -89,7 +88,7 @@ module GoCardlessPro
|
|
89
88
|
response = make_request(:post, path, options)
|
90
89
|
|
91
90
|
return if response.body.nil?
|
92
|
-
Resources::CreditorBankAccount.new(unenvelope_body(response.body))
|
91
|
+
Resources::CreditorBankAccount.new(unenvelope_body(response.body), response)
|
93
92
|
end
|
94
93
|
|
95
94
|
# Unenvelope the response of the body using the service's `envelope_key`
|
@@ -22,12 +22,11 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
-
Resources::Creditor.new(unenvelope_body(response.body))
|
25
|
+
Resources::Creditor.new(unenvelope_body(response.body), response)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Returns a
|
29
|
-
#
|
30
|
-
# list of your creditors.
|
28
|
+
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your
|
29
|
+
# creditors.
|
31
30
|
# Example URL: /creditors
|
32
31
|
# @param options [Hash] parameters as a hash, under a params key.
|
33
32
|
def list(options = {})
|
@@ -35,7 +34,7 @@ module GoCardlessPro
|
|
35
34
|
|
36
35
|
response = make_request(:get, path, options)
|
37
36
|
ListResponse.new(
|
38
|
-
|
37
|
+
response: response,
|
39
38
|
unenveloped_body: unenvelope_body(response.body),
|
40
39
|
resource_class: Resources::Creditor
|
41
40
|
)
|
@@ -65,7 +64,7 @@ module GoCardlessPro
|
|
65
64
|
response = make_request(:get, path, options)
|
66
65
|
|
67
66
|
return if response.body.nil?
|
68
|
-
Resources::Creditor.new(unenvelope_body(response.body))
|
67
|
+
Resources::Creditor.new(unenvelope_body(response.body), response)
|
69
68
|
end
|
70
69
|
|
71
70
|
# Updates a creditor object. Supports all of the fields supported when creating
|
@@ -83,7 +82,7 @@ module GoCardlessPro
|
|
83
82
|
response = make_request(:put, path, options)
|
84
83
|
|
85
84
|
return if response.body.nil?
|
86
|
-
Resources::Creditor.new(unenvelope_body(response.body))
|
85
|
+
Resources::Creditor.new(unenvelope_body(response.body), response)
|
87
86
|
end
|
88
87
|
|
89
88
|
# Unenvelope the response of the body using the service's `envelope_key`
|
@@ -16,18 +16,16 @@ module GoCardlessPro
|
|
16
16
|
# ways to supply bank account details:
|
17
17
|
#
|
18
18
|
# - [Local
|
19
|
-
# details](
|
20
|
-
#
|
19
|
+
# details](#ui-local-bank-details)
|
21
20
|
#
|
22
21
|
# - IBAN
|
23
22
|
#
|
24
23
|
# - [Customer Bank Account
|
25
|
-
# Tokens](
|
26
|
-
#
|
24
|
+
# Tokens](#js-flow-create-a-customer-bank-account-token)
|
27
25
|
#
|
28
|
-
# For more
|
29
|
-
# [local bank
|
30
|
-
# details](
|
26
|
+
# For more
|
27
|
+
# information on the different fields required in each country, see [local bank
|
28
|
+
# details](#ui-local-bank-details).
|
31
29
|
# Example URL: /customer_bank_accounts
|
32
30
|
# @param options [Hash] parameters as a hash, under a params key.
|
33
31
|
def create(options = {})
|
@@ -39,12 +37,11 @@ module GoCardlessPro
|
|
39
37
|
response = make_request(:post, path, options)
|
40
38
|
|
41
39
|
return if response.body.nil?
|
42
|
-
Resources::CustomerBankAccount.new(unenvelope_body(response.body))
|
40
|
+
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
43
41
|
end
|
44
42
|
|
45
|
-
# Returns a
|
46
|
-
#
|
47
|
-
# list of your bank accounts.
|
43
|
+
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your bank
|
44
|
+
# accounts.
|
48
45
|
# Example URL: /customer_bank_accounts
|
49
46
|
# @param options [Hash] parameters as a hash, under a params key.
|
50
47
|
def list(options = {})
|
@@ -52,7 +49,7 @@ module GoCardlessPro
|
|
52
49
|
|
53
50
|
response = make_request(:get, path, options)
|
54
51
|
ListResponse.new(
|
55
|
-
|
52
|
+
response: response,
|
56
53
|
unenveloped_body: unenvelope_body(response.body),
|
57
54
|
resource_class: Resources::CustomerBankAccount
|
58
55
|
)
|
@@ -74,7 +71,7 @@ module GoCardlessPro
|
|
74
71
|
# Retrieves the details of an existing bank account.
|
75
72
|
# Example URL: /customer_bank_accounts/:identity
|
76
73
|
#
|
77
|
-
# @param identity # Unique identifier, beginning with "BA"
|
74
|
+
# @param identity # Unique identifier, beginning with "BA".
|
78
75
|
# @param options [Hash] parameters as a hash, under a params key.
|
79
76
|
def get(identity, options = {})
|
80
77
|
path = sub_url('/customer_bank_accounts/:identity', 'identity' => identity)
|
@@ -82,14 +79,14 @@ module GoCardlessPro
|
|
82
79
|
response = make_request(:get, path, options)
|
83
80
|
|
84
81
|
return if response.body.nil?
|
85
|
-
Resources::CustomerBankAccount.new(unenvelope_body(response.body))
|
82
|
+
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
86
83
|
end
|
87
84
|
|
88
85
|
# Updates a customer bank account object. Only the metadata parameter is
|
89
86
|
# allowed.
|
90
87
|
# Example URL: /customer_bank_accounts/:identity
|
91
88
|
#
|
92
|
-
# @param identity # Unique identifier, beginning with "BA"
|
89
|
+
# @param identity # Unique identifier, beginning with "BA".
|
93
90
|
# @param options [Hash] parameters as a hash, under a params key.
|
94
91
|
def update(identity, options = {})
|
95
92
|
path = sub_url('/customer_bank_accounts/:identity', 'identity' => identity)
|
@@ -100,7 +97,7 @@ module GoCardlessPro
|
|
100
97
|
response = make_request(:put, path, options)
|
101
98
|
|
102
99
|
return if response.body.nil?
|
103
|
-
Resources::CustomerBankAccount.new(unenvelope_body(response.body))
|
100
|
+
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
104
101
|
end
|
105
102
|
|
106
103
|
# Immediately cancels all associated mandates and cancellable payments.
|
@@ -113,7 +110,7 @@ module GoCardlessPro
|
|
113
110
|
# bank account resource with the same details.
|
114
111
|
# Example URL: /customer_bank_accounts/:identity/actions/disable
|
115
112
|
#
|
116
|
-
# @param identity # Unique identifier, beginning with "BA"
|
113
|
+
# @param identity # Unique identifier, beginning with "BA".
|
117
114
|
# @param options [Hash] parameters as a hash, under a params key.
|
118
115
|
def disable(identity, options = {})
|
119
116
|
path = sub_url('/customer_bank_accounts/:identity/actions/disable', 'identity' => identity)
|
@@ -124,7 +121,7 @@ module GoCardlessPro
|
|
124
121
|
response = make_request(:post, path, options)
|
125
122
|
|
126
123
|
return if response.body.nil?
|
127
|
-
Resources::CustomerBankAccount.new(unenvelope_body(response.body))
|
124
|
+
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
128
125
|
end
|
129
126
|
|
130
127
|
# Unenvelope the response of the body using the service's `envelope_key`
|
@@ -22,12 +22,11 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
-
Resources::Customer.new(unenvelope_body(response.body))
|
25
|
+
Resources::Customer.new(unenvelope_body(response.body), response)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Returns a
|
29
|
-
#
|
30
|
-
# list of your customers.
|
28
|
+
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your
|
29
|
+
# customers.
|
31
30
|
# Example URL: /customers
|
32
31
|
# @param options [Hash] parameters as a hash, under a params key.
|
33
32
|
def list(options = {})
|
@@ -35,7 +34,7 @@ module GoCardlessPro
|
|
35
34
|
|
36
35
|
response = make_request(:get, path, options)
|
37
36
|
ListResponse.new(
|
38
|
-
|
37
|
+
response: response,
|
39
38
|
unenveloped_body: unenvelope_body(response.body),
|
40
39
|
resource_class: Resources::Customer
|
41
40
|
)
|
@@ -65,7 +64,7 @@ module GoCardlessPro
|
|
65
64
|
response = make_request(:get, path, options)
|
66
65
|
|
67
66
|
return if response.body.nil?
|
68
|
-
Resources::Customer.new(unenvelope_body(response.body))
|
67
|
+
Resources::Customer.new(unenvelope_body(response.body), response)
|
69
68
|
end
|
70
69
|
|
71
70
|
# Updates a customer object. Supports all of the fields supported when creating
|
@@ -83,7 +82,7 @@ module GoCardlessPro
|
|
83
82
|
response = make_request(:put, path, options)
|
84
83
|
|
85
84
|
return if response.body.nil?
|
86
|
-
Resources::Customer.new(unenvelope_body(response.body))
|
85
|
+
Resources::Customer.new(unenvelope_body(response.body), response)
|
87
86
|
end
|
88
87
|
|
89
88
|
# Unenvelope the response of the body using the service's `envelope_key`
|
@@ -10,9 +10,7 @@ module GoCardlessPro
|
|
10
10
|
module Services
|
11
11
|
# Service for making requests to the Event endpoints
|
12
12
|
class EventsService < BaseService
|
13
|
-
# Returns a
|
14
|
-
# [cursor-paginated](https://developer.gocardless.com/pro/2015-04-29/#overview-cursor-pagination)
|
15
|
-
# list of your events.
|
13
|
+
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your events.
|
16
14
|
# Example URL: /events
|
17
15
|
# @param options [Hash] parameters as a hash, under a params key.
|
18
16
|
def list(options = {})
|
@@ -20,7 +18,7 @@ module GoCardlessPro
|
|
20
18
|
|
21
19
|
response = make_request(:get, path, options)
|
22
20
|
ListResponse.new(
|
23
|
-
|
21
|
+
response: response,
|
24
22
|
unenveloped_body: unenvelope_body(response.body),
|
25
23
|
resource_class: Resources::Event
|
26
24
|
)
|
@@ -42,7 +40,7 @@ module GoCardlessPro
|
|
42
40
|
# Retrieves the details of a single event.
|
43
41
|
# Example URL: /events/:identity
|
44
42
|
#
|
45
|
-
# @param identity # Unique identifier, beginning with "EV"
|
43
|
+
# @param identity # Unique identifier, beginning with "EV".
|
46
44
|
# @param options [Hash] parameters as a hash, under a params key.
|
47
45
|
def get(identity, options = {})
|
48
46
|
path = sub_url('/events/:identity', 'identity' => identity)
|
@@ -50,7 +48,7 @@ module GoCardlessPro
|
|
50
48
|
response = make_request(:get, path, options)
|
51
49
|
|
52
50
|
return if response.body.nil?
|
53
|
-
Resources::Event.new(unenvelope_body(response.body))
|
51
|
+
Resources::Event.new(unenvelope_body(response.body), response)
|
54
52
|
end
|
55
53
|
|
56
54
|
# Unenvelope the response of the body using the service's `envelope_key`
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative './base_service'
|
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
|
+
module GoCardlessPro
|
10
|
+
module Services
|
11
|
+
# Service for making requests to the MandatePdf endpoints
|
12
|
+
class MandatePdfsService < BaseService
|
13
|
+
# Generates a PDF mandate and returns its temporary URL.
|
14
|
+
#
|
15
|
+
# Customer and bank
|
16
|
+
# account details can be left blank (for a blank mandate), provided manually, or
|
17
|
+
# inferred from the ID of an existing [mandate](#core-endpoints-mandates).
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# To generate a PDF mandate in a foreign language, set your `Accept-Language`
|
21
|
+
# header to the relevant [ISO
|
22
|
+
# 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table)
|
23
|
+
# language code. Supported languages are Dutch, English, French, German,
|
24
|
+
# Italian, Portuguese and Spanish.
|
25
|
+
# Example URL: /mandate_pdfs
|
26
|
+
# @param options [Hash] parameters as a hash, under a params key.
|
27
|
+
def create(options = {})
|
28
|
+
path = '/mandate_pdfs'
|
29
|
+
|
30
|
+
params = options.delete(:params) || {}
|
31
|
+
options[:params] = {}
|
32
|
+
options[:params][envelope_key] = params
|
33
|
+
response = make_request(:post, path, options)
|
34
|
+
|
35
|
+
return if response.body.nil?
|
36
|
+
Resources::MandatePdf.new(unenvelope_body(response.body), response)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Unenvelope the response of the body using the service's `envelope_key`
|
40
|
+
#
|
41
|
+
# @param body [Hash]
|
42
|
+
def unenvelope_body(body)
|
43
|
+
body[envelope_key] || body['data']
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# return the key which API responses will envelope data under
|
49
|
+
def envelope_key
|
50
|
+
'mandate_pdfs'
|
51
|
+
end
|
52
|
+
|
53
|
+
# take a URL with placeholder params and substitute them out for the acutal value
|
54
|
+
# @param url [String] the URL with placeholders in
|
55
|
+
# @param param_map [Hash] a hash of placeholders and their actual values
|
56
|
+
def sub_url(url, param_map)
|
57
|
+
param_map.reduce(url) do |new_url, (param, value)|
|
58
|
+
new_url.gsub(":#{param}", value)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -22,13 +22,11 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
-
Resources::Mandate.new(unenvelope_body(response.body))
|
25
|
+
Resources::Mandate.new(unenvelope_body(response.body), response)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Returns a
|
29
|
-
#
|
30
|
-
# list of your mandates. Except where stated, these filters can only be used one
|
31
|
-
# at a time.
|
28
|
+
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your
|
29
|
+
# mandates. Except where stated, these filters can only be used one at a time.
|
32
30
|
# Example URL: /mandates
|
33
31
|
# @param options [Hash] parameters as a hash, under a params key.
|
34
32
|
def list(options = {})
|
@@ -36,7 +34,7 @@ module GoCardlessPro
|
|
36
34
|
|
37
35
|
response = make_request(:get, path, options)
|
38
36
|
ListResponse.new(
|
39
|
-
|
37
|
+
response: response,
|
40
38
|
unenveloped_body: unenvelope_body(response.body),
|
41
39
|
resource_class: Resources::Mandate
|
42
40
|
)
|
@@ -56,19 +54,9 @@ module GoCardlessPro
|
|
56
54
|
end
|
57
55
|
|
58
56
|
# Retrieves the details of an existing mandate.
|
59
|
-
#
|
60
|
-
# If you specify `Accept:
|
61
|
-
# application/pdf` on a request to this endpoint it will return a PDF complying
|
62
|
-
# to the relevant scheme rules, which you can present to your customer.
|
63
|
-
#
|
64
|
-
# PDF
|
65
|
-
# mandates can be retrieved in Dutch, English, French, German, Italian,
|
66
|
-
# Portuguese and Spanish by specifying the [ISO
|
67
|
-
# 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table)
|
68
|
-
# language code as an `Accept-Language` header.
|
69
57
|
# Example URL: /mandates/:identity
|
70
58
|
#
|
71
|
-
# @param identity # Unique identifier, beginning with "MD"
|
59
|
+
# @param identity # Unique identifier, beginning with "MD".
|
72
60
|
# @param options [Hash] parameters as a hash, under a params key.
|
73
61
|
def get(identity, options = {})
|
74
62
|
path = sub_url('/mandates/:identity', 'identity' => identity)
|
@@ -76,13 +64,13 @@ module GoCardlessPro
|
|
76
64
|
response = make_request(:get, path, options)
|
77
65
|
|
78
66
|
return if response.body.nil?
|
79
|
-
Resources::Mandate.new(unenvelope_body(response.body))
|
67
|
+
Resources::Mandate.new(unenvelope_body(response.body), response)
|
80
68
|
end
|
81
69
|
|
82
70
|
# Updates a mandate object. This accepts only the metadata parameter.
|
83
71
|
# Example URL: /mandates/:identity
|
84
72
|
#
|
85
|
-
# @param identity # Unique identifier, beginning with "MD"
|
73
|
+
# @param identity # Unique identifier, beginning with "MD".
|
86
74
|
# @param options [Hash] parameters as a hash, under a params key.
|
87
75
|
def update(identity, options = {})
|
88
76
|
path = sub_url('/mandates/:identity', 'identity' => identity)
|
@@ -93,7 +81,7 @@ module GoCardlessPro
|
|
93
81
|
response = make_request(:put, path, options)
|
94
82
|
|
95
83
|
return if response.body.nil?
|
96
|
-
Resources::Mandate.new(unenvelope_body(response.body))
|
84
|
+
Resources::Mandate.new(unenvelope_body(response.body), response)
|
97
85
|
end
|
98
86
|
|
99
87
|
# Immediately cancels a mandate and all associated cancellable payments. Any
|
@@ -104,7 +92,7 @@ module GoCardlessPro
|
|
104
92
|
# mandate is already cancelled.
|
105
93
|
# Example URL: /mandates/:identity/actions/cancel
|
106
94
|
#
|
107
|
-
# @param identity # Unique identifier, beginning with "MD"
|
95
|
+
# @param identity # Unique identifier, beginning with "MD".
|
108
96
|
# @param options [Hash] parameters as a hash, under a params key.
|
109
97
|
def cancel(identity, options = {})
|
110
98
|
path = sub_url('/mandates/:identity/actions/cancel', 'identity' => identity)
|
@@ -115,7 +103,7 @@ module GoCardlessPro
|
|
115
103
|
response = make_request(:post, path, options)
|
116
104
|
|
117
105
|
return if response.body.nil?
|
118
|
-
Resources::Mandate.new(unenvelope_body(response.body))
|
106
|
+
Resources::Mandate.new(unenvelope_body(response.body), response)
|
119
107
|
end
|
120
108
|
|
121
109
|
# <a name="mandate_not_inactive"></a>Reinstates a cancelled or expired mandate
|
@@ -132,7 +120,7 @@ module GoCardlessPro
|
|
132
120
|
# Mandates can be resubmitted up to 3 times.
|
133
121
|
# Example URL: /mandates/:identity/actions/reinstate
|
134
122
|
#
|
135
|
-
# @param identity # Unique identifier, beginning with "MD"
|
123
|
+
# @param identity # Unique identifier, beginning with "MD".
|
136
124
|
# @param options [Hash] parameters as a hash, under a params key.
|
137
125
|
def reinstate(identity, options = {})
|
138
126
|
path = sub_url('/mandates/:identity/actions/reinstate', 'identity' => identity)
|
@@ -143,7 +131,7 @@ module GoCardlessPro
|
|
143
131
|
response = make_request(:post, path, options)
|
144
132
|
|
145
133
|
return if response.body.nil?
|
146
|
-
Resources::Mandate.new(unenvelope_body(response.body))
|
134
|
+
Resources::Mandate.new(unenvelope_body(response.body), response)
|
147
135
|
end
|
148
136
|
|
149
137
|
# Unenvelope the response of the body using the service's `envelope_key`
|