<?php
/**
 * TimeReportingTRCustomer
 *
 * 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;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'account_manager' => 'string',
        'active' => 'bool',
        'default_project_id' => 'string',
        'deleted' => 'bool',
        'id' => 'string',
        'invoice_city' => 'string',
        'invoice_zip_code' => 'string',
        'is_business' => 'int',
        'name' => 'string',
        'number' => 'string',
        'price_list' => 'string',
        'property_designation' => '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 = [
        'account_manager' => null,
        'active' => null,
        'default_project_id' => null,
        'deleted' => null,
        'id' => null,
        'invoice_city' => null,
        'invoice_zip_code' => null,
        'is_business' => 'int32',
        'name' => null,
        'number' => null,
        'price_list' => null,
        'property_designation' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'account_manager' => false,
        'active' => false,
        'default_project_id' => false,
        'deleted' => false,
        'id' => false,
        'invoice_city' => false,
        'invoice_zip_code' => false,
        'is_business' => false,
        'name' => false,
        'number' => false,
        'price_list' => false,
        'property_designation' => 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 = [
        'account_manager' => 'accountManager',
        'active' => 'active',
        'default_project_id' => 'defaultProjectId',
        'deleted' => 'deleted',
        'id' => 'id',
        'invoice_city' => 'invoiceCity',
        'invoice_zip_code' => 'invoiceZipCode',
        'is_business' => 'isBusiness',
        'name' => 'name',
        'number' => 'number',
        'price_list' => 'priceList',
        'property_designation' => 'propertyDesignation'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'account_manager' => 'setAccountManager',
        'active' => 'setActive',
        'default_project_id' => 'setDefaultProjectId',
        'deleted' => 'setDeleted',
        'id' => 'setId',
        'invoice_city' => 'setInvoiceCity',
        'invoice_zip_code' => 'setInvoiceZipCode',
        'is_business' => 'setIsBusiness',
        'name' => 'setName',
        'number' => 'setNumber',
        'price_list' => 'setPriceList',
        'property_designation' => 'setPropertyDesignation'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'account_manager' => 'getAccountManager',
        'active' => 'getActive',
        'default_project_id' => 'getDefaultProjectId',
        'deleted' => 'getDeleted',
        'id' => 'getId',
        'invoice_city' => 'getInvoiceCity',
        'invoice_zip_code' => 'getInvoiceZipCode',
        'is_business' => 'getIsBusiness',
        'name' => 'getName',
        'number' => 'getNumber',
        'price_list' => 'getPriceList',
        'property_designation' => 'getPropertyDesignation'
    ];

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


    /**
     * 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('account_manager', $data ?? [], null);
        $this->setIfExists('active', $data ?? [], null);
        $this->setIfExists('default_project_id', $data ?? [], null);
        $this->setIfExists('deleted', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('invoice_city', $data ?? [], null);
        $this->setIfExists('invoice_zip_code', $data ?? [], null);
        $this->setIfExists('is_business', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('number', $data ?? [], null);
        $this->setIfExists('price_list', $data ?? [], null);
        $this->setIfExists('property_designation', $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 (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 40)) {
            $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 40.";
        }

        if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 255)) {
            $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 255.";
        }

        if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) > 1024)) {
            $invalidProperties[] = "invalid value for 'number', the character length must be smaller than or equal to 1024.";
        }

        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 account_manager
     *
     * @return string|null
     */
    public function getAccountManager()
    {
        return $this->container['account_manager'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        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');
        }
        if ((mb_strlen($id) > 40)) {
            throw new \InvalidArgumentException('invalid length for $id when calling TimeReportingTRCustomer., must be smaller than or equal to 40.');
        }

        $this->container['id'] = $id;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets name
     *
     * @param string|null $name name
     *
     * @return self
     */
    public function setName($name)
    {
        if (is_null($name)) {
            throw new \InvalidArgumentException('non-nullable name cannot be null');
        }
        if ((mb_strlen($name) > 255)) {
            throw new \InvalidArgumentException('invalid length for $name when calling TimeReportingTRCustomer., must be smaller than or equal to 255.');
        }

        $this->container['name'] = $name;

        return $this;
    }

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

    /**
     * Sets number
     *
     * @param string|null $number number
     *
     * @return self
     */
    public function setNumber($number)
    {
        if (is_null($number)) {
            throw new \InvalidArgumentException('non-nullable number cannot be null');
        }
        if ((mb_strlen($number) > 1024)) {
            throw new \InvalidArgumentException('invalid length for $number when calling TimeReportingTRCustomer., must be smaller than or equal to 1024.');
        }

        $this->container['number'] = $number;

        return $this;
    }

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

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

        return $this;
    }

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

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

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


