Skip to content

Commit

Permalink
Template changes (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
gc-robot-readwrite-sso and gocardless-robot authored Nov 24, 2023
1 parent e0157e1 commit 9322ffa
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def default_options
'User-Agent' => "#{user_agent}",
'Content-Type' => 'application/json',
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
'GoCardless-Client-Version' => '2.51.0',
'GoCardless-Client-Version' => '2.52.0',
},
}
end
Expand Down
12 changes: 6 additions & 6 deletions lib/gocardless_pro/resources/transferred_mandate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ module Resources

# Mandates that have been transferred using Current Account Switch Service
class TransferredMandate
attr_reader :encrypted_data
attr_reader :key
attr_reader :kid
attr_reader :encrypted_customer_bank_details
attr_reader :encrypted_decryption_key
attr_reader :public_key_id

# Initialize a transferred_mandate resource instance
# @param object [Hash] an object returned from the API
def initialize(object, response = nil)
@object = object

@encrypted_data = object['encrypted_data']
@key = object['key']
@kid = object['kid']
@encrypted_customer_bank_details = object['encrypted_customer_bank_details']
@encrypted_decryption_key = object['encrypted_decryption_key']
@links = object['links']
@public_key_id = object['public_key_id']
@response = response
end

Expand Down
9 changes: 5 additions & 4 deletions lib/gocardless_pro/services/transferred_mandates_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ module GoCardlessPro
module Services
# Service for making requests to the TransferredMandate endpoints
class TransferredMandatesService < BaseService
# Returns encrypted bank details for the transferred mandate
# Example URL: /transferred_mandate/:identity
# Returns new customer bank details for a mandate that's been recently
# transferred
# Example URL: /transferred_mandates/:identity
#
# @param identity # Unique identifier, beginning with "MD". Note that this prefix may not
# apply to mandates created before 2016.
# @param options [Hash] parameters as a hash, under a params key.
def transferred_mandates(identity, options = {})
path = sub_url('/transferred_mandate/:identity', {
path = sub_url('/transferred_mandates/:identity', {
'identity' => identity,
})

Expand All @@ -41,7 +42,7 @@ def unenvelope_body(body)

# return the key which API responses will envelope data under
def envelope_key
'transferred_mandate'
'transferred_mandates'
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gocardless_pro/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module GoCardlessPro

module GoCardlessPro
# Current version of the GC gem
VERSION = '2.51.0'
VERSION = '2.52.0'
end
24 changes: 12 additions & 12 deletions spec/resources/transferred_mandate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
let(:resource_id) { 'ABC123' }

let!(:stub) do
# /transferred_mandate/%v
stub_url = '/transferred_mandate/:identity'.gsub(':identity', resource_id)
# /transferred_mandates/%v
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'transferred_mandate' => {
'transferred_mandates' => {

'encrypted_data' => 'encrypted_data-input',
'key' => 'key-input',
'kid' => 'kid-input',
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
'public_key_id' => 'public_key_id-input',
},
}.to_json,

Expand All @@ -46,20 +46,20 @@
let(:resource_id) { 'ABC123' }

let!(:stub) do
# /transferred_mandate/%v
stub_url = '/transferred_mandate/:identity'.gsub(':identity', resource_id)
# /transferred_mandates/%v
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'transferred_mandate' => {
'transferred_mandates' => {

'encrypted_data' => 'encrypted_data-input',
'key' => 'key-input',
'kid' => 'kid-input',
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
'public_key_id' => 'public_key_id-input',
},
}.to_json,
headers: response_headers
Expand Down
26 changes: 13 additions & 13 deletions spec/services/transferred_mandates_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
let(:resource_id) { 'ABC123' }

let!(:stub) do
# /transferred_mandate/%v
stub_url = '/transferred_mandate/:identity'.gsub(':identity', resource_id)
# /transferred_mandates/%v
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).to_return(
body: {
'transferred_mandate' => {
'transferred_mandates' => {

'encrypted_data' => 'encrypted_data-input',
'key' => 'key-input',
'kid' => 'kid-input',
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
'public_key_id' => 'public_key_id-input',
},
}.to_json,

Expand All @@ -40,7 +40,7 @@

describe 'retry behaviour' do
it "doesn't retry errors" do
stub_url = '/transferred_mandate/:identity'.gsub(':identity', resource_id)
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
stub = stub_request(:get, /.*api.gocardless.com#{stub_url}/).
to_timeout

Expand All @@ -57,20 +57,20 @@
let(:resource_id) { 'ABC123' }

let!(:stub) do
# /transferred_mandate/%v
stub_url = '/transferred_mandate/:identity'.gsub(':identity', resource_id)
# /transferred_mandates/%v
stub_url = '/transferred_mandates/:identity'.gsub(':identity', resource_id)
stub_request(:get, /.*api.gocardless.com#{stub_url}/).
with(
body: { foo: 'bar' },
headers: { 'Foo' => 'Bar' }
).to_return(
body: {
'transferred_mandate' => {
'transferred_mandates' => {

'encrypted_data' => 'encrypted_data-input',
'key' => 'key-input',
'kid' => 'kid-input',
'encrypted_customer_bank_details' => 'encrypted_customer_bank_details-input',
'encrypted_decryption_key' => 'encrypted_decryption_key-input',
'links' => 'links-input',
'public_key_id' => 'public_key_id-input',
},
}.to_json,
headers: response_headers
Expand Down

0 comments on commit 9322ffa

Please sign in to comment.