<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'accessScope' => 'AccessScope',
        'authenticationType' => 'AiProviderAuthenticationType',
        'status' => 'AiProviderStatus',
        'name' => 'string',
        'apiType' => 'AiProviderApiType',
        'baseUrl' => 'string',
        'region' => 'string',
        'apiVersion' => 'string',
        'defaultTimeoutMs' => 'float',
        'maxTimeoutMs' => 'float',
        'customer' => 'DynamicReference',
        'project' => 'DynamicReference',
    ];

    /**
     * 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 = [
        'accessScope' => null,
        'authenticationType' => null,
        'status' => null,
        'name' => null,
        'apiType' => null,
        'baseUrl' => null,
        'region' => null,
        'apiVersion' => null,
        'defaultTimeoutMs' => null,
        'maxTimeoutMs' => null,
        'customer' => null,
        'project' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'accessScope' => false,
        'authenticationType' => false,
        'status' => true,
        'name' => false,
        'apiType' => false,
        'baseUrl' => true,
        'region' => true,
        'apiVersion' => true,
        'defaultTimeoutMs' => true,
        'maxTimeoutMs' => true,
        'customer' => true,
        'project' => 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 = [
        'accessScope' => 'accessScope',
        'authenticationType' => 'authenticationType',
        'status' => 'status',
        'name' => 'name',
        'apiType' => 'apiType',
        'baseUrl' => 'baseUrl',
        'region' => 'region',
        'apiVersion' => 'apiVersion',
        'defaultTimeoutMs' => 'defaultTimeoutMs',
        'maxTimeoutMs' => 'maxTimeoutMs',
        'customer' => 'customer',
        'project' => 'project',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'accessScope' => 'setAccessScope',
        'authenticationType' => 'setAuthenticationType',
        'status' => 'setStatus',
        'name' => 'setName',
        'apiType' => 'setApiType',
        'baseUrl' => 'setBaseUrl',
        'region' => 'setRegion',
        'apiVersion' => 'setApiVersion',
        'defaultTimeoutMs' => 'setDefaultTimeoutMs',
        'maxTimeoutMs' => 'setMaxTimeoutMs',
        'customer' => 'setCustomer',
        'project' => 'setProject',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'accessScope' => 'getAccessScope',
        'authenticationType' => 'getAuthenticationType',
        'status' => 'getStatus',
        'name' => 'getName',
        'apiType' => 'getApiType',
        'baseUrl' => 'getBaseUrl',
        'region' => 'getRegion',
        'apiVersion' => 'getApiVersion',
        'defaultTimeoutMs' => 'getDefaultTimeoutMs',
        'maxTimeoutMs' => 'getMaxTimeoutMs',
        'customer' => 'getCustomer',
        'project' => 'getProject',
    ];

    /**
     * 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('accessScope', $data ?? [], null);
        $this->setIfExists('authenticationType', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('apiType', $data ?? [], null);
        $this->setIfExists('baseUrl', $data ?? [], null);
        $this->setIfExists('region', $data ?? [], null);
        $this->setIfExists('apiVersion', $data ?? [], null);
        $this->setIfExists('defaultTimeoutMs', $data ?? [], null);
        $this->setIfExists('maxTimeoutMs', $data ?? [], null);
        $this->setIfExists('customer', $data ?? [], null);
        $this->setIfExists('project', $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['accessScope']) {
            $invalidProperties[] = "'accessScope' can't be null";
        }
        if (null === $this->container['authenticationType']) {
            $invalidProperties[] = "'authenticationType' can't be null";
        }
        if (null === $this->container['name']) {
            $invalidProperties[] = "'name' can't be null";
        }
        if (null === $this->container['apiType']) {
            $invalidProperties[] = "'apiType' 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 accessScope.
     *
     * @return AccessScope
     */
    public function getAccessScope()
    {
        return $this->container['accessScope'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets status.
     *
     * @param null|AiProviderStatus $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 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 apiType.
     *
     * @return AiProviderApiType
     */
    public function getApiType()
    {
        return $this->container['apiType'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

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