internal static ApiListResultInvoiceApiModel DeserializeApiListResultInvoiceApiModel(JsonElement element)
        {
            Optional <long> count = default;
            Optional <IReadOnlyList <InvoiceApiModel> > 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 <InvoiceApiModel> array = new List <InvoiceApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(InvoiceApiModel.DeserializeInvoiceApiModel(item));
                    }
                    data = array;
                    continue;
                }
                if (property.NameEquals("totalCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalCount = property.Value.GetInt64();
                    continue;
                }
            }
            return(new ApiListResultInvoiceApiModel(Optional.ToNullable(count), Optional.ToList(data), Optional.ToNullable(totalCount)));
        }
Exemple #2
0
        internal static ApiResultInvoiceApiModel DeserializeApiResultInvoiceApiModel(JsonElement element)
        {
            Optional <InvoiceApiModel> data = default;

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

            foreach (var e in element.Elements("InvoiceApiModel"))
            {
                array.Add(InvoiceApiModel.DeserializeInvoiceApiModel(e));
            }
            data = array;
            return(new ApiListResultInvoiceApiModel(count, data, totalCount));
        }