Class: TotalVoice::API
Overview
Inicializa o HTTP client
Constant Summary collapse
- ENDPOINT =
'https://voice-api.zenvia.com'
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
-
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 58 59 |
# File 'lib/client.rb', line 32 def initialize(access_token, host = nil, = {}) @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() @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
#chamada ⇒ Object
73 74 75 |
# File 'lib/client.rb', line 73 def chamada @chamada ||= Chamada.new self end |
#composto ⇒ Object
77 78 79 |
# File 'lib/client.rb', line 77 def composto @composto ||= Composto.new self end |
#conferencia ⇒ Object
81 82 83 |
# File 'lib/client.rb', line 81 def conferencia @conferencia ||= Conferencia.new self end |
#delete(route) ⇒ json
DELETE HTTP Method
173 174 175 |
# File 'lib/client.rb', line 173 def delete(route) self.class.delete(@host + route.build(), @options); end |
#get(route, query = nil) ⇒ json
GET HTTP Method
127 128 129 130 131 132 133 134 135 |
# 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 ⇒ Object
93 94 95 |
# File 'lib/client.rb', line 93 def perfil @perfil ||= Perfil.new self end |
#post(route, params) ⇒ json
POST HTTP Method
144 145 146 147 148 149 150 |
# 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) ⇒ json
PUT HTTP Method
159 160 161 162 163 164 165 |
# 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 |
#verificacao ⇒ Object
117 118 119 |
# File 'lib/client.rb', line 117 def verificacao @verificacao ||= Verificacao.new self end |