class GoCardless::Services::HelperService

Service for making requests to the Helper endpoints

Public Instance Methods

mandate(options = {}, custom_headers = {}) click to toggle source

Returns a PDF mandate form with a signature field, ready to be signed by your customer. May be fully or partially pre-filled.

You must specify ‘Accept: application/pdf` on requests to this endpoint.

Bank account details may either be supplied using the IBAN (international bank account number), or [local details](developer.gocardless.com/pro/#ui-compliance-local-bank-details). For more information on the different fields required in each country, please see the [local bank details](developer.gocardless.com/pro/#ui-compliance-local-bank-details) section.

To generate a mandate in a foreign language, set your ‘Accept-Language` header to the relevant [ISO 639-1](en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table) language code. Currently Dutch, English, French, German, Italian, Portuguese and Spanish are supported.

Note: If you want to render a PDF of an existing mandate you can also do so using the [mandate show endpoint](developer.gocardless.com/pro/#mandates-get-a-single-mandate). Example URL: /helpers/mandate @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters. Else, they will be the body of the request.

# File lib/gocardless-pro/services/helper_service.rb, line 40
def mandate(options = {}, custom_headers = {})
  path = '/helpers/mandate'
  new_options = {}
  new_options['data'] = options
  options = new_options
  response = make_request(:post, path, options, custom_headers)

  Resources::Helper.new(unenvelope_body(response.body))
end
modulus_check(options = {}, custom_headers = {}) click to toggle source

Check whether an account number and bank / branch code combination are compatible.

Bank account details may either be supplied using the IBAN (international bank account number), or [local details](developer.gocardless.com/pro/#ui-compliance-local-bank-details). For more information on the different fields required in each country, please see the [local bank details](developer.gocardless.com/pro/#ui-compliance-local-bank-details) section. Example URL: /helpers/modulus_check @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters. Else, they will be the body of the request.

# File lib/gocardless-pro/services/helper_service.rb, line 63
def modulus_check(options = {}, custom_headers = {})
  path = '/helpers/modulus_check'
  new_options = {}
  new_options['data'] = options
  options = new_options
  response = make_request(:post, path, options, custom_headers)

  Resources::Helper.new(unenvelope_body(response.body))
end
unenvelope_body(body) click to toggle source

Unenvelope the response of the body using the service’s ‘envelope_key`

@param body [Hash]

# File lib/gocardless-pro/services/helper_service.rb, line 76
def unenvelope_body(body)
  body[envelope_key] || body['data']
end

Private Instance Methods

envelope_key() click to toggle source

return the key which API responses will envelope data under

# File lib/gocardless-pro/services/helper_service.rb, line 83
def envelope_key
  'helpers'
end
sub_url(url, param_map) click to toggle source

take a URL with placeholder params and substitute them out for the acutal value @param url [String] the URL with placeholders in @param param_map [Hash] a hash of placeholders and their actual values

# File lib/gocardless-pro/services/helper_service.rb, line 90
def sub_url(url, param_map)
  param_map.reduce(url) do |new_url, (param, value)|
    new_url.gsub(":#{param}", value)
  end
end