Skip to content

totalvoice/totalvoice-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

totalvoice-csharp

Client C# para a API da TotalVoice

Funcionalidades

  • Gerenciamento das chamadas
  • Consulta e envio de SMS
  • Consulta e envio de TTS
  • Consulta e envio de Audio
  • Gerenciamento da Conta
  • Gerenciamento de Ramais
  • URL do Webphone
  • Gerenciamento de DID

Pré requisitos

  • .NET Framework 4.6.1 ou .NET Core 2.0
  • Nuget

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

Instalando com o gerenciador de pacotes Nuget

PM> Install-Package TotalVoice -Version 1.0.1

ou .NET CLI

dotnet add package TotalVoice --version 1.0.1

A seguir alguns exemplos de como pode ser utilizada esta biblioteca.

Realizar uma chamada telefônica entre dois números: A e B
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            Chamada chamada = new Chamada(client);
            var json = new {
                numero_origem  = "48988888888",
                numero_destino = "48999999999"
            };
            string response = chamada.Ligar(json);
            System.Diagnostics.Debug.WriteLine(response);
        }
    }
}
Consulta de chamada pelo ID
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            Chamada chamada = new Chamada(client);
            string response = chamada.Buscar(123);
            System.Diagnostics.Debug.WriteLine(response);
        }
    }
}
Enviar um SMS
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            Sms sms = new Sms(client);
            var json = new {
                numero_destino = "48999999999",
                mensagem = "Mensagem de teste"
            };
            string response = sms.Enviar(json);
            System.Diagnostics.Debug.WriteLine(response);
        }
    }
}
Buscar os dados de um SMS pelo ID
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            Sms sms = new Sms(client);
            string response = sms.Buscar(123);
            System.Diagnostics.Debug.WriteLine(response);
        }
    }
}
Enviar um TTS
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            Tts tts = new Tts(client);
            var json = new {
                numero_destino = "48999999999",
                mensagem = "Mensagem de TTS"
            };
            string response = tts.Enviar(json);
            System.Diagnostics.Debug.WriteLine(response);
        }
    }
}
Validacao de Numero
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            ValidaNumero validacao = new ValidaNumero(client);
            var json = new {
                numero_destino = "48999999999",
                gravar_audio   = true,
                bina           = "48808880804",
                max_tentativas = 1
            };
            string response = validacao.Enviar(json);
            System.Diagnostics.Debug.WriteLine(response);
        }
    }
}
Enviar um Composto
namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            TotalVoiceClient client = new TotalVoiceClient("access-token");
            Composto composto = new Composto(client);
            var json = new {
              numero_destino = "48988888888",
              dados = new[] {
                 new {
                   acao = "tts",
                   acao_dados = new {
                     mensagem = "O número digitado não consta em nosso cadastro. Por gentileza, tente novamente",
                     tipo_voz = "br-Ricardo" 
                   }
                 },
                 new {
                   acao = "audio",
                   acao_dados = new {
                     url_audio = "https://minhaurl.com.br/audio.mp3"
                   }
                 }
              },
              gravar_audio     = false,
              bina             = "48988888888",
              tags             = "clienteX",
              detecta_caixa    = false
           };
           string response = composto.Enviar(json);
           System.Diagnostics.Debug.WriteLine(response);
        }
    }
}

Licença

Esta biblioteca segue os termos de uso da MIT