<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'name' => 'string',
        'modelKey' => 'string',
        'useCases' => '\EdgeBox\SyncCore\V2\Raw\Model\AiModelUseCase[]',
        'optimizationTypes' => '\EdgeBox\SyncCore\V2\Raw\Model\AiModelOptimizationType[]',
        'capabilities' => '\EdgeBox\SyncCore\V2\Raw\Model\AiModelCapability[]',
        'inputModalities' => '\EdgeBox\SyncCore\V2\Raw\Model\AiModelModality[]',
        'outputModalities' => '\EdgeBox\SyncCore\V2\Raw\Model\AiModelModality[]',
        'maxInputTokens' => 'float',
        'maxOutputTokens' => 'float',
        'contextWindowTokens' => 'float',
        'costPerInputToken' => 'float',
        'costPerOutputToken' => 'float',
        'costPerRequest' => 'float',
        'versionLabel' => '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 = [
        'name' => null,
        'modelKey' => null,
        'useCases' => null,
        'optimizationTypes' => null,
        'capabilities' => null,
        'inputModalities' => null,
        'outputModalities' => null,
        'maxInputTokens' => null,
        'maxOutputTokens' => null,
        'contextWindowTokens' => null,
        'costPerInputToken' => null,
        'costPerOutputToken' => null,
        'costPerRequest' => null,
        'versionLabel' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'name' => false,
        'modelKey' => false,
        'useCases' => false,
        'optimizationTypes' => false,
        'capabilities' => false,
        'inputModalities' => false,
        'outputModalities' => false,
        'maxInputTokens' => true,
        'maxOutputTokens' => true,
        'contextWindowTokens' => true,
        'costPerInputToken' => true,
        'costPerOutputToken' => true,
        'costPerRequest' => true,
        'versionLabel' => 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 = [
        'name' => 'name',
        'modelKey' => 'modelKey',
        'useCases' => 'useCases',
        'optimizationTypes' => 'optimizationTypes',
        'capabilities' => 'capabilities',
        'inputModalities' => 'inputModalities',
        'outputModalities' => 'outputModalities',
        'maxInputTokens' => 'maxInputTokens',
        'maxOutputTokens' => 'maxOutputTokens',
        'contextWindowTokens' => 'contextWindowTokens',
        'costPerInputToken' => 'costPerInputToken',
        'costPerOutputToken' => 'costPerOutputToken',
        'costPerRequest' => 'costPerRequest',
        'versionLabel' => 'versionLabel',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'name' => 'setName',
        'modelKey' => 'setModelKey',
        'useCases' => 'setUseCases',
        'optimizationTypes' => 'setOptimizationTypes',
        'capabilities' => 'setCapabilities',
        'inputModalities' => 'setInputModalities',
        'outputModalities' => 'setOutputModalities',
        'maxInputTokens' => 'setMaxInputTokens',
        'maxOutputTokens' => 'setMaxOutputTokens',
        'contextWindowTokens' => 'setContextWindowTokens',
        'costPerInputToken' => 'setCostPerInputToken',
        'costPerOutputToken' => 'setCostPerOutputToken',
        'costPerRequest' => 'setCostPerRequest',
        'versionLabel' => 'setVersionLabel',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'name' => 'getName',
        'modelKey' => 'getModelKey',
        'useCases' => 'getUseCases',
        'optimizationTypes' => 'getOptimizationTypes',
        'capabilities' => 'getCapabilities',
        'inputModalities' => 'getInputModalities',
        'outputModalities' => 'getOutputModalities',
        'maxInputTokens' => 'getMaxInputTokens',
        'maxOutputTokens' => 'getMaxOutputTokens',
        'contextWindowTokens' => 'getContextWindowTokens',
        'costPerInputToken' => 'getCostPerInputToken',
        'costPerOutputToken' => 'getCostPerOutputToken',
        'costPerRequest' => 'getCostPerRequest',
        'versionLabel' => 'getVersionLabel',
    ];

    /**
     * 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('name', $data ?? [], null);
        $this->setIfExists('modelKey', $data ?? [], null);
        $this->setIfExists('useCases', $data ?? [], null);
        $this->setIfExists('optimizationTypes', $data ?? [], null);
        $this->setIfExists('capabilities', $data ?? [], null);
        $this->setIfExists('inputModalities', $data ?? [], null);
        $this->setIfExists('outputModalities', $data ?? [], null);
        $this->setIfExists('maxInputTokens', $data ?? [], null);
        $this->setIfExists('maxOutputTokens', $data ?? [], null);
        $this->setIfExists('contextWindowTokens', $data ?? [], null);
        $this->setIfExists('costPerInputToken', $data ?? [], null);
        $this->setIfExists('costPerOutputToken', $data ?? [], null);
        $this->setIfExists('costPerRequest', $data ?? [], null);
        $this->setIfExists('versionLabel', $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['name']) {
            $invalidProperties[] = "'name' can't be null";
        }
        if (null === $this->container['modelKey']) {
            $invalidProperties[] = "'modelKey' can't be null";
        }
        if (null === $this->container['useCases']) {
            $invalidProperties[] = "'useCases' can't be null";
        }
        if (null === $this->container['optimizationTypes']) {
            $invalidProperties[] = "'optimizationTypes' can't be null";
        }
        if (null === $this->container['capabilities']) {
            $invalidProperties[] = "'capabilities' can't be null";
        }
        if (null === $this->container['inputModalities']) {
            $invalidProperties[] = "'inputModalities' can't be null";
        }
        if (null === $this->container['outputModalities']) {
            $invalidProperties[] = "'outputModalities' 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 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 modelKey.
     *
     * @return string
     */
    public function getModelKey()
    {
        return $this->container['modelKey'];
    }

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

        return $this;
    }

    /**
     * Gets useCases.
     *
     * @return AiModelUseCase[]
     */
    public function getUseCases()
    {
        return $this->container['useCases'];
    }

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

        return $this;
    }

    /**
     * Gets optimizationTypes.
     *
     * @return AiModelOptimizationType[]
     */
    public function getOptimizationTypes()
    {
        return $this->container['optimizationTypes'];
    }

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

        return $this;
    }

    /**
     * Gets capabilities.
     *
     * @return AiModelCapability[]
     */
    public function getCapabilities()
    {
        return $this->container['capabilities'];
    }

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

        return $this;
    }

    /**
     * Gets inputModalities.
     *
     * @return AiModelModality[]
     */
    public function getInputModalities()
    {
        return $this->container['inputModalities'];
    }

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

        return $this;
    }

    /**
     * Gets outputModalities.
     *
     * @return AiModelModality[]
     */
    public function getOutputModalities()
    {
        return $this->container['outputModalities'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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