<?php
/**
 * BureauTask
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  Fortnox
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Fortnox API
 *
 * # Documentation   The Fortnox API is organized around REST. This means that we’ve designed it to have resource-oriented URLs and be as predictable as possible for you as developer.  It also means that we use HTTP status codes when something goes wrong and HTTP verbs understod by many API clients around the web.  We use a modified version of OAuth2 for authentication to offer a secure way for both you and our users to interact.  The API is generally built to support both XML and JSON but in this documentation all the examples will be in JSON.  We encourage you to read all the articles in the [Guides & Good to Know section](https://www.fortnox.se/developer/guides-and-good-to-know/)</a> first, before going forward and learning about the different resources.  This to ensure you get an understanding of some of the shared components of the API such as parameters and error handling.  ## Rate limits  The limit per access-token is 25 requests per 5 seconds. This equals to 300 requests per minute.  [Read more about this here.](https://www.fortnox.se/developer/guides-and-good-to-know/rate-limits-for-fortnox-api/)  ## Query parameters  Use query parameters with the ?-character and separate parameters with the &-character.   **Example:**  GET - https://api.fortnox.se/3/invoices?accountnumberfrom=3000&accountnumberto=4000 Read more about our parameters [here](https://www.fortnox.se/developer/guides-and-good-to-know/parameters/)   Search the documentation using the search field in the top left corner.
 *
 * The version of the OpenAPI document: 
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.19.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 Fortnox\Model;

use \ArrayAccess;
use \Fortnox\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'assignees' => 'int[]',
        'bureau_id' => 'int',
        'client_id' => 'string',
        'date' => '\DateTime',
        'has_comments' => 'bool',
        'id' => 'string',
        'recurrence' => 'string[]',
        'status' => 'string',
        'status_date' => '\DateTime',
        'task_specification_has_end_date' => 'bool',
        'task_specification_id' => 'string',
        'task_type' => 'string',
        'title' => '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 = [
        'assignees' => 'int64',
        'bureau_id' => 'int64',
        'client_id' => 'uuid',
        'date' => 'date',
        'has_comments' => null,
        'id' => 'uuid',
        'recurrence' => null,
        'status' => null,
        'status_date' => 'date',
        'task_specification_has_end_date' => null,
        'task_specification_id' => 'uuid',
        'task_type' => null,
        'title' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'assignees' => false,
        'bureau_id' => false,
        'client_id' => false,
        'date' => false,
        'has_comments' => false,
        'id' => false,
        'recurrence' => false,
        'status' => false,
        'status_date' => false,
        'task_specification_has_end_date' => false,
        'task_specification_id' => false,
        'task_type' => false,
        'title' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected array $openAPINullablesSetToNull = [];

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

    /**
     * Array of nullable properties
     *
     * @return array
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null
     *
     * @return boolean[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param boolean[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Checks if a property is nullable
     *
     * @param string $property
     * @return bool
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    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
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'assignees' => 'assignees',
        'bureau_id' => 'bureauId',
        'client_id' => 'clientId',
        'date' => 'date',
        'has_comments' => 'hasComments',
        'id' => 'id',
        'recurrence' => 'recurrence',
        'status' => 'status',
        'status_date' => 'statusDate',
        'task_specification_has_end_date' => 'taskSpecificationHasEndDate',
        'task_specification_id' => 'taskSpecificationId',
        'task_type' => 'taskType',
        'title' => 'title'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'assignees' => 'setAssignees',
        'bureau_id' => 'setBureauId',
        'client_id' => 'setClientId',
        'date' => 'setDate',
        'has_comments' => 'setHasComments',
        'id' => 'setId',
        'recurrence' => 'setRecurrence',
        'status' => 'setStatus',
        'status_date' => 'setStatusDate',
        'task_specification_has_end_date' => 'setTaskSpecificationHasEndDate',
        'task_specification_id' => 'setTaskSpecificationId',
        'task_type' => 'setTaskType',
        'title' => 'setTitle'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'assignees' => 'getAssignees',
        'bureau_id' => 'getBureauId',
        'client_id' => 'getClientId',
        'date' => 'getDate',
        'has_comments' => 'getHasComments',
        'id' => 'getId',
        'recurrence' => 'getRecurrence',
        'status' => 'getStatus',
        'status_date' => 'getStatusDate',
        'task_specification_has_end_date' => 'getTaskSpecificationHasEndDate',
        'task_specification_id' => 'getTaskSpecificationId',
        'task_type' => 'getTaskType',
        'title' => 'getTitle'
    ];

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

    public const STATUS_NOT_DONE = 'NOT_DONE';
    public const STATUS_DONE = 'DONE';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getStatusAllowableValues()
    {
        return [
            self::STATUS_NOT_DONE,
            self::STATUS_DONE,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[]|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('assignees', $data ?? [], null);
        $this->setIfExists('bureau_id', $data ?? [], null);
        $this->setIfExists('client_id', $data ?? [], null);
        $this->setIfExists('date', $data ?? [], null);
        $this->setIfExists('has_comments', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('recurrence', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('status_date', $data ?? [], null);
        $this->setIfExists('task_specification_has_end_date', $data ?? [], null);
        $this->setIfExists('task_specification_id', $data ?? [], null);
        $this->setIfExists('task_type', $data ?? [], null);
        $this->setIfExists('title', $data ?? [], null);
    }

    /**
    * 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 string $variableName
    * @param array  $fields
    * @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;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['status'] === null) {
            $invalidProperties[] = "'status' can't be null";
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'status', must be one of '%s'",
                $this->container['status'],
                implode("', '", $allowedValues)
            );
        }

        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 count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets assignees
     *
     * @return int[]|null
     */
    public function getAssignees()
    {
        return $this->container['assignees'];
    }

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

        return $this;
    }

    /**
     * Gets bureau_id
     *
     * @return int|null
     */
    public function getBureauId()
    {
        return $this->container['bureau_id'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets date
     *
     * @return \DateTime|null
     */
    public function getDate()
    {
        return $this->container['date'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets status
     *
     * @param string $status status
     *
     * @return self
     */
    public function setStatus($status)
    {
        if (is_null($status)) {
            throw new \InvalidArgumentException('non-nullable status cannot be null');
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!in_array($status, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'status', must be one of '%s'",
                    $status,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['status'] = $status;

        return $this;
    }

    /**
     * Gets status_date
     *
     * @return \DateTime|null
     */
    public function getStatusDate()
    {
        return $this->container['status_date'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer|string $offset Offset
     *
     * @return boolean
     */
    public function offsetExists(mixed $offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet(mixed $offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return void
     */
    public function offsetUnset(mixed $offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link 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 the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


