class TotalVoice::API

Inicializa o HTTP client

Constants

ENDPOINT

Public Class Methods

new(access_token, host = nil, options = {}) click to toggle source
  • Args :

    • Access-Token -> Access-Token TotalVoice

    • host -> Base URL para API

# File lib/client.rb, line 32
def initialize(access_token, host = nil, options = {})
  @access_token     = access_token
  @host             = host ? host : ENDPOINT
  @options = {
    headers: {
      'Access-Token' => @access_token,
      'Content-Type' => 'application/json',
      'Accept' => 'application/json',
      'User-Agent' => 'lib-ruby/' + VERSION
    }
  }.merge(options)

  @audio = nil
  @bina = nil
  @fila = nil
  @chamada = nil
  @conta = nil
  @composto = nil
  @conferencia = nil
  @did = nil
  @perfil = nil
  @ramal = nil
  @sms = nil
  @tts = nil
  @ura = nil
  @webphone = nil
  @verificacao = nil
end

Public Instance Methods

audio() click to toggle source
# File lib/client.rb, line 61
def audio
    @audio ||= Audio.new self
end
bina() click to toggle source
# File lib/client.rb, line 65
def bina
    @bina ||= Bina.new self
end
chamada() click to toggle source
# File lib/client.rb, line 73
def chamada
    @chamada ||= Chamada.new self
end
composto() click to toggle source
# File lib/client.rb, line 77
def composto
    @composto ||= Composto.new self
end
conferencia() click to toggle source
# File lib/client.rb, line 81
def conferencia
    @conferencia ||= Conferencia.new self
end
conta() click to toggle source
# File lib/client.rb, line 85
def conta
    @conta ||= Conta.new self
end
delete(route) click to toggle source

DELETE HTTP Method

@param [Route] route @return [json]

# File lib/client.rb, line 173
def delete(route)
  self.class.delete(@host + route.build(), @options);
end
did() click to toggle source
# File lib/client.rb, line 89
def did
    @did ||= Did.new self
end
fila() click to toggle source
# File lib/client.rb, line 69
def fila
    @fila ||= Fila.new self
end
get(route, query = nil) click to toggle source

GET HTTP Method

@param [Route] route @param [Query] query @return [json]

# File lib/client.rb, line 127
def get(route, query = nil)

  url = @host + route.build()
  if(query.instance_of?(Query))
    url = url + query.to_query()
  end

  self.class.get(url, @options);
end
perfil() click to toggle source
# File lib/client.rb, line 93
def perfil
    @perfil ||= Perfil.new self
end
post(route, params) click to toggle source

POST HTTP Method

@param [Route] route @param [Hash] params @return [json]

# File lib/client.rb, line 144
def post(route, params)
  data = {
    body: params.to_json
  }
  @options.merge!(data)
  self.class.post(@host + route.build(), @options);
end
put(route, params) click to toggle source

PUT HTTP Method

@param [Route] route @param [Hash] params @return [json]

# File lib/client.rb, line 159
def put(route, params)
  data = {
    body: params.to_json
  }
  @options.merge!(data)
  self.class.put(@host + route.build(), @options);
end
ramal() click to toggle source
# File lib/client.rb, line 97
def ramal
    @ramal ||= Ramal.new self
end
sms() click to toggle source
# File lib/client.rb, line 101
def sms
    @sms ||= Sms.new self
end
tts() click to toggle source
# File lib/client.rb, line 105
def tts
    @tts ||= Tts.new self
end
ura() click to toggle source
# File lib/client.rb, line 109
def ura
    @ura ||= Ura.new self
end
verificacao() click to toggle source
# File lib/client.rb, line 117
def verificacao
  @verificacao ||= Verificacao.new self
end
webphone() click to toggle source
# File lib/client.rb, line 113
def webphone
    @webphone ||= Webphone.new self
end