private async ValueTask <WebServiceFeClient> CreateNewClient(bool isProduction) { try { var environment = _afipEnvironments.GetAfipEnvironment(isProduction: isProduction); var loginClient = new LoginCmsClient(environment, _logger); var wsfeTicket = await loginClient.LoginCmsAsync("wsfe"); var wsfeClient = new WebServiceFeClient(environment.Cuit, wsfeTicket.Token, wsfeTicket.Sign, isProduction, this); if (isProduction) { _clientProduction = wsfeClient; _ticketProduction = wsfeTicket; } else { _clientTesting = wsfeClient; _ticketTesting = wsfeTicket; } return(wsfeClient); } catch (Exception ex) { _clientProduction = null; _ticketProduction = null; _clientTesting = null; _ticketTesting = null; _logger.LogError(ex, $"AfipFeSoapClientFactory.CreateNewClient - Error: {ex.Message}"); throw; } }
private static async Task PrintTaxesTypes(WebServiceFeClient wsfeClient, string json) { var taxesTypes = await wsfeClient.GetTaxesTypesAsync(); var items = taxesTypes.Body.FEParamGetTiposTributosResult.ResultGet ?? new List <TributoTipo>(); foreach (var i in items) { Console.WriteLine($"{i.Desc.Replace(" ", "")}={i.Id}"); } json = JsonConvert.SerializeObject(taxesTypes, Formatting.Indented); Console.WriteLine(json); await File.WriteAllTextAsync("ComprobantesTipoConsultarResponse.json", json); }