Class: GoCardlessPro::Services::BaseService

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

Overview

Base Service that all services inherit from.

Instance Method Summary collapse

Constructor Details

#initialize(api_service) ⇒ BaseService

Create a new service instance to make requests against

Parameters:



9
10
11
# File 'lib/gocardless_pro/services/base_service.rb', line 9

def initialize(api_service)
  @api_service = api_service
end

Instance Method Details

#envelope_keyObject

Get the envelope key for the given service. Children are expected to implement this method.

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/gocardless_pro/services/base_service.rb', line 23

def envelope_key
  raise NotImplementedError
end

#make_request(method, path, options = {}) ⇒ Object

Make a request to the API using the API service instance

Parameters:

  • method (Symbol)

    the method to use to make the request

  • path (String)

    the URL (without the base domain) to make the request to

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

    the options hash - either the query parameters for a GET, or the body if POST/PUT



18
19
20
# File 'lib/gocardless_pro/services/base_service.rb', line 18

def make_request(method, path, options = {})
  @api_service.make_request(method, path, options.merge(envelope_key: envelope_key))
end