A C# wrapper for the seguroviagem.srv.br.
To install Seguro.Viagem.Srv.Api, run the following command in the Package Manager Console
PM> Install-Package Seguro.Viagem.Srv.Api
"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.
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
-
Budget
-
Info
RealSeguroProvider class implements the application services.
- 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>();
- Get container InsuranceProvider app service factory
var insuranceProviderFactory = container.GetInstance<IInsuranceProviderFactory>();
- Create insurance provider
var insuranceProvider = insuranceProviderFactory.Create("https://www.seguroviagem.srv.br/seguro-viagem",
"YOUR_TOKEN");
- 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"
};
- 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
},...
- 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>()
};
- 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 :)
- Write unit tests
This software is open source, licensed under the Apache License.
See LICENSE.me for details.