totalvoice node
Versão 1.12.0
Cliente en NodeJS para TotalVoice API
Funcionalidad
Requisitos
Instalación
npm install --save totalvoice-nodeo
yarn add totalvoice-nodeUsar
Para usar esta biblioteca, primero debe registrarse en el sitio web de Total Voice. Después de la creación del registro, estará disponible un accessostoken para acceder a la API.
Con AccessSstoken en la mano, será posible hacer las consultas/registros de acuerdo con la documentación de la API
Métodos API que se pueden invocar:
Los siguientes ejemplos de cómo se puede usar esta biblioteca.
Hace una llamada telefónica entre dos números: A y B
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . chamada . ligar ( "4832830151" , "4811111111" )
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; Consulta de llamadas por identificación
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . chamada . buscar ( 123 ) // ID da chamada
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; Cierra una llamada activa
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . chamada . encerrar ( 123 ) // ID da chamada
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; Envío de SMS
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
var resposta_usuario = false ;
var multi_sms = false ;
var data_criacao = '' ;
client . sms . enviar ( "4811111111" , "Mensagem SMS" , resposta_usuario , multi_sms , data_criacao )
. then ( function ( data ) {
console . log ( data )
} )
. catch ( function ( error ) {
console . error ( 'Erro: ' , error )
} ) ; Envío TTS
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
var opcoes = { velocidade : 2 , tipo_voz : "br-Vitoria" , bina : "bina_cadastrada" } ;
client . tts . enviar ( "4811111111" , "Mensagem TTS" , opcoes ) ;
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; Envío de audio
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . audio . enviar ( "4811111111" , "https://foo.bar/audio.mp3" )
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; Configuración telefónica central
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . central . buscaRamal ( 123546 ) // ID do Ramal
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; Gestión de datos de cuenta
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . conta . buscar ( 123546 ) // ID da Conta
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; Saldo saldo mi cuenta
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" ) ;
client . perfil . consultaSaldo ( )
. then ( function ( data ) {
console . log ( data ) ;
} )
. catch ( function ( error ) {
console . log ( 'Erro: ' , error )
} ) ; Si necesita usar su propia dirección configurada con voz total
const totalvoice = require ( 'totalvoice-node' ) ;
const client = new totalvoice ( "access-token" , "https://seu-dominio.com.br" ) ;
...Si necesita usarlo con proxy
const totalvoice = require ( 'totalvoice-node' ) ;
let options = {
proxy : {
host : 'proxy.com' ,
port : 8888 ,
auth : {
username : 'XXXX' ,
password : 'XXXX'
}
}
} ;
const client = new totalvoice ( "access-token" , "https://seu-dominio.com.br" , options ) ;
...Puede encontrar más información sobre los métodos disponibles en la documentación de la API
¡Contribuir!
¿Quieres contribuir? haga clic aquí
Licencia
Esta biblioteca sigue los términos de uso del MIT