Skip to content

Commit c6a01f0

Browse files
authored
Merge pull request #104 from gocardless/template-changes
v2.36.0
2 parents 18215a7 + 7f09824 commit c6a01f0

11 files changed

+163
-15
lines changed

lib/gocardless_pro.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ module GoCardlessPro
9898
require_relative 'gocardless_pro/resources/mandate_pdf'
9999
require_relative 'gocardless_pro/services/mandate_pdfs_service'
100100

101+
require_relative 'gocardless_pro/resources/mandate_request_constraints'
102+
require_relative 'gocardless_pro/services/mandate_request_constraints_service'
103+
101104
require_relative 'gocardless_pro/resources/payer_authorisation'
102105
require_relative 'gocardless_pro/services/payer_authorisations_service'
103106

lib/gocardless_pro/client.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ def mandate_pdfs
9898
@mandate_pdfs ||= Services::MandatePdfsService.new(@api_service)
9999
end
100100

101+
# Access to the service for mandate_request_constraints to make API calls
102+
def mandate_request_constraints
103+
@mandate_request_constraints ||= Services::MandateRequestConstraintsService.new(@api_service)
104+
end
105+
101106
# Access to the service for payer_authorisation to make API calls
102107
def payer_authorisations
103108
@payer_authorisations ||= Services::PayerAuthorisationsService.new(@api_service)
@@ -198,7 +203,7 @@ def default_options
198203
'User-Agent' => user_agent.to_s,
199204
'Content-Type' => 'application/json',
200205
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
201-
'GoCardless-Client-Version' => '2.35.0',
206+
'GoCardless-Client-Version' => '2.36.0',
202207
},
203208
}
204209
end

lib/gocardless_pro/resources/billing_request_template.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class BillingRequestTemplate
1818
attr_reader :created_at
1919
attr_reader :id
2020
attr_reader :mandate_request_currency
21+
attr_reader :mandate_request_description
2122
attr_reader :mandate_request_metadata
2223
attr_reader :mandate_request_scheme
2324
attr_reader :mandate_request_verify
@@ -40,6 +41,7 @@ def initialize(object, response = nil)
4041
@created_at = object['created_at']
4142
@id = object['id']
4243
@mandate_request_currency = object['mandate_request_currency']
44+
@mandate_request_description = object['mandate_request_description']
4345
@mandate_request_metadata = object['mandate_request_metadata']
4446
@mandate_request_scheme = object['mandate_request_scheme']
4547
@mandate_request_verify = object['mandate_request_verify']

