Class: VoiceTel::Resources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/voicetel/resources/base.rb

Overview

Shared base for every resource service. Each service receives the client’s transport on construction and uses it for HTTP calls. Keeping this thin lets us keep resource files focused on their endpoints.

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ Base

Returns a new instance of Base.



9
10
11
# File 'lib/voicetel/resources/base.rb', line 9

def initialize(transport)
  @transport = transport
end

Instance Method Details

#compact_query(hash) ⇒ Object

Compact a query hash, dropping nil and empty-string values, before handing it to the transport. Some endpoints take a lot of optional filters and writing ‘nil` everywhere at call sites would be noisy.



16
17
18
# File 'lib/voicetel/resources/base.rb', line 16

def compact_query(hash)
  hash.reject { |_, v| v.nil? || v == "" }
end