<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'retrieveEntity' => 'string',
        'renderEntity' => 'string',
        'listEntities' => 'string',
        'createEntity' => 'string',
        'deleteEntity' => 'string',
        'siteStatus' => 'string',
        'siteConfig' => 'string',
    ];

    /**
     * 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 = [
        'retrieveEntity' => null,
        'renderEntity' => null,
        'listEntities' => null,
        'createEntity' => null,
        'deleteEntity' => null,
        'siteStatus' => null,
        'siteConfig' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'retrieveEntity' => false,
        'renderEntity' => true,
        'listEntities' => false,
        'createEntity' => false,
        'deleteEntity' => false,
        'siteStatus' => true,
        'siteConfig' => 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 = [
        'retrieveEntity' => 'retrieveEntity',
        'renderEntity' => 'renderEntity',
        'listEntities' => 'listEntities',
        'createEntity' => 'createEntity',
        'deleteEntity' => 'deleteEntity',
        'siteStatus' => 'siteStatus',
        'siteConfig' => 'siteConfig',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'retrieveEntity' => 'setRetrieveEntity',
        'renderEntity' => 'setRenderEntity',
        'listEntities' => 'setListEntities',
        'createEntity' => 'setCreateEntity',
        'deleteEntity' => 'setDeleteEntity',
        'siteStatus' => 'setSiteStatus',
        'siteConfig' => 'setSiteConfig',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'retrieveEntity' => 'getRetrieveEntity',
        'renderEntity' => 'getRenderEntity',
        'listEntities' => 'getListEntities',
        'createEntity' => 'getCreateEntity',
        'deleteEntity' => 'getDeleteEntity',
        'siteStatus' => 'getSiteStatus',
        'siteConfig' => 'getSiteConfig',
    ];

    /**
     * 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('retrieveEntity', $data ?? [], null);
        $this->setIfExists('renderEntity', $data ?? [], null);
        $this->setIfExists('listEntities', $data ?? [], null);
        $this->setIfExists('createEntity', $data ?? [], null);
        $this->setIfExists('deleteEntity', $data ?? [], null);
        $this->setIfExists('siteStatus', $data ?? [], null);
        $this->setIfExists('siteConfig', $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['retrieveEntity']) {
            $invalidProperties[] = "'retrieveEntity' can't be null";
        }
        if (null === $this->container['listEntities']) {
            $invalidProperties[] = "'listEntities' can't be null";
        }
        if (null === $this->container['createEntity']) {
            $invalidProperties[] = "'createEntity' can't be null";
        }
        if (null === $this->container['deleteEntity']) {
            $invalidProperties[] = "'deleteEntity' 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 retrieveEntity.
     *
     * @return string
     */
    public function getRetrieveEntity()
    {
        return $this->container['retrieveEntity'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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