public async Task <Credentials> GetCredentials() { var service = new HttpRequestFactory(); var isError = false; var url = _configuration["GetCredentials:Url"]; if (IsValidCredentials()) { return(_credentials); } try { var now = DateTime.Now; var request = new AutenticarYAutorizarConsumoWebserviceRequest { BGBAHeader = await _objectFactory.InstantiateFromJsonFile <BGBAHeader>(_configuration["GetCredentials:BGBAHeader"]), Datos = new AutenticarYAutorizarConsumoWebserviceRequestDatos { IdRequerimiento = new Random(10000).Next(), HoraDesde = now.ToString("yyyy-MM-ddTHH:mm:sss.fff"), HoraHasta = now.AddMilliseconds(Convert.ToInt32(_configuration["GetCredentials:MillisecondsForValidToken"])).ToString("yyyy-MM-ddTHH:mm:sss.fff"), ServicioAConsumir = _configuration["GetCredentials:ServicioAConsumir"] } }; var response = (await service.Post(url, new SoapJsonContent(request, _configuration["GetCredentials:Operation"]), _cert)) .SoapContentAsJsonType <AutenticarYAutorizarConsumoWebserviceResponse>(); if (response.BGBAResultadoOperacion.Severidad == severidad.ERROR) { throw new Exception($"{response.BGBAResultadoOperacion.Codigo},{response.BGBAResultadoOperacion.Descripcion}"); } _endOfValidCredentials = now.AddMilliseconds(Convert.ToInt32(_configuration["GetCredentials:MillisecondsForValidToken"])); _credentials = _mapper.Map <AutenticarYAutorizarConsumoWebserviceResponseDatosCredenciales, Credentials>(response.Datos.Credenciales); return(_credentials); } catch (Exception e) { isError = true; throw new Exception("Error getting credentials", e); } finally { this.Communicator_TraceHandler(this, new TraceEventArgs { Description = "Get credentials afip.", ElapsedTime = service.ElapsedTime, ForceDebug = false, IsError = isError, Request = service.Request, Response = service.Response, URL = url }); } }
public AutenticarYAutorizarConsumoWebserviceResponse AutenticarYAutorizarConsumoWebservice(AutenticarYAutorizarConsumoWebserviceRequest AutenticarYAutorizarConsumoWebserviceRequest) { AutenticarYAutorizarConsumoWebserviceRequest1 inValue = new AutenticarYAutorizarConsumoWebserviceRequest1(); inValue.AutenticarYAutorizarConsumoWebserviceRequest = AutenticarYAutorizarConsumoWebserviceRequest; AutenticarYAutorizarConsumoWebserviceResponse1 retVal = ((AccionesAutenticacionAFIP)(this)).AutenticarYAutorizarConsumoWebservice(inValue); return(retVal.AutenticarYAutorizarConsumoWebserviceResponse); }
public System.Threading.Tasks.Task <AutenticarYAutorizarConsumoWebserviceResponse1> AutenticarYAutorizarConsumoWebserviceAsync(AutenticarYAutorizarConsumoWebserviceRequest AutenticarYAutorizarConsumoWebserviceRequest) { AutenticarYAutorizarConsumoWebserviceRequest1 inValue = new AutenticarYAutorizarConsumoWebserviceRequest1(); inValue.AutenticarYAutorizarConsumoWebserviceRequest = AutenticarYAutorizarConsumoWebserviceRequest; return(((AccionesAutenticacionAFIP)(this)).AutenticarYAutorizarConsumoWebserviceAsync(inValue)); }
public AutenticarYAutorizarConsumoWebserviceRequest1(AutenticarYAutorizarConsumoWebserviceRequest AutenticarYAutorizarConsumoWebserviceRequest) { this.AutenticarYAutorizarConsumoWebserviceRequest = AutenticarYAutorizarConsumoWebserviceRequest; }