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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'cost_center_code' => 'string',
        'delivered_quantity' => 'float',
        'forced_quantity' => 'float',
        'item_description' => 'string',
        'item_id' => 'string',
        'item_unit' => 'string',
        'project_id' => 'string',
        'quantity' => 'float',
        'reserved_quantity' => 'float',
        'row_id' => 'int',
        'stock_location_id' => 'string',
        'stock_point_id' => '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 = [
        'cost_center_code' => null,
        'delivered_quantity' => null,
        'forced_quantity' => null,
        'item_description' => null,
        'item_id' => null,
        'item_unit' => null,
        'project_id' => null,
        'quantity' => null,
        'reserved_quantity' => null,
        'row_id' => 'int64',
        'stock_location_id' => 'uuid',
        'stock_point_id' => 'uuid'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'cost_center_code' => false,
        'delivered_quantity' => false,
        'forced_quantity' => false,
        'item_description' => false,
        'item_id' => false,
        'item_unit' => false,
        'project_id' => false,
        'quantity' => false,
        'reserved_quantity' => false,
        'row_id' => false,
        'stock_location_id' => false,
        'stock_point_id' => 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 = [
        'cost_center_code' => 'costCenterCode',
        'delivered_quantity' => 'deliveredQuantity',
        'forced_quantity' => 'forcedQuantity',
        'item_description' => 'itemDescription',
        'item_id' => 'itemId',
        'item_unit' => 'itemUnit',
        'project_id' => 'projectId',
        'quantity' => 'quantity',
        'reserved_quantity' => 'reservedQuantity',
        'row_id' => 'rowId',
        'stock_location_id' => 'stockLocationId',
        'stock_point_id' => 'stockPointId'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'cost_center_code' => 'setCostCenterCode',
        'delivered_quantity' => 'setDeliveredQuantity',
        'forced_quantity' => 'setForcedQuantity',
        'item_description' => 'setItemDescription',
        'item_id' => 'setItemId',
        'item_unit' => 'setItemUnit',
        'project_id' => 'setProjectId',
        'quantity' => 'setQuantity',
        'reserved_quantity' => 'setReservedQuantity',
        'row_id' => 'setRowId',
        'stock_location_id' => 'setStockLocationId',
        'stock_point_id' => 'setStockPointId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'cost_center_code' => 'getCostCenterCode',
        'delivered_quantity' => 'getDeliveredQuantity',
        'forced_quantity' => 'getForcedQuantity',
        'item_description' => 'getItemDescription',
        'item_id' => 'getItemId',
        'item_unit' => 'getItemUnit',
        'project_id' => 'getProjectId',
        'quantity' => 'getQuantity',
        'reserved_quantity' => 'getReservedQuantity',
        'row_id' => 'getRowId',
        'stock_location_id' => 'getStockLocationId',
        'stock_point_id' => 'getStockPointId'
    ];

    /**
     * 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('cost_center_code', $data ?? [], null);
        $this->setIfExists('delivered_quantity', $data ?? [], null);
        $this->setIfExists('forced_quantity', $data ?? [], null);
        $this->setIfExists('item_description', $data ?? [], null);
        $this->setIfExists('item_id', $data ?? [], null);
        $this->setIfExists('item_unit', $data ?? [], null);
        $this->setIfExists('project_id', $data ?? [], null);
        $this->setIfExists('quantity', $data ?? [], null);
        $this->setIfExists('reserved_quantity', $data ?? [], null);
        $this->setIfExists('row_id', $data ?? [], null);
        $this->setIfExists('stock_location_id', $data ?? [], null);
        $this->setIfExists('stock_point_id', $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['cost_center_code']) && (mb_strlen($this->container['cost_center_code']) > 25)) {
            $invalidProperties[] = "invalid value for 'cost_center_code', the character length must be smaller than or equal to 25.";
        }

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

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

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

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

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

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

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

        if ($this->container['quantity'] === null) {
            $invalidProperties[] = "'quantity' can't be null";
        }
        if (!is_null($this->container['row_id']) && ($this->container['row_id'] < 1)) {
            $invalidProperties[] = "invalid value for 'row_id', 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 cost_center_code
     *
     * @return string|null
     */
    public function getCostCenterCode()
    {
        return $this->container['cost_center_code'];
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

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

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

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

        return $this;
    }

    /**
     * Gets quantity
     *
     * @return float
     */
    public function getQuantity()
    {
        return $this->container['quantity'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets row_id
     *
     * @param int|null $row_id row_id
     *
     * @return self
     */
    public function setRowId($row_id)
    {
        if (is_null($row_id)) {
            throw new \InvalidArgumentException('non-nullable row_id cannot be null');
        }

        if (($row_id < 1)) {
            throw new \InvalidArgumentException('invalid value for $row_id when calling WarehouseCustomOutboundDocumentRow., must be bigger than or equal to 1.');
        }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


