internal static ApiListResultClassItem DeserializeApiListResultClassItem(XElement element)
        {
            long?count      = default;
            long?totalCount = default;
            IReadOnlyList <ClassItem> data = default;

            if (element.Element("count") is XElement countElement)
            {
                count = (long?)countElement;
            }
            if (element.Element("totalCount") is XElement totalCountElement)
            {
                totalCount = (long?)totalCountElement;
            }
            var array = new List <ClassItem>();

            foreach (var e in element.Elements("ClassItem"))
            {
                array.Add(ClassItem.DeserializeClassItem(e));
            }
            data = array;
            return(new ApiListResultClassItem(count, data, totalCount));
        }
        internal static ConfigurationApiModel DeserializeConfigurationApiModel(JsonElement element)
        {
            Optional <IReadOnlyList <CountryApiModel> >     allCountries            = default;
            Optional <IReadOnlyList <CompanyTypeApiModel> > companyTypes            = default;
            Optional <IReadOnlyList <CountryApiModel> >     countries               = default;
            Optional <IReadOnlyList <IrpfModeApiModel> >    irpfEstimationModes     = default;
            Optional <IReadOnlyList <ClassItem> >           issuedInvoicesClasses   = default;
            Optional <IReadOnlyList <ClassItem> >           receivedInvoicesClasses = default;
            Optional <IReadOnlyList <VatModeApiModel> >     vatModes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("allCountries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <CountryApiModel> array = new List <CountryApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(CountryApiModel.DeserializeCountryApiModel(item));
                    }
                    allCountries = array;
                    continue;
                }
                if (property.NameEquals("companyTypes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <CompanyTypeApiModel> array = new List <CompanyTypeApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(CompanyTypeApiModel.DeserializeCompanyTypeApiModel(item));
                    }
                    companyTypes = array;
                    continue;
                }
                if (property.NameEquals("countries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <CountryApiModel> array = new List <CountryApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(CountryApiModel.DeserializeCountryApiModel(item));
                    }
                    countries = array;
                    continue;
                }
                if (property.NameEquals("irpfEstimationModes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <IrpfModeApiModel> array = new List <IrpfModeApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(IrpfModeApiModel.DeserializeIrpfModeApiModel(item));
                    }
                    irpfEstimationModes = array;
                    continue;
                }
                if (property.NameEquals("issuedInvoicesClasses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ClassItem> array = new List <ClassItem>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ClassItem.DeserializeClassItem(item));
                    }
                    issuedInvoicesClasses = array;
                    continue;
                }
                if (property.NameEquals("receivedInvoicesClasses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ClassItem> array = new List <ClassItem>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ClassItem.DeserializeClassItem(item));
                    }
                    receivedInvoicesClasses = array;
                    continue;
                }
                if (property.NameEquals("vatModes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VatModeApiModel> array = new List <VatModeApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VatModeApiModel.DeserializeVatModeApiModel(item));
                    }
                    vatModes = array;
                    continue;
                }
            }
            return(new ConfigurationApiModel(Optional.ToList(allCountries), Optional.ToList(companyTypes), Optional.ToList(countries), Optional.ToList(irpfEstimationModes), Optional.ToList(issuedInvoicesClasses), Optional.ToList(receivedInvoicesClasses), Optional.ToList(vatModes)));
        }