internal static ApiListResultIrpfModeApiModel DeserializeApiListResultIrpfModeApiModel(JsonElement element)
        {
            Optional <long> count = default;
            Optional <IReadOnlyList <IrpfModeApiModel> > data = default;
            Optional <long> totalCount = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("data"))
                {
                    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));
                    }
                    data = array;
                    continue;
                }
                if (property.NameEquals("totalCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalCount = property.Value.GetInt64();
                    continue;
                }
            }
            return(new ApiListResultIrpfModeApiModel(Optional.ToNullable(count), Optional.ToList(data), Optional.ToNullable(totalCount)));
        }
Example #2
0
        internal static ApiResultIrpfModeApiModel DeserializeApiResultIrpfModeApiModel(JsonElement element)
        {
            Optional <IrpfModeApiModel> data = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    data = IrpfModeApiModel.DeserializeIrpfModeApiModel(property.Value);
                    continue;
                }
            }
            return(new ApiResultIrpfModeApiModel(data.Value));
        }
        internal static ApiListResultIrpfModeApiModel DeserializeApiListResultIrpfModeApiModel(XElement element)
        {
            long?count      = default;
            long?totalCount = default;
            IReadOnlyList <IrpfModeApiModel> 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 <IrpfModeApiModel>();

            foreach (var e in element.Elements("IrpfModeApiModel"))
            {
                array.Add(IrpfModeApiModel.DeserializeIrpfModeApiModel(e));
            }
            data = array;
            return(new ApiListResultIrpfModeApiModel(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)));
        }