public async Task <Address> GetAddressNV(string idHost) { var service = new HttpRequestFactory(); var isError = false; var url = _configuration["GetClientByIdHost:Url"]; BUS.ConsultaCliente.ObtenerClienteRequest request = null; try { request = new BUS.ConsultaCliente.ObtenerClienteRequest { BGBAHeader = await _objectFactory.InstantiateFromJsonFile <BUS.ConsultaCliente.BGBAHeader>(_configuration["GetClientByIdHost:BGBAHeader"]), Datos = new BUS.ConsultaCliente.ObtenerClienteRequestDatos { IdPersona = Convert.ToUInt64(idHost), DatosSolicitados = new BUS.ConsultaCliente.ObtenerClienteRequestDatosDatosSolicitados { SolicitudDatosPersona = new BUS.ConsultaCliente.SolicitudDatosPersona { SolicitaDatosDomicilio = true, SolicitaDatosEmail = true, SolicitaDatosPosesionEmail = true, SolicitaDatosTelefono = true } } } }; } catch (Exception e) { throw new Exception("Error generating the request", e); } try { var response = await service.Post(url, new SoapJsonContent(request, _configuration["GetClientByIdHost:Operation"]), _cert); dynamic soapResponse = JsonConvert.DeserializeObject <dynamic>( JsonConvert.SerializeObject( JObject.Parse(response.ContentAsString()) .SelectToken("..ObtenerClienteResponse"))); if (soapResponse.BGBAResultadoOperacion.Severidad == BUS.ConsultaCliente.severidad.ERROR) { throw new Exception($"{soapResponse.BGBAResultadoOperacion.Codigo} {soapResponse.BGBAResultadoOperacion.Descripcion}"); } dynamic s = soapResponse.PersonaFisica; var result = new Models.N.Location.Address { Default = true, Country = new Models.N.Location.Country { Code = s.Domicilio.Direccion.CodigoPais, Description = s.Domicilio.Direccion.DescripcionPais }, FlatNumber = s.Domicilio.Direccion.Departamento, Floor = s.Domicilio.Direccion.Piso, Location = new Models.N.Location.Location { Latitude = s.Domicilio.Direccion.Latitud, Longitude = s.Domicilio.Direccion.Longitud }, LocalityDescription = s.Domicilio.Direccion.NombreLocalidad, Number = s.Domicilio.Direccion.NumeroPuerta, PostalCode = s.Domicilio.Direccion.CodigoPostal.ToString(), Province = new Models.N.Location.Province { Code = s.Domicilio.Direccion.CodigoProvincia, Name = s.Domicilio.Direccion.DescripcionProvincia }, Street = s.Domicilio.Direccion.Calle, AddressType = BGBA.Models.N.Afip.AfipProfiler.RealAddress }; return(result); } catch (Exception e) { isError = true; throw new Exception("Error getting the client", e); } finally { this.Communicator_TraceHandler(this, new TraceEventArgs { Description = "Get client from NV.", ElapsedTime = service.ElapsedTime, ForceDebug = false, IsError = isError, Request = service.Request, Response = service.Response, URL = url }); } }
public async Task WhenICreateTheMenu() { lastResponse = await HttpRequestFactory.Post(baseUrl, menuPath, createMenuRequest); }