lib/gocardless_pro/resources/block.rb

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,37 @@ module Resources
1818
#
1919
# The details used to create blocks can be exact matches, like a bank
2020
# account or an email,
21-
# or a more generic match such as an email domain. New block types may be
22-
# added over time.
21+
# or a more generic match such as an email domain or bank name. Please be
22+
# careful when creating
23+
# blocks for more generic matches as this may block legitimate payers from
24+
# using your service.
2325
#
24-
# A block object is in essence a simple rule that is used to match against
25-
# details in a
26-
# newly created mandate. If there is a successful match then the mandate is
27-
# transitioned
28-
# to a "blocked" state.
26+
# New block types may be added over time.
2927
#
30-
# Payments and subscriptions cannot be created against a mandate in blocked
31-
# state.
28+
# A block is in essence a simple rule that is used to match against details
29+
# in a newly
30+
# created mandate. If there is a successful match then the mandate is
31+
# transitioned to a
32+
# "blocked" state.
3233
#
33-
# A mandate can never be transitioned out of the blocked state.
34+
# Please note:
35+
#
36+
# - Payments and subscriptions cannot be created against a mandate in
37+
# blocked state.
38+
# - A mandate can never be transitioned out of the blocked state.
39+
#
40+
# The one exception to this is when blocking a 'bank_name'. This block will
41+
# prevent bank
42+
# accounts from being created for banks that match the given name. To ensure
43+
# we match
44+
# bank names correctly an existing bank account must be used when creating
45+
# this block. Please
46+
# be aware that we cannot always match a bank account to a given bank name.
3447
#
3548
# <p class="notice">
36-
# This API is currently only available for approved integrators - please
37-
# <a href="mailto:[email protected]">get in touch</a> if you would like to
38-
# use this API.
49+
# This API is currently only available for GoCardless Protect+ integrators
50+
# - please <a href="mailto:[email protected]">get in touch</a> if you
51+
# would like to use this API.
3952
# </p>
4053
class Block
4154
attr_reader :active
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# encoding: utf-8
2+
3+
#
4+
# This client is automatically generated from a template and JSON schema definition.
5+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
6+
#
7+
8+
require 'uri'
9+
10+
module GoCardlessPro
11+
# A module containing classes for each of the resources in the GC Api
12+
module Resources
13+
# Represents an instance of a mandate_request_constraints resource returned from the API
14+
15+
# Constraints that will apply to the mandate_request. (Optional)
16+
# Specifically for PayTo and VRP.
17+
class MandateRequestConstraints
18+
attr_reader :end_date
19+
attr_reader :max_amount_per_payment
20+
attr_reader :periodic_limits
21+
attr_reader :start_date
22+
23+
# Initialize a mandate_request_constraints resource instance
24+
# @param object [Hash] an object returned from the API
25+
def initialize(object, response = nil)
26+
@object = object
27+
28+
@end_date = object['end_date']
29+
@max_amount_per_payment = object['max_amount_per_payment']
30+
@periodic_limits = object['periodic_limits']
31+
@start_date = object['start_date']
32+
@response = response
33+
end
34+
35+
def api_response
36+
ApiResponse.new(@response)
37+
end
38+
39+
# Provides the mandate_request_constraints resource as a hash of all its readable attributes
40+
def to_h
41+
@object
42+
end
43+
end
44+
end
45+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require_relative './base_service'
2+
3+
# encoding: utf-8
4+
#
5+
# This client is automatically generated from a template and JSON schema definition.
6+
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
7+
#
8+
9+
module GoCardlessPro
10+
module Services
11+
# Service for making requests to the MandateRequestConstraints endpoints
12+
class MandateRequestConstraintsService < BaseService
13+
private
14+
15+
# Unenvelope the response of the body using the service's `envelope_key`
16+
#
17+
# @param body [Hash]
18+
def unenvelope_body(body)
19+
body[envelope_key] || body['data']
20+
end
21+
22+
# return the key which API responses will envelope data under
23+
def envelope_key
24+
'mandate_request_constraints'
25+
end
26+
end
27+
end
28+
end

lib/gocardless_pro/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ module GoCardlessPro
44

55
module GoCardlessPro
66
# Current version of the GC gem
7-
VERSION = '2.35.0'.freeze
7+
VERSION = '2.36.0'.freeze
88
end

spec/resources/billing_request_template_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'created_at' => 'created_at-input',
2323
'id' => 'id-input',
2424
'mandate_request_currency' => 'mandate_request_currency-input',
25+
'mandate_request_description' => 'mandate_request_description-input',
2526
'mandate_request_metadata' => 'mandate_request_metadata-input',
2627
'mandate_request_scheme' => 'mandate_request_scheme-input',
2728
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -57,6 +58,8 @@
5758

5859
expect(get_list_response.records.first.mandate_request_currency).to eq('mandate_request_currency-input')
5960

61+
expect(get_list_response.records.first.mandate_request_description).to eq('mandate_request_description-input')
62+
6063
expect(get_list_response.records.first.mandate_request_metadata).to eq('mandate_request_metadata-input')
6164

