<?php

/**
 * OnboardingMainPageDataExtractionDto.
 *
 * PHP version 7.4
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Sync Core.
 *
 * The Sync Core that sends and receives content from all connected sites and services for Content Sync.
 *
 * The version of the OpenAPI document: 1.0
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.4.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace EdgeBox\SyncCore\V2\Raw\Model;

use EdgeBox\SyncCore\V2\Raw\ObjectSerializer;

/**
 * OnboardingMainPageDataExtractionDto Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @implements \ArrayAccess<string, mixed>
 */
class OnboardingMainPageDataExtractionDto implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
     * The original name of the model.
     *
     * @var string
     */
    protected static $openAPIModelName = 'OnboardingMainPageDataExtractionDto';

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'compatibilityDate' => 'string',
        'taskId' => 'string',
        'extractedAt' => 'float',
        'baseUrlResolution' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingMainPageDataExtractionDtoBaseUrlResolution',
        'favicons' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingFaviconVariantDto[]',
        'industryInference' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingMainPageDataExtractionDtoIndustryInference',
        'organizationTypeSegmentation' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingMainPageDataExtractionDtoOrganizationTypeSegmentation',
        'websiteSubjectExtraction' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingMainPageDataExtractionDtoWebsiteSubjectExtraction',
        'taxonomyFacetRelevance' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingMainPageDataExtractionDtoTaxonomyFacetRelevance',
        'selectedUrlSuggestions' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingSelectedUrlSuggestionDto[]',
        'links' => '\EdgeBox\SyncCore\V2\Raw\Model\OnboardingExtractedLinkDto[]',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     *
     * @phpstan-var array<string, string|null>
     *
     * @psalm-var array<string, string|null>
     */
    protected static $openAPIFormats = [
        'compatibilityDate' => null,
        'taskId' => null,
        'extractedAt' => null,
        'baseUrlResolution' => null,
        'favicons' => null,
        'industryInference' => null,
        'organizationTypeSegmentation' => null,
        'websiteSubjectExtraction' => null,
        'taxonomyFacetRelevance' => null,
        'selectedUrlSuggestions' => null,
        'links' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'compatibilityDate' => false,
        'taskId' => false,
        'extractedAt' => false,
        'baseUrlResolution' => false,
        'favicons' => false,
        'industryInference' => false,
        'organizationTypeSegmentation' => false,
        'websiteSubjectExtraction' => false,
        'taxonomyFacetRelevance' => false,
        'selectedUrlSuggestions' => true,
        'links' => false,
    ];

    /**
     * If a nullable field gets set to null, insert it here.
     *
     * @var bool[]
     */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'compatibilityDate' => 'compatibilityDate',
        'taskId' => 'taskId',
        'extractedAt' => 'extractedAt',
        'baseUrlResolution' => 'baseUrlResolution',
        'favicons' => 'favicons',
        'industryInference' => 'industryInference',
        'organizationTypeSegmentation' => 'organizationTypeSegmentation',
        'websiteSubjectExtraction' => 'websiteSubjectExtraction',
        'taxonomyFacetRelevance' => 'taxonomyFacetRelevance',
        'selectedUrlSuggestions' => 'selectedUrlSuggestions',
        'links' => 'links',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'compatibilityDate' => 'setCompatibilityDate',
        'taskId' => 'setTaskId',
        'extractedAt' => 'setExtractedAt',
        'baseUrlResolution' => 'setBaseUrlResolution',
        'favicons' => 'setFavicons',
        'industryInference' => 'setIndustryInference',
        'organizationTypeSegmentation' => 'setOrganizationTypeSegmentation',
        'websiteSubjectExtraction' => 'setWebsiteSubjectExtraction',
        'taxonomyFacetRelevance' => 'setTaxonomyFacetRelevance',
        'selectedUrlSuggestions' => 'setSelectedUrlSuggestions',
        'links' => 'setLinks',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'compatibilityDate' => 'getCompatibilityDate',
        'taskId' => 'getTaskId',
        'extractedAt' => 'getExtractedAt',
        'baseUrlResolution' => 'getBaseUrlResolution',
        'favicons' => 'getFavicons',
        'industryInference' => 'getIndustryInference',
        'organizationTypeSegmentation' => 'getOrganizationTypeSegmentation',
        'websiteSubjectExtraction' => 'getWebsiteSubjectExtraction',
        'taxonomyFacetRelevance' => 'getTaxonomyFacetRelevance',
        'selectedUrlSuggestions' => 'getSelectedUrlSuggestions',
        'links' => 'getLinks',
    ];

    /**
     * Associative array for storing property values.
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor.
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('compatibilityDate', $data ?? [], null);
        $this->setIfExists('taskId', $data ?? [], null);
        $this->setIfExists('extractedAt', $data ?? [], null);
        $this->setIfExists('baseUrlResolution', $data ?? [], null);
        $this->setIfExists('favicons', $data ?? [], null);
        $this->setIfExists('industryInference', $data ?? [], null);
        $this->setIfExists('organizationTypeSegmentation', $data ?? [], null);
        $this->setIfExists('websiteSubjectExtraction', $data ?? [], null);
        $this->setIfExists('taxonomyFacetRelevance', $data ?? [], null);
        $this->setIfExists('selectedUrlSuggestions', $data ?? [], null);
        $this->setIfExists('links', $data ?? [], null);
    }

    /**
     * Gets the string presentation of the object.
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Checks if a property is nullable.
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if (null === $this->container['compatibilityDate']) {
            $invalidProperties[] = "'compatibilityDate' can't be null";
        }
        if (null === $this->container['taskId']) {
            $invalidProperties[] = "'taskId' can't be null";
        }
        if (null === $this->container['extractedAt']) {
            $invalidProperties[] = "'extractedAt' can't be null";
        }
        if (null === $this->container['baseUrlResolution']) {
            $invalidProperties[] = "'baseUrlResolution' can't be null";
        }
        if (null === $this->container['favicons']) {
            $invalidProperties[] = "'favicons' can't be null";
        }
        if (null === $this->container['industryInference']) {
            $invalidProperties[] = "'industryInference' can't be null";
        }
        if (null === $this->container['organizationTypeSegmentation']) {
            $invalidProperties[] = "'organizationTypeSegmentation' can't be null";
        }
        if (null === $this->container['websiteSubjectExtraction']) {
            $invalidProperties[] = "'websiteSubjectExtraction' can't be null";
        }
        if (null === $this->container['taxonomyFacetRelevance']) {
            $invalidProperties[] = "'taxonomyFacetRelevance' can't be null";
        }
        if (null === $this->container['links']) {
            $invalidProperties[] = "'links' can't be null";
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed.
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return 0 === count($this->listInvalidProperties());
    }

    /**
     * Gets compatibilityDate.
     *
     * @return string
     */
    public function getCompatibilityDate()
    {
        return $this->container['compatibilityDate'];
    }

    /**
     * Sets compatibilityDate.
     *
     * @param string $compatibilityDate compatibilityDate
     *
     * @return self
     */
    public function setCompatibilityDate($compatibilityDate)
    {
        if (is_null($compatibilityDate)) {
            throw new \InvalidArgumentException('non-nullable compatibilityDate cannot be null');
        }
        $this->container['compatibilityDate'] = $compatibilityDate;

        return $this;
    }

    /**
     * Gets taskId.
     *
     * @return string
     */
    public function getTaskId()
    {
        return $this->container['taskId'];
    }

    /**
     * Sets taskId.
     *
     * @param string $taskId taskId
     *
     * @return self
     */
    public function setTaskId($taskId)
    {
        if (is_null($taskId)) {
            throw new \InvalidArgumentException('non-nullable taskId cannot be null');
        }
        $this->container['taskId'] = $taskId;

        return $this;
    }

    /**
     * Gets extractedAt.
     *
     * @return float
     */
    public function getExtractedAt()
    {
        return $this->container['extractedAt'];
    }

    /**
     * Sets extractedAt.
     *
     * @param float $extractedAt extractedAt
     *
     * @return self
     */
    public function setExtractedAt($extractedAt)
    {
        if (is_null($extractedAt)) {
            throw new \InvalidArgumentException('non-nullable extractedAt cannot be null');
        }
        $this->container['extractedAt'] = $extractedAt;

        return $this;
    }

    /**
     * Gets baseUrlResolution.
     *
     * @return OnboardingMainPageDataExtractionDtoBaseUrlResolution
     */
    public function getBaseUrlResolution()
    {
        return $this->container['baseUrlResolution'];
    }

    /**
     * Sets baseUrlResolution.
     *
     * @param OnboardingMainPageDataExtractionDtoBaseUrlResolution $baseUrlResolution baseUrlResolution
     *
     * @return self
     */
    public function setBaseUrlResolution($baseUrlResolution)
    {
        if (is_null($baseUrlResolution)) {
            throw new \InvalidArgumentException('non-nullable baseUrlResolution cannot be null');
        }
        $this->container['baseUrlResolution'] = $baseUrlResolution;

        return $this;
    }

    /**
     * Gets favicons.
     *
     * @return OnboardingFaviconVariantDto[]
     */
    public function getFavicons()
    {
        return $this->container['favicons'];
    }

    /**
     * Sets favicons.
     *
     * @param OnboardingFaviconVariantDto[] $favicons favicons
     *
     * @return self
     */
    public function setFavicons($favicons)
    {
        if (is_null($favicons)) {
            throw new \InvalidArgumentException('non-nullable favicons cannot be null');
        }
        $this->container['favicons'] = $favicons;

        return $this;
    }

    /**
     * Gets industryInference.
     *
     * @return OnboardingMainPageDataExtractionDtoIndustryInference
     */
    public function getIndustryInference()
    {
        return $this->container['industryInference'];
    }

    /**
     * Sets industryInference.
     *
     * @param OnboardingMainPageDataExtractionDtoIndustryInference $industryInference industryInference
     *
     * @return self
     */
    public function setIndustryInference($industryInference)
    {
        if (is_null($industryInference)) {
            throw new \InvalidArgumentException('non-nullable industryInference cannot be null');
        }
        $this->container['industryInference'] = $industryInference;

        return $this;
    }

    /**
     * Gets organizationTypeSegmentation.
     *
     * @return OnboardingMainPageDataExtractionDtoOrganizationTypeSegmentation
     */
    public function getOrganizationTypeSegmentation()
    {
        return $this->container['organizationTypeSegmentation'];
    }

    /**
     * Sets organizationTypeSegmentation.
     *
     * @param OnboardingMainPageDataExtractionDtoOrganizationTypeSegmentation $organizationTypeSegmentation organizationTypeSegmentation
     *
     * @return self
     */
    public function setOrganizationTypeSegmentation($organizationTypeSegmentation)
    {
        if (is_null($organizationTypeSegmentation)) {
            throw new \InvalidArgumentException('non-nullable organizationTypeSegmentation cannot be null');
        }
        $this->container['organizationTypeSegmentation'] = $organizationTypeSegmentation;

        return $this;
    }

    /**
     * Gets websiteSubjectExtraction.
     *
     * @return OnboardingMainPageDataExtractionDtoWebsiteSubjectExtraction
     */
    public function getWebsiteSubjectExtraction()
    {
        return $this->container['websiteSubjectExtraction'];
    }

    /**
     * Sets websiteSubjectExtraction.
     *
     * @param OnboardingMainPageDataExtractionDtoWebsiteSubjectExtraction $websiteSubjectExtraction websiteSubjectExtraction
     *
     * @return self
     */
    public function setWebsiteSubjectExtraction($websiteSubjectExtraction)
    {
        if (is_null($websiteSubjectExtraction)) {
            throw new \InvalidArgumentException('non-nullable websiteSubjectExtraction cannot be null');
        }
        $this->container['websiteSubjectExtraction'] = $websiteSubjectExtraction;

        return $this;
    }

    /**
     * Gets taxonomyFacetRelevance.
     *
     * @return OnboardingMainPageDataExtractionDtoTaxonomyFacetRelevance
     */
    public function getTaxonomyFacetRelevance()
    {
        return $this->container['taxonomyFacetRelevance'];
    }

    /**
     * Sets taxonomyFacetRelevance.
     *
     * @param OnboardingMainPageDataExtractionDtoTaxonomyFacetRelevance $taxonomyFacetRelevance taxonomyFacetRelevance
     *
     * @return self
     */
    public function setTaxonomyFacetRelevance($taxonomyFacetRelevance)
    {
        if (is_null($taxonomyFacetRelevance)) {
            throw new \InvalidArgumentException('non-nullable taxonomyFacetRelevance cannot be null');
        }
        $this->container['taxonomyFacetRelevance'] = $taxonomyFacetRelevance;

        return $this;
    }

    /**
     * Gets selectedUrlSuggestions.
     *
     * @return null|OnboardingSelectedUrlSuggestionDto[]
     */
    public function getSelectedUrlSuggestions()
    {
        return $this->container['selectedUrlSuggestions'];
    }

    /**
     * Sets selectedUrlSuggestions.
     *
     * @param null|OnboardingSelectedUrlSuggestionDto[] $selectedUrlSuggestions selectedUrlSuggestions
     *
     * @return self
     */
    public function setSelectedUrlSuggestions($selectedUrlSuggestions)
    {
        if (is_null($selectedUrlSuggestions)) {
            array_push($this->openAPINullablesSetToNull, 'selectedUrlSuggestions');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('selectedUrlSuggestions', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['selectedUrlSuggestions'] = $selectedUrlSuggestions;

        return $this;
    }

    /**
     * Gets links.
     *
     * @return OnboardingExtractedLinkDto[]
     */
    public function getLinks()
    {
        return $this->container['links'];
    }

    /**
     * Sets links.
     *
     * @param OnboardingExtractedLinkDto[] $links links
     *
     * @return self
     */
    public function setLinks($links)
    {
        if (is_null($links)) {
            throw new \InvalidArgumentException('non-nullable links cannot be null');
        }
        $this->container['links'] = $links;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return null|mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param null|int $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     *
     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed returns data which can be serialized by json_encode(), which is a value
     * of any type other than a resource
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets a header-safe presentation of the object.
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }

    /**
     * Array of nullable properties.
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null.
     *
     * @return bool[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null.
     *
     * @param bool[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
     * $this->openAPINullablesSetToNull array.
     *
     * @param mixed  $defaultValue
     */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }
}
