class GoCardlessPro::Services::BankAuthorisationsService
Service for making requests to the BankAuthorisation endpoints
Public Instance Methods
Source
# File lib/gocardless_pro/services/bank_authorisations_service.rb, line 16 def create(options = {}) path = '/bank_authorisations' params = options.delete(:params) || {} options[:params] = {} options[:params][envelope_key] = params options[:retry_failures] = true begin response = make_request(:post, path, options) # Response doesn't raise any errors until #body is called response.tap(&:body) rescue InvalidStateError => e if e.idempotent_creation_conflict? case @api_service.on_idempotency_conflict when :raise raise IdempotencyConflict, e.error when :fetch return get(e.conflicting_resource_id) end end raise e end return if response.body.nil? Resources::BankAuthorisation.new(unenvelope_body(response.body), response) end
Create a Bank Authorisation. Example URL: /bank_authorisations @param options [Hash] parameters as a hash, under a params key.
Source
# File lib/gocardless_pro/services/bank_authorisations_service.rb, line 53 def get(identity, options = {}) path = sub_url('/bank_authorisations/:identity', { 'identity' => identity }) options[:retry_failures] = true response = make_request(:get, path, options) return if response.body.nil? Resources::BankAuthorisation.new(unenvelope_body(response.body), response) end
Get a single bank authorisation. Example URL: /bank_authorisations/:identity
@param identity # Unique identifier, beginning with “BAU”. @param options [Hash] parameters as a hash, under a params key.
Private Instance Methods
Source
# File lib/gocardless_pro/services/bank_authorisations_service.rb, line 77 def envelope_key 'bank_authorisations' end
return the key which API responses will envelope data under
Source
# File lib/gocardless_pro/services/bank_authorisations_service.rb, line 72 def unenvelope_body(body) body[envelope_key] || body['data'] end
Unenvelope the response of the body using the service’s ‘envelope_key`
@param body [Hash]