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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'active' => 'bool',
        'code' => 'string',
        'delivery_address' => 'string',
        'delivery_address2' => 'string',
        'delivery_city' => 'string',
        'delivery_country_code' => 'string',
        'delivery_name' => 'string',
        'delivery_phone' => 'string',
        'delivery_zip_code' => 'string',
        'id' => 'string',
        'name' => 'string',
        'stock_locations' => '\Fortnox\Model\WarehouseStockLocation[]',
        'using_company_address' => 'bool'
    ];

    /**
      * 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 = [
        'active' => null,
        'code' => null,
        'delivery_address' => null,
        'delivery_address2' => null,
        'delivery_city' => null,
        'delivery_country_code' => null,
        'delivery_name' => null,
        'delivery_phone' => null,
        'delivery_zip_code' => null,
        'id' => 'uuid',
        'name' => null,
        'stock_locations' => null,
        'using_company_address' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'active' => false,
        'code' => false,
        'delivery_address' => false,
        'delivery_address2' => false,
        'delivery_city' => false,
        'delivery_country_code' => false,
        'delivery_name' => false,
        'delivery_phone' => false,
        'delivery_zip_code' => false,
        'id' => false,
        'name' => false,
        'stock_locations' => false,
        'using_company_address' => 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 = [
        'active' => 'active',
        'code' => 'code',
        'delivery_address' => 'deliveryAddress',
        'delivery_address2' => 'deliveryAddress2',
        'delivery_city' => 'deliveryCity',
        'delivery_country_code' => 'deliveryCountryCode',
        'delivery_name' => 'deliveryName',
        'delivery_phone' => 'deliveryPhone',
        'delivery_zip_code' => 'deliveryZipCode',
        'id' => 'id',
        'name' => 'name',
        'stock_locations' => 'stockLocations',
        'using_company_address' => 'usingCompanyAddress'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'active' => 'setActive',
        'code' => 'setCode',
        'delivery_address' => 'setDeliveryAddress',
        'delivery_address2' => 'setDeliveryAddress2',
        'delivery_city' => 'setDeliveryCity',
        'delivery_country_code' => 'setDeliveryCountryCode',
        'delivery_name' => 'setDeliveryName',
        'delivery_phone' => 'setDeliveryPhone',
        'delivery_zip_code' => 'setDeliveryZipCode',
        'id' => 'setId',
        'name' => 'setName',
        'stock_locations' => 'setStockLocations',
        'using_company_address' => 'setUsingCompanyAddress'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'active' => 'getActive',
        'code' => 'getCode',
        'delivery_address' => 'getDeliveryAddress',
        'delivery_address2' => 'getDeliveryAddress2',
        'delivery_city' => 'getDeliveryCity',
        'delivery_country_code' => 'getDeliveryCountryCode',
        'delivery_name' => 'getDeliveryName',
        'delivery_phone' => 'getDeliveryPhone',
        'delivery_zip_code' => 'getDeliveryZipCode',
        'id' => 'getId',
        'name' => 'getName',
        'stock_locations' => 'getStockLocations',
        'using_company_address' => 'getUsingCompanyAddress'
    ];

    /**
     * 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('active', $data ?? [], null);
        $this->setIfExists('code', $data ?? [], null);
        $this->setIfExists('delivery_address', $data ?? [], null);
        $this->setIfExists('delivery_address2', $data ?? [], null);
        $this->setIfExists('delivery_city', $data ?? [], null);
        $this->setIfExists('delivery_country_code', $data ?? [], null);
        $this->setIfExists('delivery_name', $data ?? [], null);
        $this->setIfExists('delivery_phone', $data ?? [], null);
        $this->setIfExists('delivery_zip_code', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('stock_locations', $data ?? [], null);
        $this->setIfExists('using_company_address', $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['code'] === null) {
            $invalidProperties[] = "'code' can't be null";
        }
        if ((mb_strlen($this->container['code']) > 10)) {
            $invalidProperties[] = "invalid value for 'code', the character length must be smaller than or equal to 10.";
        }

        if ((mb_strlen($this->container['code']) < 1)) {
            $invalidProperties[] = "invalid value for 'code', the character length must be bigger than or equal to 1.";
        }

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

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

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

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

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

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

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

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

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

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

    /**
     * Sets code
     *
     * @param string $code code
     *
     * @return self
     */
    public function setCode($code)
    {
        if (is_null($code)) {
            throw new \InvalidArgumentException('non-nullable code cannot be null');
        }
        if ((mb_strlen($code) > 10)) {
            throw new \InvalidArgumentException('invalid length for $code when calling WarehouseStockPoint., must be smaller than or equal to 10.');
        }
        if ((mb_strlen($code) < 1)) {
            throw new \InvalidArgumentException('invalid length for $code when calling WarehouseStockPoint., must be bigger than or equal to 1.');
        }

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

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

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

        return $this;
    }

    /**
     * Gets stock_locations
     *
     * @return \Fortnox\Model\WarehouseStockLocation[]|null
     */
    public function getStockLocations()
    {
        return $this->container['stock_locations'];
    }

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

        return $this;
    }

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

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

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


