Giter VIP home page Giter VIP logo

totalvoice-go's Introduction

totalvoice-go

Cliente em Golang para consumo da API da TotalVoice

Build Status

Funcionalidades

  • Gerenciamento das chamadas
  • Consulta e envio de SMS
  • Consulta e envio de TTS
  • Consulta e envio de Audio
  • Consulta e envio de Composto
  • Consulta e envio de Conferência
  • Gerenciamento da Conta
  • Gerenciamento da Central
  • Gerenciamento de DID

Requisitos

  • Golang 1.6+

Instalação

Para instalar a biblioteca basta digitar

go get github.com/totalvoice/totalvoice-go

Utilização

Para utilizar esta biblioteca, primeiramente você deverá realizar um cadastro no site da Total Voice. Após a criação do cadastro será disponibilizado um AccessToken para acesso a API.

Com o AccessToken em mãos será possível realizar as consultas/cadastros conforme documentação da API

Os métodos da API que poderão ser invocados:

  • audio
  • central
  • chamada
  • composto
  • conferencia
  • conta
  • perfil
  • sms
  • tts
  • did

A seguir exemplos de como pode ser utilizada esta biblioteca.

Realiza uma chamada telefônica entre dois números: A e B
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Chamada.Criar("4811111111", "4822222222", nil)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Consulta de chamada pelo ID
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Chamada.Buscar(123) // ID da chamada

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Encerra uma chamada ativa
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Chamada.Encerrar(123) // ID da chamada

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Relatório de Chamadas
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

	client := totalvoice.NewTotalVoiceClient("access-token")
	di := time.Date(2017, time.December, 06, 00, 20, 0, 0, time.Local)
	df := time.Date(2017, time.December, 06, 18, 20, 0, 0, time.Local)
	// parametros opcionais - filtros e paginacao
	filtros := map[string]interface{}{
		"origem": "48999999999",
		"destino": "489888888888",
		"posicao": 0,
		"limite":  100,
	}

	response, err := client.Chamada.Relatorio.Gerar(di, df, filtros)

  if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Envio de SMS
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.SMS.Enviar("4811111111", "Minha mensagem SMS", false, false, nil)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Relatório de SMS
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

	client := totalvoice.NewTotalVoiceClient("access-token")
	di := time.Date(2017, time.December, 06, 00, 20, 0, 0, time.Local)
	df := time.Date(2017, time.December, 06, 18, 20, 0, 0, time.Local)
	response, err := client.SMS.Relatorio.Gerar(di, df)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Envio de TTS
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.TTS.Enviar("4811111111", "Minha mensagem TTS", nil)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Envio de TTS com opções adicionais
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    opcoes := map[string]interface{}{
        "velocidade": 1,
        "resposta_usuario": true,
        "tipo_voz": "br-Vitoria",
        "bina": "4811111111",
	}
    response, err := client.TTS.Enviar("4811111111", "Minha mensagem TTS", opcoes)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Relatório de TTS
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

	client := totalvoice.NewTotalVoiceClient("access-token")
	di := time.Date(2017, time.December, 06, 00, 20, 0, 0, time.Local)
	df := time.Date(2017, time.December, 06, 18, 20, 0, 0, time.Local)
	response, err := client.TTS.Relatorio.Gerar(di, df)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Envio de Audio
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Audio.Enviar("4811111111", "http://foooo.bar/audio.mp3", false, "4811111111", false)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Configurações de central telefonica
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    ramal = new(Ramal)
    ramal.Ramal = "4001"
    ramal.Login = "[email protected]"
    ramal.Senha = "12345789"
    response, err := client.Ramal.Criar(ramal)

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Gerenciamento dos dados da Conta
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Conta.Buscar(123) // ID da Conta

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Visualizando os dados da Minha Conta
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Perfil.MinhaConta()

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Consulta saldo da Minha Conta
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Saldo.ConsultaSaldo()

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Gerar URL de Recarga
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Perfil.GeraURLRecarga()

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Relatório de Recarga
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.Perfil.RelatorioRecarga()

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Listando DIDs no estoque
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.DID.Estoque()

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Adquirindo um DID
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewTotalVoiceClient("access-token")
    response, err := client.DID.Adquirir(123) // ID do DID

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}
Caso você necessite utilizar seu próprio endereço configurado na Total Voice
package main

import (
	"fmt"

	"github.com/totalvoice/totalvoice-go"
)

func main() {

    client := totalvoice.NewClient("access-token", "https://seudominio.com.br")
    response, err := client.Saldo.ConsultaSaldo()

    if err != nil {
		panic(err)
	}

	fmt.Println(response)
}

Mais informações sobre os métodos disponíveis podem ser encontrados na documentação da API

Contribua!

Quer contribuir? clique aqui

Licença

Esta biblioteca segue os termos de uso da MIT

totalvoice-go's People

Contributors

andrewronscki avatar carloshenriqueds avatar dilowagner avatar marcelitocs avatar raphaelmacsabpf avatar vinifinger avatar wendermrn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.