Class: GoCardlessPro::Services::BaseService
- Inherits:
-
Object
- Object
- GoCardlessPro::Services::BaseService
- Defined in:
- lib/gocardless_pro/services/base_service.rb
Overview
Base Service that all services inherit from.
Direct Known Subclasses
BankAuthorisationsService, BankDetailsLookupsService, BillingRequestFlowsService, BillingRequestTemplatesService, BillingRequestsService, BlocksService, CreditorBankAccountsService, CreditorsService, CurrencyExchangeRatesService, CustomerBankAccountsService, CustomerNotificationsService, CustomersService, EventsService, ExportsService, InstalmentSchedulesService, InstitutionsService, LogosService, MandateImportEntriesService, MandateImportsService, MandatePdfsService, MandatesService, NegativeBalanceLimitsService, PayerAuthorisationsService, PayerThemesService, PaymentsService, PayoutItemsService, PayoutsService, RedirectFlowsService, RefundsService, ScenarioSimulatorsService, SchemeIdentifiersService, SubscriptionsService, TaxRatesService, TransferredMandatesService, VerificationDetailsService, WebhooksService
Instance Method Summary collapse
-
#envelope_key ⇒ Object
Get the envelope key for the given service.
-
#initialize(api_service) ⇒ BaseService
constructor
Create a new service instance to make requests against.
-
#make_request(method, path, options = {}) ⇒ Object
Make a request to the API using the API service instance.
-
#sub_url(url, param_map) ⇒ Object
take a URL with placeholder params and substitute them out for the actual value.
Constructor Details
#initialize(api_service) ⇒ BaseService
Create a new service instance to make requests against
11 12 13 |
# File 'lib/gocardless_pro/services/base_service.rb', line 11 def initialize(api_service) @api_service = api_service end |
Instance Method Details
#envelope_key ⇒ Object
Get the envelope key for the given service. Children are expected to implement this method.
25 26 27 |
# File 'lib/gocardless_pro/services/base_service.rb', line 25 def envelope_key raise NotImplementedError end |
#make_request(method, path, options = {}) ⇒ Object
Make a request to the API using the API service instance
20 21 22 |
# File 'lib/gocardless_pro/services/base_service.rb', line 20 def make_request(method, path, = {}) @api_service.make_request(method, path, .merge(envelope_key: envelope_key)) end |
#sub_url(url, param_map) ⇒ Object
take a URL with placeholder params and substitute them out for the actual value
32 33 34 35 36 |
# File 'lib/gocardless_pro/services/base_service.rb', line 32 def sub_url(url, param_map) param_map.reduce(url) do |new_url, (param, value)| new_url.gsub(":#{param}", CGI.escape(value)) end end |