gocardless_pro 1.0.3 → 1.0.4
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/.travis.yml +12 -0
- data/README.md +71 -28
- data/gocardless_pro.gemspec +1 -1
- data/lib/gocardless_pro/api_service.rb +4 -2
- data/lib/gocardless_pro/client.rb +2 -1
- data/lib/gocardless_pro/error.rb +12 -1
- data/lib/gocardless_pro/resources/mandate.rb +3 -0
- data/lib/gocardless_pro/resources/payout.rb +3 -0
- data/lib/gocardless_pro/resources/redirect_flow.rb +15 -14
- data/lib/gocardless_pro/services/bank_details_lookups_service.rb +10 -0
- data/lib/gocardless_pro/services/creditor_bank_accounts_service.rb +5 -2
- data/lib/gocardless_pro/services/creditors_service.rb +5 -2
- data/lib/gocardless_pro/services/customer_bank_accounts_service.rb +7 -3
- data/lib/gocardless_pro/services/customers_service.rb +5 -2
- data/lib/gocardless_pro/services/events_service.rb +2 -1
- data/lib/gocardless_pro/services/mandate_pdfs_service.rb +2 -1
- data/lib/gocardless_pro/services/mandates_service.rb +10 -5
- data/lib/gocardless_pro/services/payments_service.rb +11 -6
- data/lib/gocardless_pro/services/payouts_service.rb +2 -1
- data/lib/gocardless_pro/services/redirect_flows_service.rb +6 -3
- data/lib/gocardless_pro/services/refunds_service.rb +5 -2
- data/lib/gocardless_pro/services/subscriptions_service.rb +7 -3
- data/lib/gocardless_pro/version.rb +1 -1
- data/spec/api_response_spec.rb +4 -4
- data/spec/api_service_spec.rb +41 -43
- data/spec/client_spec.rb +2 -2
- data/spec/error_spec.rb +27 -18
- data/spec/resources/bank_details_lookup_spec.rb +19 -34
- data/spec/resources/creditor_bank_account_spec.rb +54 -99
- data/spec/resources/creditor_spec.rb +66 -115
- data/spec/resources/customer_bank_account_spec.rb +54 -99
- data/spec/resources/customer_spec.rb +71 -138
- data/spec/resources/event_spec.rb +74 -107
- data/spec/resources/mandate_pdf_spec.rb +15 -26
- data/spec/resources/mandate_spec.rb +54 -87
- data/spec/resources/payment_spec.rb +70 -119
- data/spec/resources/payout_spec.rb +50 -79
- data/spec/resources/redirect_flow_spec.rb +58 -95
- data/spec/resources/refund_spec.rb +42 -75
- data/spec/resources/subscription_spec.rb +82 -155
- data/spec/response_spec.rb +45 -46
- data/spec/services/bank_details_lookups_service_spec.rb +55 -60
- data/spec/services/creditor_bank_accounts_service_spec.rb +303 -347
- data/spec/services/creditors_service_spec.rb +290 -333
- data/spec/services/customer_bank_accounts_service_spec.rb +332 -380
- data/spec/services/customers_service_spec.rb +347 -400
- data/spec/services/events_service_spec.rb +154 -184
- data/spec/services/mandate_pdfs_service_spec.rb +52 -57
- data/spec/services/mandates_service_spec.rb +374 -410
- data/spec/services/payments_service_spec.rb +404 -461
- data/spec/services/payouts_service_spec.rb +161 -184
- data/spec/services/redirect_flows_service_spec.rb +188 -205
- data/spec/services/refunds_service_spec.rb +245 -280
- data/spec/services/subscriptions_service_spec.rb +423 -485
- data/spec/spec_helper.rb +46 -48
- metadata +22 -20
@@ -37,6 +37,7 @@ module GoCardlessPro
|
|
37
37
|
response = make_request(:post, path, options)
|
38
38
|
|
39
39
|
return if response.body.nil?
|
40
|
+
|
40
41
|
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
41
42
|
end
|
42
43
|
|
@@ -74,11 +75,12 @@ module GoCardlessPro
|
|
74
75
|
# @param identity # Unique identifier, beginning with "BA".
|
75
76
|
# @param options [Hash] parameters as a hash, under a params key.
|
76
77
|
def get(identity, options = {})
|
77
|
-
path = sub_url('/customer_bank_accounts/:identity',
|
78
|
+
path = sub_url('/customer_bank_accounts/:identity', 'identity' => identity)
|
78
79
|
|
79
80
|
response = make_request(:get, path, options)
|
80
81
|
|
81
82
|
return if response.body.nil?
|
83
|
+
|
82
84
|
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
83
85
|
end
|
84
86
|
|
@@ -89,7 +91,7 @@ module GoCardlessPro
|
|
89
91
|
# @param identity # Unique identifier, beginning with "BA".
|
90
92
|
# @param options [Hash] parameters as a hash, under a params key.
|
91
93
|
def update(identity, options = {})
|
92
|
-
path = sub_url('/customer_bank_accounts/:identity',
|
94
|
+
path = sub_url('/customer_bank_accounts/:identity', 'identity' => identity)
|
93
95
|
|
94
96
|
params = options.delete(:params) || {}
|
95
97
|
options[:params] = {}
|
@@ -97,6 +99,7 @@ module GoCardlessPro
|
|
97
99
|
response = make_request(:put, path, options)
|
98
100
|
|
99
101
|
return if response.body.nil?
|
102
|
+
|
100
103
|
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
101
104
|
end
|
102
105
|
|
@@ -113,7 +116,7 @@ module GoCardlessPro
|
|
113
116
|
# @param identity # Unique identifier, beginning with "BA".
|
114
117
|
# @param options [Hash] parameters as a hash, under a params key.
|
115
118
|
def disable(identity, options = {})
|
116
|
-
path = sub_url('/customer_bank_accounts/:identity/actions/disable',
|
119
|
+
path = sub_url('/customer_bank_accounts/:identity/actions/disable', 'identity' => identity)
|
117
120
|
|
118
121
|
params = options.delete(:params) || {}
|
119
122
|
options[:params] = {}
|
@@ -121,6 +124,7 @@ module GoCardlessPro
|
|
121
124
|
response = make_request(:post, path, options)
|
122
125
|
|
123
126
|
return if response.body.nil?
|
127
|
+
|
124
128
|
Resources::CustomerBankAccount.new(unenvelope_body(response.body), response)
|
125
129
|
end
|
126
130
|
|
@@ -22,6 +22,7 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
+
|
25
26
|
Resources::Customer.new(unenvelope_body(response.body), response)
|
26
27
|
end
|
27
28
|
|
@@ -59,11 +60,12 @@ module GoCardlessPro
|
|
59
60
|
# @param identity # Unique identifier, beginning with "CU".
|
60
61
|
# @param options [Hash] parameters as a hash, under a params key.
|
61
62
|
def get(identity, options = {})
|
62
|
-
path = sub_url('/customers/:identity',
|
63
|
+
path = sub_url('/customers/:identity', 'identity' => identity)
|
63
64
|
|
64
65
|
response = make_request(:get, path, options)
|
65
66
|
|
66
67
|
return if response.body.nil?
|
68
|
+
|
67
69
|
Resources::Customer.new(unenvelope_body(response.body), response)
|
68
70
|
end
|
69
71
|
|
@@ -74,7 +76,7 @@ module GoCardlessPro
|
|
74
76
|
# @param identity # Unique identifier, beginning with "CU".
|
75
77
|
# @param options [Hash] parameters as a hash, under a params key.
|
76
78
|
def update(identity, options = {})
|
77
|
-
path = sub_url('/customers/:identity',
|
79
|
+
path = sub_url('/customers/:identity', 'identity' => identity)
|
78
80
|
|
79
81
|
params = options.delete(:params) || {}
|
80
82
|
options[:params] = {}
|
@@ -82,6 +84,7 @@ module GoCardlessPro
|
|
82
84
|
response = make_request(:put, path, options)
|
83
85
|
|
84
86
|
return if response.body.nil?
|
87
|
+
|
85
88
|
Resources::Customer.new(unenvelope_body(response.body), response)
|
86
89
|
end
|
87
90
|
|
@@ -43,11 +43,12 @@ module GoCardlessPro
|
|
43
43
|
# @param identity # Unique identifier, beginning with "EV".
|
44
44
|
# @param options [Hash] parameters as a hash, under a params key.
|
45
45
|
def get(identity, options = {})
|
46
|
-
path = sub_url('/events/:identity',
|
46
|
+
path = sub_url('/events/:identity', 'identity' => identity)
|
47
47
|
|
48
48
|
response = make_request(:get, path, options)
|
49
49
|
|
50
50
|
return if response.body.nil?
|
51
|
+
|
51
52
|
Resources::Event.new(unenvelope_body(response.body), response)
|
52
53
|
end
|
53
54
|
|
@@ -21,7 +21,7 @@ module GoCardlessPro
|
|
21
21
|
# header to the relevant [ISO
|
22
22
|
# 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table)
|
23
23
|
# language code. Supported languages are Dutch, English, French, German,
|
24
|
-
# Italian, Portuguese and
|
24
|
+
# Italian, Portuguese, Spanish and Swedish.
|
25
25
|
# Example URL: /mandate_pdfs
|
26
26
|
# @param options [Hash] parameters as a hash, under a params key.
|
27
27
|
def create(options = {})
|
@@ -33,6 +33,7 @@ module GoCardlessPro
|
|
33
33
|
response = make_request(:post, path, options)
|
34
34
|
|
35
35
|
return if response.body.nil?
|
36
|
+
|
36
37
|
Resources::MandatePdf.new(unenvelope_body(response.body), response)
|
37
38
|
end
|
38
39
|
|
@@ -22,11 +22,12 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
+
|
25
26
|
Resources::Mandate.new(unenvelope_body(response.body), response)
|
26
27
|
end
|
27
28
|
|
28
29
|
# Returns a [cursor-paginated](#overview-cursor-pagination) list of your
|
29
|
-
# mandates.
|
30
|
+
# mandates.
|
30
31
|
# Example URL: /mandates
|
31
32
|
# @param options [Hash] parameters as a hash, under a params key.
|
32
33
|
def list(options = {})
|
@@ -59,11 +60,12 @@ module GoCardlessPro
|
|
59
60
|
# @param identity # Unique identifier, beginning with "MD".
|
60
61
|
# @param options [Hash] parameters as a hash, under a params key.
|
61
62
|
def get(identity, options = {})
|
62
|
-
path = sub_url('/mandates/:identity',
|
63
|
+
path = sub_url('/mandates/:identity', 'identity' => identity)
|
63
64
|
|
64
65
|
response = make_request(:get, path, options)
|
65
66
|
|
66
67
|
return if response.body.nil?
|
68
|
+
|
67
69
|
Resources::Mandate.new(unenvelope_body(response.body), response)
|
68
70
|
end
|
69
71
|
|
@@ -73,7 +75,7 @@ module GoCardlessPro
|
|
73
75
|
# @param identity # Unique identifier, beginning with "MD".
|
74
76
|
# @param options [Hash] parameters as a hash, under a params key.
|
75
77
|
def update(identity, options = {})
|
76
|
-
path = sub_url('/mandates/:identity',
|
78
|
+
path = sub_url('/mandates/:identity', 'identity' => identity)
|
77
79
|
|
78
80
|
params = options.delete(:params) || {}
|
79
81
|
options[:params] = {}
|
@@ -81,6 +83,7 @@ module GoCardlessPro
|
|
81
83
|
response = make_request(:put, path, options)
|
82
84
|
|
83
85
|
return if response.body.nil?
|
86
|
+
|
84
87
|
Resources::Mandate.new(unenvelope_body(response.body), response)
|
85
88
|
end
|
86
89
|
|
@@ -95,7 +98,7 @@ module GoCardlessPro
|
|
95
98
|
# @param identity # Unique identifier, beginning with "MD".
|
96
99
|
# @param options [Hash] parameters as a hash, under a params key.
|
97
100
|
def cancel(identity, options = {})
|
98
|
-
path = sub_url('/mandates/:identity/actions/cancel',
|
101
|
+
path = sub_url('/mandates/:identity/actions/cancel', 'identity' => identity)
|
99
102
|
|
100
103
|
params = options.delete(:params) || {}
|
101
104
|
options[:params] = {}
|
@@ -103,6 +106,7 @@ module GoCardlessPro
|
|
103
106
|
response = make_request(:post, path, options)
|
104
107
|
|
105
108
|
return if response.body.nil?
|
109
|
+
|
106
110
|
Resources::Mandate.new(unenvelope_body(response.body), response)
|
107
111
|
end
|
108
112
|
|
@@ -123,7 +127,7 @@ module GoCardlessPro
|
|
123
127
|
# @param identity # Unique identifier, beginning with "MD".
|
124
128
|
# @param options [Hash] parameters as a hash, under a params key.
|
125
129
|
def reinstate(identity, options = {})
|
126
|
-
path = sub_url('/mandates/:identity/actions/reinstate',
|
130
|
+
path = sub_url('/mandates/:identity/actions/reinstate', 'identity' => identity)
|
127
131
|
|
128
132
|
params = options.delete(:params) || {}
|
129
133
|
options[:params] = {}
|
@@ -131,6 +135,7 @@ module GoCardlessPro
|
|
131
135
|
response = make_request(:post, path, options)
|
132
136
|
|
133
137
|
return if response.body.nil?
|
138
|
+
|
134
139
|
Resources::Mandate.new(unenvelope_body(response.body), response)
|
135
140
|
end
|
136
141
|
|
@@ -15,8 +15,8 @@ module GoCardlessPro
|
|
15
15
|
# This
|
16
16
|
# fails with a `mandate_is_inactive` error if the linked
|
17
17
|
# [mandate](#core-endpoints-mandates) is cancelled or has failed. Payments can
|
18
|
-
# be created against
|
19
|
-
#
|
18
|
+
# be created against mandates with status of: `pending_customer_approval`,
|
19
|
+
# `pending_submission`, `submitted`, and `active`.
|
20
20
|
# Example URL: /payments
|
21
21
|
# @param options [Hash] parameters as a hash, under a params key.
|
22
22
|
def create(options = {})
|
@@ -28,6 +28,7 @@ module GoCardlessPro
|
|
28
28
|
response = make_request(:post, path, options)
|
29
29
|
|
30
30
|
return if response.body.nil?
|
31
|
+
|
31
32
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
32
33
|
end
|
33
34
|
|
@@ -65,11 +66,12 @@ module GoCardlessPro
|
|
65
66
|
# @param identity # Unique identifier, beginning with "PM".
|
66
67
|
# @param options [Hash] parameters as a hash, under a params key.
|
67
68
|
def get(identity, options = {})
|
68
|
-
path = sub_url('/payments/:identity',
|
69
|
+
path = sub_url('/payments/:identity', 'identity' => identity)
|
69
70
|
|
70
71
|
response = make_request(:get, path, options)
|
71
72
|
|
72
73
|
return if response.body.nil?
|
74
|
+
|
73
75
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
74
76
|
end
|
75
77
|
|
@@ -79,7 +81,7 @@ module GoCardlessPro
|
|
79
81
|
# @param identity # Unique identifier, beginning with "PM".
|
80
82
|
# @param options [Hash] parameters as a hash, under a params key.
|
81
83
|
def update(identity, options = {})
|
82
|
-
path = sub_url('/payments/:identity',
|
84
|
+
path = sub_url('/payments/:identity', 'identity' => identity)
|
83
85
|
|
84
86
|
params = options.delete(:params) || {}
|
85
87
|
options[:params] = {}
|
@@ -87,6 +89,7 @@ module GoCardlessPro
|
|
87
89
|
response = make_request(:put, path, options)
|
88
90
|
|
89
91
|
return if response.body.nil?
|
92
|
+
|
90
93
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
91
94
|
end
|
92
95
|
|
@@ -101,7 +104,7 @@ module GoCardlessPro
|
|
101
104
|
# @param identity # Unique identifier, beginning with "PM".
|
102
105
|
# @param options [Hash] parameters as a hash, under a params key.
|
103
106
|
def cancel(identity, options = {})
|
104
|
-
path = sub_url('/payments/:identity/actions/cancel',
|
107
|
+
path = sub_url('/payments/:identity/actions/cancel', 'identity' => identity)
|
105
108
|
|
106
109
|
params = options.delete(:params) || {}
|
107
110
|
options[:params] = {}
|
@@ -109,6 +112,7 @@ module GoCardlessPro
|
|
109
112
|
response = make_request(:post, path, options)
|
110
113
|
|
111
114
|
return if response.body.nil?
|
115
|
+
|
112
116
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
113
117
|
end
|
114
118
|
|
@@ -129,7 +133,7 @@ module GoCardlessPro
|
|
129
133
|
# @param identity # Unique identifier, beginning with "PM".
|
130
134
|
# @param options [Hash] parameters as a hash, under a params key.
|
131
135
|
def retry(identity, options = {})
|
132
|
-
path = sub_url('/payments/:identity/actions/retry',
|
136
|
+
path = sub_url('/payments/:identity/actions/retry', 'identity' => identity)
|
133
137
|
|
134
138
|
params = options.delete(:params) || {}
|
135
139
|
options[:params] = {}
|
@@ -137,6 +141,7 @@ module GoCardlessPro
|
|
137
141
|
response = make_request(:post, path, options)
|
138
142
|
|
139
143
|
return if response.body.nil?
|
144
|
+
|
140
145
|
Resources::Payment.new(unenvelope_body(response.body), response)
|
141
146
|
end
|
142
147
|
|
@@ -46,11 +46,12 @@ module GoCardlessPro
|
|
46
46
|
# @param identity # Unique identifier, beginning with "PO".
|
47
47
|
# @param options [Hash] parameters as a hash, under a params key.
|
48
48
|
def get(identity, options = {})
|
49
|
-
path = sub_url('/payouts/:identity',
|
49
|
+
path = sub_url('/payouts/:identity', 'identity' => identity)
|
50
50
|
|
51
51
|
response = make_request(:get, path, options)
|
52
52
|
|
53
53
|
return if response.body.nil?
|
54
|
+
|
54
55
|
Resources::Payout.new(unenvelope_body(response.body), response)
|
55
56
|
end
|
56
57
|
|
@@ -11,7 +11,7 @@ module GoCardlessPro
|
|
11
11
|
# Service for making requests to the RedirectFlow endpoints
|
12
12
|
class RedirectFlowsService < BaseService
|
13
13
|
# Creates a redirect flow object which can then be used to redirect your
|
14
|
-
# customer to the GoCardless
|
14
|
+
# customer to the GoCardless hosted payment pages.
|
15
15
|
# Example URL: /redirect_flows
|
16
16
|
# @param options [Hash] parameters as a hash, under a params key.
|
17
17
|
def create(options = {})
|
@@ -23,6 +23,7 @@ module GoCardlessPro
|
|
23
23
|
response = make_request(:post, path, options)
|
24
24
|
|
25
25
|
return if response.body.nil?
|
26
|
+
|
26
27
|
Resources::RedirectFlow.new(unenvelope_body(response.body), response)
|
27
28
|
end
|
28
29
|
|
@@ -32,11 +33,12 @@ module GoCardlessPro
|
|
32
33
|
# @param identity # Unique identifier, beginning with "RE".
|
33
34
|
# @param options [Hash] parameters as a hash, under a params key.
|
34
35
|
def get(identity, options = {})
|
35
|
-
path = sub_url('/redirect_flows/:identity',
|
36
|
+
path = sub_url('/redirect_flows/:identity', 'identity' => identity)
|
36
37
|
|
37
38
|
response = make_request(:get, path, options)
|
38
39
|
|
39
40
|
return if response.body.nil?
|
41
|
+
|
40
42
|
Resources::RedirectFlow.new(unenvelope_body(response.body), response)
|
41
43
|
end
|
42
44
|
|
@@ -56,7 +58,7 @@ module GoCardlessPro
|
|
56
58
|
# @param identity # Unique identifier, beginning with "RE".
|
57
59
|
# @param options [Hash] parameters as a hash, under a params key.
|
58
60
|
def complete(identity, options = {})
|
59
|
-
path = sub_url('/redirect_flows/:identity/actions/complete',
|
61
|
+
path = sub_url('/redirect_flows/:identity/actions/complete', 'identity' => identity)
|
60
62
|
|
61
63
|
params = options.delete(:params) || {}
|
62
64
|
options[:params] = {}
|
@@ -64,6 +66,7 @@ module GoCardlessPro
|
|
64
66
|
response = make_request(:post, path, options)
|
65
67
|
|
66
68
|
return if response.body.nil?
|
69
|
+
|
67
70
|
Resources::RedirectFlow.new(unenvelope_body(response.body), response)
|
68
71
|
end
|
69
72
|
|
@@ -40,6 +40,7 @@ module GoCardlessPro
|
|
40
40
|
response = make_request(:post, path, options)
|
41
41
|
|
42
42
|
return if response.body.nil?
|
43
|
+
|
43
44
|
Resources::Refund.new(unenvelope_body(response.body), response)
|
44
45
|
end
|
45
46
|
|
@@ -77,11 +78,12 @@ module GoCardlessPro
|
|
77
78
|
# @param identity # Unique identifier, beginning with "RF".
|
78
79
|
# @param options [Hash] parameters as a hash, under a params key.
|
79
80
|
def get(identity, options = {})
|
80
|
-
path = sub_url('/refunds/:identity',
|
81
|
+
path = sub_url('/refunds/:identity', 'identity' => identity)
|
81
82
|
|
82
83
|
response = make_request(:get, path, options)
|
83
84
|
|
84
85
|
return if response.body.nil?
|
86
|
+
|
85
87
|
Resources::Refund.new(unenvelope_body(response.body), response)
|
86
88
|
end
|
87
89
|
|
@@ -91,7 +93,7 @@ module GoCardlessPro
|
|
91
93
|
# @param identity # Unique identifier, beginning with "RF".
|
92
94
|
# @param options [Hash] parameters as a hash, under a params key.
|
93
95
|
def update(identity, options = {})
|
94
|
-
path = sub_url('/refunds/:identity',
|
96
|
+
path = sub_url('/refunds/:identity', 'identity' => identity)
|
95
97
|
|
96
98
|
params = options.delete(:params) || {}
|
97
99
|
options[:params] = {}
|
@@ -99,6 +101,7 @@ module GoCardlessPro
|
|
99
101
|
response = make_request(:put, path, options)
|
100
102
|
|
101
103
|
return if response.body.nil?
|
104
|
+
|
102
105
|
Resources::Refund.new(unenvelope_body(response.body), response)
|
103
106
|
end
|
104
107
|
|
@@ -22,6 +22,7 @@ module GoCardlessPro
|
|
22
22
|
response = make_request(:post, path, options)
|
23
23
|
|
24
24
|
return if response.body.nil?
|
25
|
+
|
25
26
|
Resources::Subscription.new(unenvelope_body(response.body), response)
|
26
27
|
end
|
27
28
|
|
@@ -59,11 +60,12 @@ module GoCardlessPro
|
|
59
60
|
# @param identity # Unique identifier, beginning with "SB".
|
60
61
|
# @param options [Hash] parameters as a hash, under a params key.
|
61
62
|
def get(identity, options = {})
|
62
|
-
path = sub_url('/subscriptions/:identity',
|
63
|
+
path = sub_url('/subscriptions/:identity', 'identity' => identity)
|
63
64
|
|
64
65
|
response = make_request(:get, path, options)
|
65
66
|
|
66
67
|
return if response.body.nil?
|
68
|
+
|
67
69
|
Resources::Subscription.new(unenvelope_body(response.body), response)
|
68
70
|
end
|
69
71
|
|
@@ -73,7 +75,7 @@ module GoCardlessPro
|
|
73
75
|
# @param identity # Unique identifier, beginning with "SB".
|
74
76
|
# @param options [Hash] parameters as a hash, under a params key.
|
75
77
|
def update(identity, options = {})
|
76
|
-
path = sub_url('/subscriptions/:identity',
|
78
|
+
path = sub_url('/subscriptions/:identity', 'identity' => identity)
|
77
79
|
|
78
80
|
params = options.delete(:params) || {}
|
79
81
|
options[:params] = {}
|
@@ -81,6 +83,7 @@ module GoCardlessPro
|
|
81
83
|
response = make_request(:put, path, options)
|
82
84
|
|
83
85
|
return if response.body.nil?
|
86
|
+
|
84
87
|
Resources::Subscription.new(unenvelope_body(response.body), response)
|
85
88
|
end
|
86
89
|
|
@@ -95,7 +98,7 @@ module GoCardlessPro
|
|
95
98
|
# @param identity # Unique identifier, beginning with "SB".
|
96
99
|
# @param options [Hash] parameters as a hash, under a params key.
|
97
100
|
def cancel(identity, options = {})
|
98
|
-
path = sub_url('/subscriptions/:identity/actions/cancel',
|
101
|
+
path = sub_url('/subscriptions/:identity/actions/cancel', 'identity' => identity)
|
99
102
|
|
100
103
|
params = options.delete(:params) || {}
|
101
104
|
options[:params] = {}
|
@@ -103,6 +106,7 @@ module GoCardlessPro
|
|
103
106
|
response = make_request(:post, path, options)
|
104
107
|
|
105
108
|
return if response.body.nil?
|
109
|
+
|
106
110
|
Resources::Subscription.new(unenvelope_body(response.body), response)
|
107
111
|
end
|
108
112
|
|
data/spec/api_response_spec.rb
CHANGED
@@ -2,13 +2,13 @@ require 'spec_helper'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
describe GoCardlessPro::ApiResponse do
|
5
|
-
describe
|
5
|
+
describe 'wrapping a Faraday response' do
|
6
6
|
let(:content_type) { 'application/json' }
|
7
7
|
|
8
8
|
let(:stubbed) do
|
9
9
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
10
|
-
stub.get('/testing') do |
|
11
|
-
[200, { 'Content-Type' => content_type}, { test: true }.to_json]
|
10
|
+
stub.get('/testing') do |_env|
|
11
|
+
[200, { 'Content-Type' => content_type }, { test: true }.to_json]
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -23,6 +23,6 @@ describe GoCardlessPro::ApiResponse do
|
|
23
23
|
specify do
|
24
24
|
expect(api_response.headers).to eql('Content-Type' => content_type)
|
25
25
|
end
|
26
|
-
specify { expect(api_response.body).to eql(
|
26
|
+
specify { expect(api_response.body).to eql('test' => true) }
|
27
27
|
end
|
28
28
|
end
|