internal static ProductStockOperationApiModel DeserializeProductStockOperationApiModel(XElement element)
        {
            double?        amount         = default;
            string         comments       = default;
            DateTimeOffset?createdTime    = default;
            long?          deliveryNoteId = default;
            long?          id             = default;
            long?          invoiceId      = default;
            ProductStockOperationApiModelOperationAction?operationAction = default;
            ProductStockOperationApiModelOperationType?  operationType   = default;
            string productFamily                         = default;
            long?  productId                             = default;
            string productInternalCode                   = default;
            string productName                           = default;
            double?productStockAfterOperation            = default;
            ProductStockOperationApiModelSubtype?subtype = default;
            ProductStockOperationApiModelType?   type    = default;

            if (element.Element("amount") is XElement amountElement)
            {
                amount = (double?)amountElement;
            }
            if (element.Element("comments") is XElement commentsElement)
            {
                comments = (string)commentsElement;
            }
            if (element.Element("createdTime") is XElement createdTimeElement)
            {
                createdTime = createdTimeElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("deliveryNoteId") is XElement deliveryNoteIdElement)
            {
                deliveryNoteId = (long?)deliveryNoteIdElement;
            }
            if (element.Element("id") is XElement idElement)
            {
                id = (long?)idElement;
            }
            if (element.Element("invoiceId") is XElement invoiceIdElement)
            {
                invoiceId = (long?)invoiceIdElement;
            }
            if (element.Element("operationAction") is XElement operationActionElement)
            {
                operationAction = new ProductStockOperationApiModelOperationAction(operationActionElement.Value);
            }
            if (element.Element("operationType") is XElement operationTypeElement)
            {
                operationType = new ProductStockOperationApiModelOperationType(operationTypeElement.Value);
            }
            if (element.Element("productFamily") is XElement productFamilyElement)
            {
                productFamily = (string)productFamilyElement;
            }
            if (element.Element("productId") is XElement productIdElement)
            {
                productId = (long?)productIdElement;
            }
            if (element.Element("productInternalCode") is XElement productInternalCodeElement)
            {
                productInternalCode = (string)productInternalCodeElement;
            }
            if (element.Element("productName") is XElement productNameElement)
            {
                productName = (string)productNameElement;
            }
            if (element.Element("productStockAfterOperation") is XElement productStockAfterOperationElement)
            {
                productStockAfterOperation = (double?)productStockAfterOperationElement;
            }
            if (element.Element("subtype") is XElement subtypeElement)
            {
                subtype = new ProductStockOperationApiModelSubtype(subtypeElement.Value);
            }
            if (element.Element("type") is XElement typeElement)
            {
                type = new ProductStockOperationApiModelType(typeElement.Value);
            }
            return(new ProductStockOperationApiModel(amount, comments, createdTime, deliveryNoteId, id, invoiceId, operationAction, operationType, productFamily, productId, productInternalCode, productName, productStockAfterOperation, subtype, type));
        }
        internal static ProductStockOperationApiModel DeserializeProductStockOperationApiModel(JsonElement element)
        {
            Optional <double>         amount         = default;
            Optional <string>         comments       = default;
            Optional <DateTimeOffset> createdTime    = default;
            Optional <long>           deliveryNoteId = default;
            Optional <long>           id             = default;
            Optional <long>           invoiceId      = default;
            Optional <ProductStockOperationApiModelOperationAction> operationAction = default;
            Optional <ProductStockOperationApiModelOperationType>   operationType   = default;
            Optional <string> productFamily                         = default;
            Optional <long>   productId                             = default;
            Optional <string> productInternalCode                   = default;
            Optional <string> productName                           = default;
            Optional <double> productStockAfterOperation            = default;
            Optional <ProductStockOperationApiModelSubtype> subtype = default;
            Optional <ProductStockOperationApiModelType>    type    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("amount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    amount = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("comments"))
                {
                    comments = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("deliveryNoteId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deliveryNoteId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    id = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("invoiceId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    invoiceId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("operationAction"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    operationAction = new ProductStockOperationApiModelOperationAction(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("operationType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    operationType = new ProductStockOperationApiModelOperationType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("productFamily"))
                {
                    productFamily = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("productId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    productId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("productInternalCode"))
                {
                    productInternalCode = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("productName"))
                {
                    productName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("productStockAfterOperation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    productStockAfterOperation = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("subtype"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    subtype = new ProductStockOperationApiModelSubtype(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new ProductStockOperationApiModelType(property.Value.GetString());
                    continue;
                }
            }
            return(new ProductStockOperationApiModel(Optional.ToNullable(amount), comments.Value, Optional.ToNullable(createdTime), Optional.ToNullable(deliveryNoteId), Optional.ToNullable(id), Optional.ToNullable(invoiceId), Optional.ToNullable(operationAction), Optional.ToNullable(operationType), productFamily.Value, Optional.ToNullable(productId), productInternalCode.Value, productName.Value, Optional.ToNullable(productStockAfterOperation), Optional.ToNullable(subtype), Optional.ToNullable(type)));
        }