Class: Nexmo::Voice::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo/voice.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret, options = {}) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nexmo/voice.rb', line 17

def initialize(api_key, api_secret, options = {})
  @nexmo_adaptor =
    RestClient::Resource.new(
      BASE_URL,
      read_timeout: options.fetch(:read_timeout) { DEFAULT_TIMEOUT },
      open_timeout: options.fetch(:open_timeout) { DEFAULT_TIMEOUT }
    )

  @api_config = {
    api_key: api_key,
    api_secret: api_secret
  }

  @calls = Calls.new(self)
  @ttses = Ttses.new(self)
end

Instance Attribute Details

#api_configObject

Returns the value of attribute api_config.



14
15
16
# File 'lib/nexmo/voice.rb', line 14

def api_config
  @api_config
end

#callsObject

Returns the value of attribute calls.



14
15
16
# File 'lib/nexmo/voice.rb', line 14

def calls
  @calls
end

#nexmo_adaptorObject

Returns the value of attribute nexmo_adaptor.



14
15
16
# File 'lib/nexmo/voice.rb', line 14

def nexmo_adaptor
  @nexmo_adaptor
end

#ttsesObject

Returns the value of attribute ttses.



14
15
16
# File 'lib/nexmo/voice.rb', line 14

def ttses
  @ttses
end

Instance Method Details

#get(resource, entity = {}) ⇒ Object



34
35
36
37
# File 'lib/nexmo/voice.rb', line 34

def get(resource, entity = {})
  @nexmo_adaptor[resource.class::RELATIVE_URL]
    .get(params: entity.merge(@api_config))
end