Class: Starling::Services::DirectDebitMandatesService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/starling/services/direct_debit_mandates_service.rb

Overview

A service for accessing the Direct Debit Mandates API

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

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

Instance Method Details

#delete(id, params: {}, headers: {}) ⇒ Faraday::Response

Cancels a Direct Debit mandate

Parameters:

  • id (String)

    The Starling internal ID of the Direct Debit mandate

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

    Parameters which will be included in the HTTP request, included in the body

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

    Headers which be included in the HTTP request, merged on top of the headers set at the Client level

Returns:

  • (Faraday::Response)

    the raw response from the Starling Bank API

Raises:

  • (Errors::ApiError)

    if the HTTP request returns a status indicating that it was unsuccessful


31
32
33
34
35
36
# 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: {}) ⇒ Resources::DirectDebitMandateResource

Parameters:

  • id (String)

    The Starling internal ID of the Direct Debit mandate

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

    Parameters which will be included in the HTTP request, included in the URL as a query string

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

    Headers which be included in the HTTP request, merged on top of the headers set at the Client level

Returns:

Raises:

  • (Errors::ApiError)

    if the HTTP request returns a status indicating that it was unsuccessful


13
14
15
16
17
18
19
# 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: {}) ⇒ Array<Resources::DirectDebitMandateResource>

Parameters:

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

    Parameters which will be included in the HTTP request, included in the URL as a query string

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

    Headers which be included in the HTTP request, merged on top of the headers set at the Client level

Returns:

Raises:

  • (Errors::ApiError)

    if the HTTP request returns a status indicating that it was unsuccessful


45
46
47
48
49
50
51
52
# 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