Class: TotalVoice::API
Overview
Inicializa o HTTP client
Constant Summary collapse
- ENDPOINT =
'https://api2.totalvoice.com.br'
Instance Method Summary collapse
- #audio ⇒ Object
- #bina ⇒ Object
- #chamada ⇒ Object
- #composto ⇒ Object
- #conferencia ⇒ Object
- #conta ⇒ Object
-
#delete(route) ⇒ json
DELETE HTTP Method.
- #did ⇒ Object
- #fila ⇒ Object
-
#get(route, query = nil) ⇒ json
GET HTTP Method.
-
#initialize(access_token, host = nil, options = {}) ⇒ API
constructor
-
Args : -
Access-Token-> Access-Token TotalVoice -host-> Base URL para API.
-
- #perfil ⇒ Object
-
#post(route, params) ⇒ json
POST HTTP Method.
-
#put(route, params) ⇒ json
PUT HTTP Method.
- #ramal ⇒ Object
- #sms ⇒ Object
- #tts ⇒ Object
- #ura ⇒ Object
- #verificacao ⇒ Object
- #webphone ⇒ Object
Constructor Details
#initialize(access_token, host = nil, options = {}) ⇒ API
-
Args :
-
Access-Token-> Access-Token TotalVoice -
host-> Base URL para API
-
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/client.rb', line 31 def initialize(access_token, host = nil, = {}) @access_token = access_token @host = host ? host : ENDPOINT = { headers: { 'Access-Token' => @access_token, 'Content-Type' => 'application/json', 'Accept' => 'application/json' } }.merge() @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 |
Instance Method Details
#audio ⇒ Object
59 60 61 |
# File 'lib/client.rb', line 59 def audio @audio ||= Audio.new self end |
#bina ⇒ Object
63 64 65 |
# File 'lib/client.rb', line 63 def bina @bina ||= Bina.new self end |
#chamada ⇒ Object
71 72 73 |
# File 'lib/client.rb', line 71 def chamada @chamada ||= Chamada.new self end |
#composto ⇒ Object
75 76 77 |
# File 'lib/client.rb', line 75 def composto @composto ||= Composto.new self end |
#conferencia ⇒ Object
79 80 81 |
# File 'lib/client.rb', line 79 def conferencia @conferencia ||= Conferencia.new self end |
#conta ⇒ Object
83 84 85 |
# File 'lib/client.rb', line 83 def conta @conta ||= Conta.new self end |
#delete(route) ⇒ json
DELETE HTTP Method
171 172 173 |
# File 'lib/client.rb', line 171 def delete(route) self.class.delete(@host + route.build(), ); end |
#did ⇒ Object
87 88 89 |
# File 'lib/client.rb', line 87 def did @did ||= Did.new self end |
#fila ⇒ Object
67 68 69 |
# File 'lib/client.rb', line 67 def fila @fila ||= Fila.new self end |
#get(route, query = nil) ⇒ json
GET HTTP Method
125 126 127 128 129 130 131 132 133 |
# File 'lib/client.rb', line 125 def get(route, query = nil) url = @host + route.build() if(query.instance_of?(Query)) url = url + query.to_query() end self.class.get(url, ); end |
#perfil ⇒ Object
91 92 93 |
# File 'lib/client.rb', line 91 def perfil @perfil ||= Perfil.new self end |
#post(route, params) ⇒ json
POST HTTP Method
142 143 144 145 146 147 148 |
# File 'lib/client.rb', line 142 def post(route, params) data = { body: params.to_json } .merge!(data) self.class.post(@host + route.build(), ); end |
#put(route, params) ⇒ json
PUT HTTP Method
157 158 159 160 161 162 163 |
# File 'lib/client.rb', line 157 def put(route, params) data = { body: params.to_json } .merge!(data) self.class.put(@host + route.build(), ); end |
#ramal ⇒ Object
95 96 97 |
# File 'lib/client.rb', line 95 def ramal @ramal ||= Ramal.new self end |
#sms ⇒ Object
99 100 101 |
# File 'lib/client.rb', line 99 def sms @sms ||= Sms.new self end |
#tts ⇒ Object
103 104 105 |
# File 'lib/client.rb', line 103 def tts @tts ||= Tts.new self end |
#ura ⇒ Object
107 108 109 |
# File 'lib/client.rb', line 107 def ura @ura ||= Ura.new self end |
#verificacao ⇒ Object
115 116 117 |
# File 'lib/client.rb', line 115 def verificacao @verificacao ||= Verificacao.new self end |
#webphone ⇒ Object
111 112 113 |
# File 'lib/client.rb', line 111 def webphone @webphone ||= Webphone.new self end |