<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'environmentType' => 'SiteEnvironmentType',
        'contractUuid' => 'string',
        'projectUuid' => 'string',
        'uuid' => 'string',
        'useProxy' => 'bool',
        'secret' => 'string',
        'authenticationType' => 'AuthenticationType',
        'authenticationUsername' => 'string',
        'token' => 'string',
        'restUrls' => 'SiteRestUrls',
        'name' => 'string',
        'baseUrl' => 'string',
        'appType' => 'SiteApplicationType',
        'appVersion' => 'string',
        'appModuleVersion' => '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 = [
        'environmentType' => null,
        'contractUuid' => null,
        'projectUuid' => null,
        'uuid' => null,
        'useProxy' => null,
        'secret' => null,
        'authenticationType' => null,
        'authenticationUsername' => null,
        'token' => null,
        'restUrls' => null,
        'name' => null,
        'baseUrl' => null,
        'appType' => null,
        'appVersion' => null,
        'appModuleVersion' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'environmentType' => false,
        'contractUuid' => false,
        'projectUuid' => false,
        'uuid' => true,
        'useProxy' => true,
        'secret' => false,
        'authenticationType' => true,
        'authenticationUsername' => true,
        'token' => false,
        'restUrls' => true,
        'name' => false,
        'baseUrl' => false,
        'appType' => false,
        'appVersion' => false,
        'appModuleVersion' => 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 = [
        'environmentType' => 'environmentType',
        'contractUuid' => 'contractUuid',
        'projectUuid' => 'projectUuid',
        'uuid' => 'uuid',
        'useProxy' => 'useProxy',
        'secret' => 'secret',
        'authenticationType' => 'authenticationType',
        'authenticationUsername' => 'authenticationUsername',
        'token' => 'token',
        'restUrls' => 'restUrls',
        'name' => 'name',
        'baseUrl' => 'baseUrl',
        'appType' => 'appType',
        'appVersion' => 'appVersion',
        'appModuleVersion' => 'appModuleVersion',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'environmentType' => 'setEnvironmentType',
        'contractUuid' => 'setContractUuid',
        'projectUuid' => 'setProjectUuid',
        'uuid' => 'setUuid',
        'useProxy' => 'setUseProxy',
        'secret' => 'setSecret',
        'authenticationType' => 'setAuthenticationType',
        'authenticationUsername' => 'setAuthenticationUsername',
        'token' => 'setToken',
        'restUrls' => 'setRestUrls',
        'name' => 'setName',
        'baseUrl' => 'setBaseUrl',
        'appType' => 'setAppType',
        'appVersion' => 'setAppVersion',
        'appModuleVersion' => 'setAppModuleVersion',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'environmentType' => 'getEnvironmentType',
        'contractUuid' => 'getContractUuid',
        'projectUuid' => 'getProjectUuid',
        'uuid' => 'getUuid',
        'useProxy' => 'getUseProxy',
        'secret' => 'getSecret',
        'authenticationType' => 'getAuthenticationType',
        'authenticationUsername' => 'getAuthenticationUsername',
        'token' => 'getToken',
        'restUrls' => 'getRestUrls',
        'name' => 'getName',
        'baseUrl' => 'getBaseUrl',
        'appType' => 'getAppType',
        'appVersion' => 'getAppVersion',
        'appModuleVersion' => 'getAppModuleVersion',
    ];

    /**
     * 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('environmentType', $data ?? [], null);
        $this->setIfExists('contractUuid', $data ?? [], null);
        $this->setIfExists('projectUuid', $data ?? [], null);
        $this->setIfExists('uuid', $data ?? [], null);
        $this->setIfExists('useProxy', $data ?? [], null);
        $this->setIfExists('secret', $data ?? [], null);
        $this->setIfExists('authenticationType', $data ?? [], null);
        $this->setIfExists('authenticationUsername', $data ?? [], null);
        $this->setIfExists('token', $data ?? [], null);
        $this->setIfExists('restUrls', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('baseUrl', $data ?? [], null);
        $this->setIfExists('appType', $data ?? [], null);
        $this->setIfExists('appVersion', $data ?? [], null);
        $this->setIfExists('appModuleVersion', $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['environmentType']) {
            $invalidProperties[] = "'environmentType' can't be null";
        }
        if (null === $this->container['contractUuid']) {
            $invalidProperties[] = "'contractUuid' can't be null";
        }
        if (null === $this->container['projectUuid']) {
            $invalidProperties[] = "'projectUuid' can't be null";
        }
        if (null === $this->container['secret']) {
            $invalidProperties[] = "'secret' can't be null";
        }
        if (null === $this->container['token']) {
            $invalidProperties[] = "'token' can't be null";
        }
        if (null === $this->container['name']) {
            $invalidProperties[] = "'name' can't be null";
        }
        if (null === $this->container['baseUrl']) {
            $invalidProperties[] = "'baseUrl' can't be null";
        }
        if (null === $this->container['appType']) {
            $invalidProperties[] = "'appType' can't be null";
        }
        if (null === $this->container['appVersion']) {
            $invalidProperties[] = "'appVersion' can't be null";
        }
        if (null === $this->container['appModuleVersion']) {
            $invalidProperties[] = "'appModuleVersion' 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 environmentType.
     *
     * @return SiteEnvironmentType
     */
    public function getEnvironmentType()
    {
        return $this->container['environmentType'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets useProxy.
     *
     * @return null|bool
     */
    public function getUseProxy()
    {
        return $this->container['useProxy'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets authenticationType.
     *
     * @return null|AuthenticationType
     */
    public function getAuthenticationType()
    {
        return $this->container['authenticationType'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets restUrls.
     *
     * @return null|SiteRestUrls
     */
    public function getRestUrls()
    {
        return $this->container['restUrls'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets appType.
     *
     * @return SiteApplicationType
     */
    public function getAppType()
    {
        return $this->container['appType'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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