internal static CompanyLightweightApiModel DeserializeCompanyLightweightApiModel(XElement element)
        {
            int?           activated             = default;
            string         displayName           = default;
            long?          domainId              = default;
            string         email                 = default;
            DateTimeOffset?expirationDate        = default;
            long?          id                    = default;
            bool?          isDefault             = default;
            string         nif                   = default;
            string         organizationName      = default;
            bool?          requiresConfiguration = default;
            CompanyLightweightApiModelType?type  = default;

            if (element.Element("activated") is XElement activatedElement)
            {
                activated = (int?)activatedElement;
            }
            if (element.Element("displayName") is XElement displayNameElement)
            {
                displayName = (string)displayNameElement;
            }
            if (element.Element("domainId") is XElement domainIdElement)
            {
                domainId = (long?)domainIdElement;
            }
            if (element.Element("email") is XElement emailElement)
            {
                email = (string)emailElement;
            }
            if (element.Element("expirationDate") is XElement expirationDateElement)
            {
                expirationDate = expirationDateElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("id") is XElement idElement)
            {
                id = (long?)idElement;
            }
            if (element.Element("isDefault") is XElement isDefaultElement)
            {
                isDefault = (bool?)isDefaultElement;
            }
            if (element.Element("nif") is XElement nifElement)
            {
                nif = (string)nifElement;
            }
            if (element.Element("organizationName") is XElement organizationNameElement)
            {
                organizationName = (string)organizationNameElement;
            }
            if (element.Element("requiresConfiguration") is XElement requiresConfigurationElement)
            {
                requiresConfiguration = (bool?)requiresConfigurationElement;
            }
            if (element.Element("type") is XElement typeElement)
            {
                type = new CompanyLightweightApiModelType(typeElement.Value);
            }
            return(new CompanyLightweightApiModel(activated, displayName, domainId, email, expirationDate, id, isDefault, nif, organizationName, requiresConfiguration, type));
        }
        internal static CompanyLightweightApiModel DeserializeCompanyLightweightApiModel(JsonElement element)
        {
            Optional <int>            activated             = default;
            Optional <string>         displayName           = default;
            Optional <long>           domainId              = default;
            Optional <string>         email                 = default;
            Optional <DateTimeOffset> expirationDate        = default;
            Optional <long>           id                    = default;
            Optional <bool>           isDefault             = default;
            Optional <string>         nif                   = default;
            Optional <string>         organizationName      = default;
            Optional <bool>           requiresConfiguration = default;
            Optional <CompanyLightweightApiModelType> type  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("activated"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    activated = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("domainId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    domainId = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("email"))
                {
                    email = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expirationDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expirationDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    id = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("isDefault"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isDefault = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("nif"))
                {
                    nif = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("organizationName"))
                {
                    organizationName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("requiresConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    requiresConfiguration = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new CompanyLightweightApiModelType(property.Value.GetString());
                    continue;
                }
            }
            return(new CompanyLightweightApiModel(Optional.ToNullable(activated), displayName.Value, Optional.ToNullable(domainId), email.Value, Optional.ToNullable(expirationDate), Optional.ToNullable(id), Optional.ToNullable(isDefault), nif.Value, organizationName.Value, Optional.ToNullable(requiresConfiguration), Optional.ToNullable(type)));
        }