6265
expect(get_list_response.records.first.mandate_request_scheme).to eq('mandate_request_scheme-input')
@@ -101,6 +104,7 @@
101104
'created_at' => 'created_at-input',
102105
'id' => 'id-input',
103106
'mandate_request_currency' => 'mandate_request_currency-input',
107+
'mandate_request_description' => 'mandate_request_description-input',
104108
'mandate_request_metadata' => 'mandate_request_metadata-input',
105109
'mandate_request_scheme' => 'mandate_request_scheme-input',
106110
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -132,6 +136,7 @@
132136
'created_at' => 'created_at-input',
133137
'id' => 'id-input',
134138
'mandate_request_currency' => 'mandate_request_currency-input',
139+
'mandate_request_description' => 'mandate_request_description-input',
135140
'mandate_request_metadata' => 'mandate_request_metadata-input',
136141
'mandate_request_scheme' => 'mandate_request_scheme-input',
137142
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -179,6 +184,7 @@
179184
'created_at' => 'created_at-input',
180185
'id' => 'id-input',
181186
'mandate_request_currency' => 'mandate_request_currency-input',
187+
'mandate_request_description' => 'mandate_request_description-input',
182188
'mandate_request_metadata' => 'mandate_request_metadata-input',
183189
'mandate_request_scheme' => 'mandate_request_scheme-input',
184190
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -220,6 +226,7 @@
220226
'created_at' => 'created_at-input',
221227
'id' => 'id-input',
222228
'mandate_request_currency' => 'mandate_request_currency-input',
229+
'mandate_request_description' => 'mandate_request_description-input',
223230
'mandate_request_metadata' => 'mandate_request_metadata-input',
224231
'mandate_request_scheme' => 'mandate_request_scheme-input',
225232
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -276,6 +283,7 @@
276283
'created_at' => 'created_at-input',
277284
'id' => 'id-input',
278285
'mandate_request_currency' => 'mandate_request_currency-input',
286+
'mandate_request_description' => 'mandate_request_description-input',
279287
'mandate_request_metadata' => 'mandate_request_metadata-input',
280288
'mandate_request_scheme' => 'mandate_request_scheme-input',
281289
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -301,6 +309,7 @@
301309
'created_at' => 'created_at-input',
302310
'id' => 'id-input',
303311
'mandate_request_currency' => 'mandate_request_currency-input',
312+
'mandate_request_description' => 'mandate_request_description-input',
304313
'mandate_request_metadata' => 'mandate_request_metadata-input',
305314
'mandate_request_scheme' => 'mandate_request_scheme-input',
306315
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -326,6 +335,7 @@
326335
'created_at' => 'created_at-input',
327336
'id' => 'id-input',
328337
'mandate_request_currency' => 'mandate_request_currency-input',
338+
'mandate_request_description' => 'mandate_request_description-input',
329339
'mandate_request_metadata' => 'mandate_request_metadata-input',
330340
'mandate_request_scheme' => 'mandate_request_scheme-input',
331341
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -384,6 +394,7 @@
384394
'created_at' => 'created_at-input',
385395
'id' => 'id-input',
386396
'mandate_request_currency' => 'mandate_request_currency-input',
397+
'mandate_request_description' => 'mandate_request_description-input',
387398
'mandate_request_metadata' => 'mandate_request_metadata-input',
388399
'mandate_request_scheme' => 'mandate_request_scheme-input',
389400
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -432,6 +443,7 @@
432443
'created_at' => 'created_at-input',
433444
'id' => 'id-input',
434445
'mandate_request_currency' => 'mandate_request_currency-input',
446+
'mandate_request_description' => 'mandate_request_description-input',
435447
'mandate_request_metadata' => 'mandate_request_metadata-input',
436448
'mandate_request_scheme' => 'mandate_request_scheme-input',
437449
'mandate_request_verify' => 'mandate_request_verify-input',
@@ -475,6 +487,7 @@
475487
'created_at' => 'created_at-input',
476488
'id' => 'id-input',
477489
'mandate_request_currency' => 'mandate_request_currency-input',
490+
'mandate_request_description' => 'mandate_request_description-input',
478491
'mandate_request_metadata' => 'mandate_request_metadata-input',
479492
'mandate_request_scheme' => 'mandate_request_scheme-input',
480493
'mandate_request_verify' => 'mandate_request_verify-input',
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
3+
describe GoCardlessPro::Resources::MandateRequestConstraints do
4+
let(:client) do
5+
GoCardlessPro::Client.new(
6+
access_token: 'SECRET_TOKEN'
7+
)
8+
end
9+
10+
let(:response_headers) { { 'Content-Type' => 'application/json' } }
11+
end

0 commit comments

Comments
 (0)