<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'inputTokens' => 'float',
        'cachedInputTokens' => 'float',
        'inputVariableTokens' => 'float',
        'reasoningTokens' => 'float',
        'outputTokens' => 'float',
        'tokens' => 'float',
        'inputCosts' => 'float',
        'inputVariableCosts' => 'float',
        'outputCosts' => 'float',
        'reasoningCosts' => 'float',
        'costs' => '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 = [
        'inputTokens' => null,
        'cachedInputTokens' => null,
        'inputVariableTokens' => null,
        'reasoningTokens' => null,
        'outputTokens' => null,
        'tokens' => null,
        'inputCosts' => null,
        'inputVariableCosts' => null,
        'outputCosts' => null,
        'reasoningCosts' => null,
        'costs' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'inputTokens' => true,
        'cachedInputTokens' => true,
        'inputVariableTokens' => true,
        'reasoningTokens' => true,
        'outputTokens' => true,
        'tokens' => true,
        'inputCosts' => true,
        'inputVariableCosts' => true,
        'outputCosts' => true,
        'reasoningCosts' => true,
        'costs' => 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 = [
        'inputTokens' => 'inputTokens',
        'cachedInputTokens' => 'cachedInputTokens',
        'inputVariableTokens' => 'inputVariableTokens',
        'reasoningTokens' => 'reasoningTokens',
        'outputTokens' => 'outputTokens',
        'tokens' => 'tokens',
        'inputCosts' => 'inputCosts',
        'inputVariableCosts' => 'inputVariableCosts',
        'outputCosts' => 'outputCosts',
        'reasoningCosts' => 'reasoningCosts',
        'costs' => 'costs',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'inputTokens' => 'setInputTokens',
        'cachedInputTokens' => 'setCachedInputTokens',
        'inputVariableTokens' => 'setInputVariableTokens',
        'reasoningTokens' => 'setReasoningTokens',
        'outputTokens' => 'setOutputTokens',
        'tokens' => 'setTokens',
        'inputCosts' => 'setInputCosts',
        'inputVariableCosts' => 'setInputVariableCosts',
        'outputCosts' => 'setOutputCosts',
        'reasoningCosts' => 'setReasoningCosts',
        'costs' => 'setCosts',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'inputTokens' => 'getInputTokens',
        'cachedInputTokens' => 'getCachedInputTokens',
        'inputVariableTokens' => 'getInputVariableTokens',
        'reasoningTokens' => 'getReasoningTokens',
        'outputTokens' => 'getOutputTokens',
        'tokens' => 'getTokens',
        'inputCosts' => 'getInputCosts',
        'inputVariableCosts' => 'getInputVariableCosts',
        'outputCosts' => 'getOutputCosts',
        'reasoningCosts' => 'getReasoningCosts',
        'costs' => 'getCosts',
    ];

    /**
     * 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('inputTokens', $data ?? [], null);
        $this->setIfExists('cachedInputTokens', $data ?? [], null);
        $this->setIfExists('inputVariableTokens', $data ?? [], null);
        $this->setIfExists('reasoningTokens', $data ?? [], null);
        $this->setIfExists('outputTokens', $data ?? [], null);
        $this->setIfExists('tokens', $data ?? [], null);
        $this->setIfExists('inputCosts', $data ?? [], null);
        $this->setIfExists('inputVariableCosts', $data ?? [], null);
        $this->setIfExists('outputCosts', $data ?? [], null);
        $this->setIfExists('reasoningCosts', $data ?? [], null);
        $this->setIfExists('costs', $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 inputTokens.
     *
     * @return null|float
     */
    public function getInputTokens()
    {
        return $this->container['inputTokens'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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