class GoCardlessPro::Services::BillingRequestFlowsService
Service for making requests to the BillingRequestFlow endpoints
Public Instance Methods
create(options = {})
click to toggle source
Creates a new billing request flow. Example URL: /billing_request_flows @param options [Hash] parameters as a hash, under a params key.
# File lib/gocardless_pro/services/billing_request_flows_service.rb, line 16 def create(options = {}) path = '/billing_request_flows' params = options.delete(:params) || {} options[:params] = {} options[:params][envelope_key] = params options[:retry_failures] = true response = make_request(:post, path, options) return if response.body.nil? Resources::BillingRequestFlow.new(unenvelope_body(response.body), response) end
initialise(identity, options = {})
click to toggle source
Returns the flow having generated a fresh session token which can be used to power integrations that manipulate the flow. Example URL: /billing_request_flows/:identity/actions/initialise
@param identity # Unique identifier, beginning with “BRQ”. @param options [Hash] parameters as a hash, under a params key.
# File lib/gocardless_pro/services/billing_request_flows_service.rb, line 39 def initialise(identity, options = {}) path = sub_url('/billing_request_flows/:identity/actions/initialise', 'identity' => identity) params = options.delete(:params) || {} options[:params] = {} options[:params]['data'] = params options[:retry_failures] = false response = make_request(:post, path, options) return if response.body.nil? Resources::BillingRequestFlow.new(unenvelope_body(response.body), response) 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/billing_request_flows_service.rb, line 65 def envelope_key 'billing_request_flows' 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/billing_request_flows_service.rb, line 60 def unenvelope_body(body) body[envelope_key] || body['data'] end