public override async Task <CuentaResponse> ConsultarSaldoCta (CuentaRequest request, ServerCallContext _context) { logger.LogWarning("Llego a opbanca grpc"); // TxRequestBE be = new TxRequestBE() // { // IdCuentaDestino = request.IdCuentaDestino, // }; SaldoCuentaResponseBE resp = await cuentaServices.RecuperarSaldoIdCuenta(request.IdCuenta); CuentaResponse txRpta = new CuentaResponse() { Saldo = (double)resp.Amount }; return(txRpta); }
public async Task <SaldoCuentaResponseBE> ConsultaSaldo(int codCuenta) { var handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; var miHttpClient = new HttpClient(handler); TokenResponseDTO responseToken = await tokenAdapter.GeneraToken(); var metadata = new Metadata(); metadata.Add("Authorization", $"Bearer {responseToken.Token}"); var channel = GrpcChannel.ForAddress (configuration.GetValue <string>("UrlApiCliente"), new GrpcChannelOptions { HttpClient = miHttpClient }); BancaServiceGrpc.BancaServiceGrpcClient client = new BancaServiceGrpc.BancaServiceGrpcClient(channel); CuentaRequest request = new CuentaRequest() { IdCuenta = codCuenta }; CuentaResponse response = await client.ConsultarSaldoCtaAsync (request, headers : metadata); SaldoCuentaResponseBE txResponseBE = new SaldoCuentaResponseBE() { Amount = (decimal)response.Saldo, Date = DateTime.Now }; return(txResponseBE); //return null; }