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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'activated' => 'bool',
        'active' => 'bool',
        'bureau_id' => 'int',
        'company_name' => 'string',
        'company_type' => 'string',
        'db_id' => 'int',
        'has_access' => 'bool',
        'has_interpret_supplier_invoices' => 'bool',
        'id' => 'string',
        'org_no' => 'string',
        'removed_at' => '\DateTime',
        'user_disabled_at' => '\DateTime'
    ];

    /**
      * 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 = [
        'activated' => null,
        'active' => null,
        'bureau_id' => 'int64',
        'company_name' => null,
        'company_type' => null,
        'db_id' => 'int64',
        'has_access' => null,
        'has_interpret_supplier_invoices' => null,
        'id' => null,
        'org_no' => null,
        'removed_at' => 'date-time',
        'user_disabled_at' => 'date-time'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'activated' => false,
        'active' => false,
        'bureau_id' => false,
        'company_name' => false,
        'company_type' => false,
        'db_id' => false,
        'has_access' => false,
        'has_interpret_supplier_invoices' => false,
        'id' => false,
        'org_no' => false,
        'removed_at' => false,
        'user_disabled_at' => 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 = [
        'activated' => 'activated',
        'active' => 'active',
        'bureau_id' => 'bureauId',
        'company_name' => 'companyName',
        'company_type' => 'companyType',
        'db_id' => 'dbId',
        'has_access' => 'hasAccess',
        'has_interpret_supplier_invoices' => 'hasInterpretSupplierInvoices',
        'id' => 'id',
        'org_no' => 'orgNo',
        'removed_at' => 'removedAt',
        'user_disabled_at' => 'userDisabledAt'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'activated' => 'setActivated',
        'active' => 'setActive',
        'bureau_id' => 'setBureauId',
        'company_name' => 'setCompanyName',
        'company_type' => 'setCompanyType',
        'db_id' => 'setDbId',
        'has_access' => 'setHasAccess',
        'has_interpret_supplier_invoices' => 'setHasInterpretSupplierInvoices',
        'id' => 'setId',
        'org_no' => 'setOrgNo',
        'removed_at' => 'setRemovedAt',
        'user_disabled_at' => 'setUserDisabledAt'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'activated' => 'getActivated',
        'active' => 'getActive',
        'bureau_id' => 'getBureauId',
        'company_name' => 'getCompanyName',
        'company_type' => 'getCompanyType',
        'db_id' => 'getDbId',
        'has_access' => 'getHasAccess',
        'has_interpret_supplier_invoices' => 'getHasInterpretSupplierInvoices',
        'id' => 'getId',
        'org_no' => 'getOrgNo',
        'removed_at' => 'getRemovedAt',
        'user_disabled_at' => 'getUserDisabledAt'
    ];

    /**
     * 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 COMPANY_TYPE_ESTATE = 'ESTATE';
    public const COMPANY_TYPE_SOLE_TRADER = 'SOLE_TRADER';
    public const COMPANY_TYPE_NATURAL_PERSON = 'NATURAL_PERSON';
    public const COMPANY_TYPE_CORPORATION = 'CORPORATION';
    public const COMPANY_TYPE_NONPROFIT_ASSOCIATION = 'NONPROFIT_ASSOCIATION';
    public const COMPANY_TYPE_HOUSING_ASSOCIATION = 'HOUSING_ASSOCIATION';
    public const COMPANY_TYPE_TENANCY_COMPOUND = 'TENANCY_COMPOUND';
    public const COMPANY_TYPE_COOPERATIVE = 'COOPERATIVE';
    public const COMPANY_TYPE_ECONOMIC_ASSOCIATION = 'ECONOMIC_ASSOCIATION';
    public const COMPANY_TYPE_HOUSING_SOCIETY = 'HOUSING_SOCIETY';
    public const COMPANY_TYPE_RELIGIOUS_BODY = 'RELIGIOUS_BODY';
    public const COMPANY_TYPE_LIMITED_PARTNERSHIP = 'LIMITED_PARTNERSHIP';
    public const COMPANY_TYPE_PARTNERSHIP = 'PARTNERSHIP';
    public const COMPANY_TYPE_PRIVATE_INDIVIDUAL = 'PRIVATE_INDIVIDUAL';
    public const COMPANY_TYPE_UNKNOWN = 'UNKNOWN';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getCompanyTypeAllowableValues()
    {
        return [
            self::COMPANY_TYPE_ESTATE,
            self::COMPANY_TYPE_SOLE_TRADER,
            self::COMPANY_TYPE_NATURAL_PERSON,
            self::COMPANY_TYPE_CORPORATION,
            self::COMPANY_TYPE_NONPROFIT_ASSOCIATION,
            self::COMPANY_TYPE_HOUSING_ASSOCIATION,
            self::COMPANY_TYPE_TENANCY_COMPOUND,
            self::COMPANY_TYPE_COOPERATIVE,
            self::COMPANY_TYPE_ECONOMIC_ASSOCIATION,
            self::COMPANY_TYPE_HOUSING_SOCIETY,
            self::COMPANY_TYPE_RELIGIOUS_BODY,
            self::COMPANY_TYPE_LIMITED_PARTNERSHIP,
            self::COMPANY_TYPE_PARTNERSHIP,
            self::COMPANY_TYPE_PRIVATE_INDIVIDUAL,
            self::COMPANY_TYPE_UNKNOWN,
        ];
    }

    /**
     * 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('activated', $data ?? [], null);
        $this->setIfExists('active', $data ?? [], null);
        $this->setIfExists('bureau_id', $data ?? [], null);
        $this->setIfExists('company_name', $data ?? [], null);
        $this->setIfExists('company_type', $data ?? [], null);
        $this->setIfExists('db_id', $data ?? [], null);
        $this->setIfExists('has_access', $data ?? [], null);
        $this->setIfExists('has_interpret_supplier_invoices', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('org_no', $data ?? [], null);
        $this->setIfExists('removed_at', $data ?? [], null);
        $this->setIfExists('user_disabled_at', $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 = [];

        $allowedValues = $this->getCompanyTypeAllowableValues();
        if (!is_null($this->container['company_type']) && !in_array($this->container['company_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'company_type', must be one of '%s'",
                $this->container['company_type'],
                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 activated
     *
     * @return bool|null
     */
    public function getActivated()
    {
        return $this->container['activated'];
    }

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


