Class: Nombaone::Resources::BaseResource
- Inherits:
-
Object
- Object
- Nombaone::Resources::BaseResource
- Defined in:
- lib/nombaone/resources/base_resource.rb,
sig/nombaone/resources.rbs
Overview
Base class every resource namespace extends. Holds the client and the small request helpers each method builds on.
Direct Known Subclasses
Coupons, Customers, Events, Invoices, Mandates, Metrics, Organization, OrganizationBilling, PaymentMethods, PlanPrices, Plans, Prices, Sandbox, Settlements, SubscriptionDunning, SubscriptionSchedules, Subscriptions, WebhookEndpointDeliveries, WebhookEndpoints
Instance Method Summary collapse
-
#encode(value) ⇒ String
Percent-encode one id before splicing it into a path — ids come from user input and are never trusted raw.
-
#initialize(client) ⇒ BaseResource
constructor
private
A new instance of BaseResource.
-
#request(method, path, body: nil, query: nil, options: {}) ⇒ Object
Issue a single-object request; returns a NombaObject.
-
#request_page(path, query: nil, options: {}) ⇒ Object
Issue a list request; returns a Page.
Constructor Details
#initialize(client) ⇒ BaseResource
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BaseResource.
17 18 19 |
# File 'lib/nombaone/resources/base_resource.rb', line 17 def initialize(client) @client = client end |
Instance Method Details
#encode(value) ⇒ String
Percent-encode one id before splicing it into a path — ids come from user input and are never trusted raw.
35 36 37 |
# File 'lib/nombaone/resources/base_resource.rb', line 35 def encode(value) Internal::Util.encode_path_segment(value) end |
#request(method, path, body: nil, query: nil, options: {}) ⇒ Object
Issue a single-object request; returns a NombaObject.
24 25 26 |
# File 'lib/nombaone/resources/base_resource.rb', line 24 def request(method, path, body: nil, query: nil, options: {}) @client.request(method: method, path: path, body: body, query: query, options: ) end |
#request_page(path, query: nil, options: {}) ⇒ Object
Issue a list request; returns a Page.
29 30 31 |
# File 'lib/nombaone/resources/base_resource.rb', line 29 def request_page(path, query: nil, options: {}) @client.request_page(method: :get, path: path, query: query, options: ) end |