Exemplo n.º 1
0
 internal ExpenseApiModel(long?aeatAprovedFileId, double?amount, double?computablePercentage, string concept, DateTimeOffset?creationTime, int?expenseClass, string expenseClassDescription, DateTimeOffset?expenseDate, DocumentPaymentApiModel expensePayment, bool?hasAeatAprovedFile, long?id, ExpenseEntity issuer, DateTimeOffset?modificationTime, string notes, string number, string period)
 {
     AeatAprovedFileId       = aeatAprovedFileId;
     Amount                  = amount;
     ComputablePercentage    = computablePercentage;
     Concept                 = concept;
     CreationTime            = creationTime;
     ExpenseClass            = expenseClass;
     ExpenseClassDescription = expenseClassDescription;
     ExpenseDate             = expenseDate;
     ExpensePayment          = expensePayment;
     HasAeatAprovedFile      = hasAeatAprovedFile;
     Id               = id;
     Issuer           = issuer;
     ModificationTime = modificationTime;
     Notes            = notes;
     Number           = number;
     Period           = period;
 }
        internal static ExpenseApiModel DeserializeExpenseApiModel(XElement element)
        {
            long?                   aeatAprovedFileId       = default;
            double?                 amount                  = default;
            double?                 computablePercentage    = default;
            string                  concept                 = default;
            DateTimeOffset?         creationTime            = default;
            int?                    expenseClass            = default;
            string                  expenseClassDescription = default;
            DateTimeOffset?         expenseDate             = default;
            DocumentPaymentApiModel expensePayment          = default;
            bool?                   hasAeatAprovedFile      = default;
            long?                   id               = default;
            ExpenseEntity           issuer           = default;
            DateTimeOffset?         modificationTime = default;
            string                  notes            = default;
            string                  number           = default;
            string                  period           = default;

            if (element.Element("aeatAprovedFileId") is XElement aeatAprovedFileIdElement)
            {
                aeatAprovedFileId = (long?)aeatAprovedFileIdElement;
            }
            if (element.Element("amount") is XElement amountElement)
            {
                amount = (double?)amountElement;
            }
            if (element.Element("computablePercentage") is XElement computablePercentageElement)
            {
                computablePercentage = (double?)computablePercentageElement;
            }
            if (element.Element("concept") is XElement conceptElement)
            {
                concept = (string)conceptElement;
            }
            if (element.Element("creationTime") is XElement creationTimeElement)
            {
                creationTime = creationTimeElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("expenseClass") is XElement expenseClassElement)
            {
                expenseClass = (int?)expenseClassElement;
            }
            if (element.Element("expenseClassDescription") is XElement expenseClassDescriptionElement)
            {
                expenseClassDescription = (string)expenseClassDescriptionElement;
            }
            if (element.Element("expenseDate") is XElement expenseDateElement)
            {
                expenseDate = expenseDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("expensePayment") is XElement expensePaymentElement)
            {
                expensePayment = DocumentPaymentApiModel.DeserializeDocumentPaymentApiModel(expensePaymentElement);
            }
            if (element.Element("hasAeatAprovedFile") is XElement hasAeatAprovedFileElement)
            {
                hasAeatAprovedFile = (bool?)hasAeatAprovedFileElement;
            }
            if (element.Element("id") is XElement idElement)
            {
                id = (long?)idElement;
            }
            if (element.Element("issuer") is XElement issuerElement)
            {
                issuer = ExpenseEntity.DeserializeExpenseEntity(issuerElement);
            }
            if (element.Element("modificationTime") is XElement modificationTimeElement)
            {
                modificationTime = modificationTimeElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("notes") is XElement notesElement)
            {
                notes = (string)notesElement;
            }
            if (element.Element("number") is XElement numberElement)
            {
                number = (string)numberElement;
            }
            if (element.Element("period") is XElement periodElement)
            {
                period = (string)periodElement;
            }
            return(new ExpenseApiModel(aeatAprovedFileId, amount, computablePercentage, concept, creationTime, expenseClass, expenseClassDescription, expenseDate, expensePayment, hasAeatAprovedFile, id, issuer, modificationTime, notes, number, period));
        }
        internal static ExpenseApiModel DeserializeExpenseApiModel(JsonElement element)
        {
            Optional <long>                    aeatAprovedFileId       = default;
            Optional <double>                  amount                  = default;
            Optional <double>                  computablePercentage    = default;
            Optional <string>                  concept                 = default;
            Optional <DateTimeOffset>          creationTime            = default;
            Optional <int>                     expenseClass            = default;
            Optional <string>                  expenseClassDescription = default;
            Optional <DateTimeOffset>          expenseDate             = default;
            Optional <DocumentPaymentApiModel> expensePayment          = default;
            Optional <bool>                    hasAeatAprovedFile      = default;
            Optional <long>                    id               = default;
            Optional <ExpenseEntity>           issuer           = default;
            Optional <DateTimeOffset>          modificationTime = default;
            Optional <string>                  notes            = default;
            Optional <string>                  number           = default;
            Optional <string>                  period           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("aeatAprovedFileId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    aeatAprovedFileId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("amount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    amount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("computablePercentage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    computablePercentage = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("concept"))
                {
                    concept = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("creationTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    creationTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("expenseClass"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expenseClass = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("expenseClassDescription"))
                {
                    expenseClassDescription = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expenseDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expenseDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("expensePayment"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expensePayment = DocumentPaymentApiModel.DeserializeDocumentPaymentApiModel(property.Value);
                    continue;
                }
                if (property.NameEquals("hasAeatAprovedFile"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hasAeatAprovedFile = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    id = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("issuer"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    issuer = ExpenseEntity.DeserializeExpenseEntity(property.Value);
                    continue;
                }
                if (property.NameEquals("modificationTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    modificationTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("notes"))
                {
                    notes = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("number"))
                {
                    number = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("period"))
                {
                    period = property.Value.GetString();
                    continue;
                }
            }
            return(new ExpenseApiModel(Optional.ToNullable(aeatAprovedFileId), Optional.ToNullable(amount), Optional.ToNullable(computablePercentage), concept.Value, Optional.ToNullable(creationTime), Optional.ToNullable(expenseClass), expenseClassDescription.Value, Optional.ToNullable(expenseDate), expensePayment.Value, Optional.ToNullable(hasAeatAprovedFile), Optional.ToNullable(id), issuer.Value, Optional.ToNullable(modificationTime), notes.Value, number.Value, period.Value));
        }