<?php

/**
 * CreateContentOptimizationDto.
 *
 * 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;

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'inputPage' => 'DynamicRevisionReference',
        'inputEntity' => 'DynamicRevisionReference',
        'outputPage' => 'DynamicRevisionReference',
        'outputEntity' => 'DynamicRevisionReference',
        'site' => 'DynamicReference',
        'types' => '\EdgeBox\SyncCore\V2\Raw\Model\DynamicRevisionReference[]',
        'fixesIssueTypes' => '\EdgeBox\SyncCore\V2\Raw\Model\DynamicRevisionReference[]',
        'fixesIssues' => '\EdgeBox\SyncCore\V2\Raw\Model\DynamicReference[]',
        'customer' => 'DynamicReference',
        'project' => 'DynamicReference',
        'targetStage' => 'ContentOptimizationTargetStage',
        'targetWorkflowStage' => 'string',
        'status' => 'ContentOptimizationStatus',
        'appliedAt' => 'float',
    ];

    /**
     * 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 = [
        'inputPage' => null,
        'inputEntity' => null,
        'outputPage' => null,
        'outputEntity' => null,
        'site' => null,
        'types' => null,
        'fixesIssueTypes' => null,
        'fixesIssues' => null,
        'customer' => null,
        'project' => null,
        'targetStage' => null,
        'targetWorkflowStage' => null,
        'status' => null,
        'appliedAt' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'inputPage' => true,
        'inputEntity' => true,
        'outputPage' => true,
        'outputEntity' => true,
        'site' => true,
        'types' => true,
        'fixesIssueTypes' => true,
        'fixesIssues' => true,
        'customer' => true,
        'project' => true,
        'targetStage' => true,
        'targetWorkflowStage' => true,
        'status' => true,
        'appliedAt' => true,
    ];

    /**
     * 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 = [
        'inputPage' => 'inputPage',
        'inputEntity' => 'inputEntity',
        'outputPage' => 'outputPage',
        'outputEntity' => 'outputEntity',
        'site' => 'site',
        'types' => 'types',
        'fixesIssueTypes' => 'fixesIssueTypes',
        'fixesIssues' => 'fixesIssues',
        'customer' => 'customer',
        'project' => 'project',
        'targetStage' => 'targetStage',
        'targetWorkflowStage' => 'targetWorkflowStage',
        'status' => 'status',
        'appliedAt' => 'appliedAt',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'inputPage' => 'setInputPage',
        'inputEntity' => 'setInputEntity',
        'outputPage' => 'setOutputPage',
        'outputEntity' => 'setOutputEntity',
        'site' => 'setSite',
        'types' => 'setTypes',
        'fixesIssueTypes' => 'setFixesIssueTypes',
        'fixesIssues' => 'setFixesIssues',
        'customer' => 'setCustomer',
        'project' => 'setProject',
        'targetStage' => 'setTargetStage',
        'targetWorkflowStage' => 'setTargetWorkflowStage',
        'status' => 'setStatus',
        'appliedAt' => 'setAppliedAt',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'inputPage' => 'getInputPage',
        'inputEntity' => 'getInputEntity',
        'outputPage' => 'getOutputPage',
        'outputEntity' => 'getOutputEntity',
        'site' => 'getSite',
        'types' => 'getTypes',
        'fixesIssueTypes' => 'getFixesIssueTypes',
        'fixesIssues' => 'getFixesIssues',
        'customer' => 'getCustomer',
        'project' => 'getProject',
        'targetStage' => 'getTargetStage',
        'targetWorkflowStage' => 'getTargetWorkflowStage',
        'status' => 'getStatus',
        'appliedAt' => 'getAppliedAt',
    ];

    /**
     * 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('inputPage', $data ?? [], null);
        $this->setIfExists('inputEntity', $data ?? [], null);
        $this->setIfExists('outputPage', $data ?? [], null);
        $this->setIfExists('outputEntity', $data ?? [], null);
        $this->setIfExists('site', $data ?? [], null);
        $this->setIfExists('types', $data ?? [], null);
        $this->setIfExists('fixesIssueTypes', $data ?? [], null);
        $this->setIfExists('fixesIssues', $data ?? [], null);
        $this->setIfExists('customer', $data ?? [], null);
        $this->setIfExists('project', $data ?? [], null);
        $this->setIfExists('targetStage', $data ?? [], null);
        $this->setIfExists('targetWorkflowStage', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('appliedAt', $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()
    {
        return [];
    }

    /**
     * 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 inputPage.
     *
     * @return null|DynamicRevisionReference
     */
    public function getInputPage()
    {
        return $this->container['inputPage'];
    }

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

        return $this;
    }

    /**
     * Gets inputEntity.
     *
     * @return null|DynamicRevisionReference
     */
    public function getInputEntity()
    {
        return $this->container['inputEntity'];
    }

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

        return $this;
    }

    /**
     * Gets outputPage.
     *
     * @return null|DynamicRevisionReference
     */
    public function getOutputPage()
    {
        return $this->container['outputPage'];
    }

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

        return $this;
    }

    /**
     * Gets outputEntity.
     *
     * @return null|DynamicRevisionReference
     */
    public function getOutputEntity()
    {
        return $this->container['outputEntity'];
    }

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

        return $this;
    }

    /**
     * Gets site.
     *
     * @return null|DynamicReference
     */
    public function getSite()
    {
        return $this->container['site'];
    }

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

        return $this;
    }

    /**
     * Gets types.
     *
     * @return null|DynamicRevisionReference[]
     */
    public function getTypes()
    {
        return $this->container['types'];
    }

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

        return $this;
    }

    /**
     * Gets fixesIssueTypes.
     *
     * @return null|DynamicRevisionReference[]
     */
    public function getFixesIssueTypes()
    {
        return $this->container['fixesIssueTypes'];
    }

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

        return $this;
    }

    /**
     * Gets fixesIssues.
     *
     * @return null|DynamicReference[]
     */
    public function getFixesIssues()
    {
        return $this->container['fixesIssues'];
    }

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

        return $this;
    }

    /**
     * Gets customer.
     *
     * @return null|DynamicReference
     */
    public function getCustomer()
    {
        return $this->container['customer'];
    }

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

        return $this;
    }

    /**
     * Gets project.
     *
     * @return null|DynamicReference
     */
    public function getProject()
    {
        return $this->container['project'];
    }

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

        return $this;
    }

    /**
     * Gets targetStage.
     *
     * @return null|ContentOptimizationTargetStage
     */
    public function getTargetStage()
    {
        return $this->container['targetStage'];
    }

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

        return $this;
    }

    /**
     * Gets targetWorkflowStage.
     *
     * @return null|string
     */
    public function getTargetWorkflowStage()
    {
        return $this->container['targetWorkflowStage'];
    }

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

        return $this;
    }

    /**
     * Gets status.
     *
     * @return null|ContentOptimizationStatus
     */
    public function getStatus()
    {
        return $this->container['status'];
    }

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

        return $this;
    }

    /**
     * Gets appliedAt.
     *
     * @return null|float
     */
    public function getAppliedAt()
    {
        return $this->container['appliedAt'];
    }

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

        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;
    }
}
