Class: GoCardlessPro::Services::BillingRequestFlowsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/gocardless_pro/services/billing_request_flows_service.rb

Overview

Service for making requests to the BillingRequestFlow endpoints

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #make_request, #sub_url

Constructor Details

This class inherits a constructor from GoCardlessPro::Services::BaseService

Instance Method Details

#create(options = {}) ⇒ Object

Creates a new billing request flow. Example URL: /billing_request_flows

Parameters:

  • options (Hash) (defaults to: {})

    parameters as a hash, under a params key.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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 = {}) ⇒ Object

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

Parameters:

  • identity

    # Unique identifier, beginning with “BRF”.

  • options (Hash) (defaults to: {})

    parameters as a hash, under a params key.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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