Skip to content

Latest commit

 

History

History
156 lines (116 loc) · 4.32 KB

README.md

File metadata and controls

156 lines (116 loc) · 4.32 KB

C# Real Seguro Viagem

A C# wrapper for the seguroviagem.srv.br.

Installation

To install Seguro.Viagem.Srv.Api, run the following command in the Package Manager Console

PM> Install-Package Seguro.Viagem.Srv.Api

Begin

"Real Seguro Viagem has developed a practical way for you to create websites, applications and integrations with other systems allowing you to register new budgets and inform travelers and the chosen plan."

To begin, you need to have an seguroviagem.srv.br/afiliados account.

Structure

The solution structure (.sln) is based in The Onion Architecture

DataTranferObject (DTO) project, contains the call parameters used as either parameters in the URL or JSON keys in the POST body

RealSeguroProvider class implements the application services.

Usage

  1. Using Dependency Injection, the configuration of the application with Simple Injector might look something like this:
   var container = new Container();

   container.RegisterSingleton<IServiceProvider>(container);
   container.RegisterSingleton<IInsuranceProviderFactory, InsuranceProviderFactory>();
  1. Get container InsuranceProvider app service factory
var insuranceProviderFactory = container.GetInstance<IInsuranceProviderFactory>();
  1. Create insurance provider
var insuranceProvider = insuranceProviderFactory.Create("https://www.seguroviagem.srv.br/seguro-viagem",
  "YOUR_TOKEN");
  1. Create budget request
var budgetRequest = new BudgetRequest
{
  viagem = new Travel { destino = Destiny.Brazil, partida = "11/06/2016", retorno = "21/06/2016" },
  cliente = new Client { nome = "Test", telefone = "(11) 55551234", email = "fulano@real-compare.com" },
  lead_tag = "tag-123456"
};
  1. Create budget by http post method
var budgetResponse = await insuranceProvider.CreateBudgetAsync(budgetRequest);

Use SrvJson to Serialize/Deserialize response.

var json = SrvJson<List<BudgetResponse>>.Serialize(budgetResponse);

json property value:

  [
  {
    "nome_plano": "Brasil",
    "tipo_de_seguro": "padrao",
    "apelido": "vital-card_brasil_MTc2IDEyMzYxNzM1NzguMA",
    "preco_em_reais": 58.0,
    "seguradora_logo": "https://d2co66ly98117g.cloudfront.net/fornecedores/logo/31/preview/qbe.png",
    "seguradora_nome": "Qbe",
    "assistencia_logo": "https://d2co66ly98117g.cloudfront.net/fornecedores/logo/31/preview/vital-card-logo.png",
    "assistencia_nome": "Vital Card",
    "idade_minima": 0,
    "idade_maxima": 100,
    "propriedades": [
      {
        "valor": 0.0
      },
      {
        "valor": 0.0
      },
      {
        "valor": 0.0
      },
      {
        "valor": 0.0
      },
      {
        "grupo": "assistencia-medica",
        "codigo": "a-med-enf",
        "nome": "Assistência Médica Acidente e Doença (por evento)",
        "modificador": "BRL",
        "valor": 5000.0
      },...
  1. Create info request
var infoRequest == new InfoRequest
{
  viagem = budgetRequest.viagem,
  cliente = budgetRequest.cliente,
  produto = new Product { apelido = "vital-card_brasil_XXXXXXX" },
  viajantes = new Dictionary<int, Traveler>()
};
  1. Inform product and travelers by http post method
var infoResponse = insuranceProvider.InfoProductTravelers(infoRequest)
var json = SrvJson<InfoResponse>.Serialize(infoResponse);

json property value:

{
  "url": "https://www.seguroviagem.srv.br/payment/xxxx/xxxxxx"
}

Download the examples for test your application :)

TODO

  • Write unit tests

License

This software is open source, licensed under the Apache License.
See LICENSE.me for details.