public async void ShootEventoGet() { WebRequestHandler handler = new WebRequestHandler(); handler.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; using (var client = new HttpClient()) { client.BaseAddress = new Uri(gArenaUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Add("Authorization", gApiKey); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); switch (NomeEvento) { case "RequestDeLogin": var lCliente = ClienteContaServico.ConsultarClienteConta(IdCliente); LoginRequest.Phone = lCliente.Phone; LoginRequest.IdClienteGradual = lCliente.ID; LoginRequest.IsBovespaAllowed = lCliente.StatusBovespa; LoginRequest.IsBmfAllowed = lCliente.StatusBmf; LoginRequest.IsSuperQualified = false; HttpResponseMessage response = await client.GetAsync(ApiEnvio); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { var lRedirectUrl = await response.Content.ReadAsAsync <string>(); //return lRedirectUrl; // HTTP PUT //gizmo.Price = 80; // Update price //response = await client.PutAsJsonAsync(gizmoUrl, gizmo); // HTTP DELETE //response = await client.DeleteAsync(gizmoUrl); //Uri gizmoUrl = response.Headers.Location; //lRetorno = lRedirectUrl; } break; } //HttpResponseMessage response = await client.GetAsync("api/products/1"); //HttpResponseMessage response = await client.GetAsync(ApiEnvio); //if (response.IsSuccessStatusCode) //{ // //Product product = await response.Content.ReadAsAsync>Product>(); // //Console.WriteLine("{0}\t${1}\t{2}", product.Name, product.Price, product.Category); //} } }
// GET api_teste/posicao/5 public PosicaoCliente Get(int id) { var lRetornoPosicao = new PosicaoCliente(); try { Cliente lCliente = ClienteContaServico.ConsultarClienteConta(id); int lCodigoBovespa = lCliente.CodigoBovespa; var lCustodia = gServicoCustodia.GetPosicaoCustodiaCliente(lCodigoBovespa); if (lCustodia.CodigoClienteBov.HasValue) { lRetornoPosicao.CodigoBovespaCliente = lCustodia.CodigoClienteBov.Value; lCodigoBovespa = lCustodia.CodigoClienteBov.Value; } if (lCustodia.CodigoClienteBmf.HasValue) { lRetornoPosicao.CodigoBmfCliente = lCustodia.CodigoClienteBmf.Value; } var lContaCorrente = gServicoContaCorrente.GetSaldoContaCorrenteCliente(lCodigoBovespa); lRetornoPosicao.SaldoFinanceiro = TransporteFinanceiro.TraduzirCustodiaInfo(lContaCorrente); lRetornoPosicao.SaldoCustodiaBovespaCliente = TransporteCustodia.TraduzirCustodiaInfo(lCustodia.ListaCustodia); lRetornoPosicao.SaldoCustodiaBmfCliente = TransporteCustodia.TraduzirCustodiaInfo(lCustodia.ListaPosicaoDiaBMF, lCustodia.ListaCustodia); } catch (Exception ex) { throw (ex); } return(lRetornoPosicao); }
public async Task <string> ShootEventPost() { string lRetorno = string.Empty; try { WebRequestHandler handler = new WebRequestHandler(); //X509Certificate2 certificate = GetMyX509Certificate(); //handler.ClientCertificates.Add(certificate); //HttpClient client = new HttpClient(handler); handler.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; using (var client = new HttpClient(handler)) { client.BaseAddress = new Uri(gArenaUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Add("Authorization", gApiKey); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); switch (NomeEvento) { case "RequestDeLogin": var lCliente = ClienteContaServico.ConsultarClienteConta(IdCliente); LoginRequest.Phone = lCliente.Phone; LoginRequest.IdClienteGradual = lCliente.ID; LoginRequest.IsBovespaAllowed = lCliente.StatusBovespa; LoginRequest.IsBmfAllowed = lCliente.StatusBmf; LoginRequest.IsSuperQualified = false; HttpResponseMessage response = await client.PostAsJsonAsync(ApiEnvio, LoginRequest); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; response.EnsureSuccessStatusCode(); //response if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsAsync <string>()); //return lRedirectUrl; // HTTP PUT //gizmo.Price = 80; // Update price //response = await client.PutAsJsonAsync(gizmoUrl, gizmo); // HTTP DELETE //response = await client.DeleteAsync(gizmoUrl); //Uri gizmoUrl = response.Headers.Location; //lRetorno = lRedirectUrl; } break; } } } catch (Exception ex) { //gLogger.Error(); } return(lRetorno); }