class Starling::Services::DirectDebitMandatesService

A service for accessing the Direct Debit Mandates API

Public Instance Methods

delete(id, params: {}, headers: {}) click to toggle source

Cancels a Direct Debit mandate

@param id [String] The Starling internal ID of the Direct Debit mandate @param params [Hash] Parameters which will be included in the HTTP request,

included in the body

@param headers [Hash] Headers which be included in the HTTP request, merged on

top of the headers set at the {Client} level

@return [Faraday::Response] the raw response from the Starling Bank API @raise [Errors::ApiError] if the HTTP request returns a status indicating that it

was unsuccessful
# File lib/starling/services/direct_debit_mandates_service.rb, line 31
def delete(id, params: {}, headers: {})
  api_service.make_request(:delete,
                           "/direct-debit/mandates/#{id}",
                           params: params,
                           headers: headers)
end
get(id, params: {}, headers: {}) click to toggle source

@param id [String] The Starling internal ID of the Direct Debit mandate @param params [Hash] Parameters which will be included in the HTTP request,

included in the URL as a query string

@param headers [Hash] Headers which be included in the HTTP request, merged on

top of the headers set at the {Client} level

@return [Resources::DirectDebitMandateResource] @raise [Errors::ApiError] if the HTTP request returns a status indicating that it

was unsuccessful
# File lib/starling/services/direct_debit_mandates_service.rb, line 13
def get(id, params: {}, headers: {})
  response = api_service.make_request(:get,
                                      "/direct-debit/mandates/#{id}",
                                      params: params,
                                      headers: headers)
  resource.new(response: response)
end
list(params: {}, headers: {}) click to toggle source

@param params [Hash] Parameters which will be included in the HTTP request,

included in the URL as a query string

@param headers [Hash] Headers which be included in the HTTP request, merged on

top of the headers set at the {Client} level

@return [Array<Resources::DirectDebitMandateResource>] @raise [Errors::ApiError] if the HTTP request returns a status indicating that it

was unsuccessful
# File lib/starling/services/direct_debit_mandates_service.rb, line 45
def list(params: {}, headers: {})
  response = api_service.make_request(:get,
                                      '/direct-debit/mandates',
                                      params: params,
                                      headers: headers)

  build_collection_from_embedded_key(response, key: 'mandates', resource: resource)
end

Private Instance Methods

resource() click to toggle source
# File lib/starling/services/direct_debit_mandates_service.rb, line 56
def resource
  Resources::DirectDebitMandateResource
end