Class: Nombaone::Resources::BaseResource

Inherits:
Object
  • Object
show all
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.

Instance Method Summary collapse

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.

Parameters:



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.

Parameters:

  • value (Object)

Returns:

  • (String)


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: 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: options)
end