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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'counted_by' => 'string',
        'current_row_no' => 'int',
        'has_post_release_stock_changes' => 'bool',
        'id' => 'string',
        'item_id' => 'string',
        'stock_location_id' => 'string',
        'stock_point_id' => 'string',
        'stock_taken_quantity' => 'float',
        'stock_taking_id' => 'int',
        'stock_taking_row_id' => 'string',
        'total_quantity_in_stock' => 'float'
    ];

    /**
      * 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 = [
        'counted_by' => null,
        'current_row_no' => 'int32',
        'has_post_release_stock_changes' => null,
        'id' => null,
        'item_id' => null,
        'stock_location_id' => 'uuid',
        'stock_point_id' => 'uuid',
        'stock_taken_quantity' => null,
        'stock_taking_id' => 'int64',
        'stock_taking_row_id' => null,
        'total_quantity_in_stock' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'counted_by' => false,
        'current_row_no' => false,
        'has_post_release_stock_changes' => false,
        'id' => false,
        'item_id' => false,
        'stock_location_id' => false,
        'stock_point_id' => false,
        'stock_taken_quantity' => false,
        'stock_taking_id' => false,
        'stock_taking_row_id' => false,
        'total_quantity_in_stock' => 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 = [
        'counted_by' => 'countedBy',
        'current_row_no' => 'currentRowNo',
        'has_post_release_stock_changes' => 'hasPostReleaseStockChanges',
        'id' => 'id',
        'item_id' => 'itemId',
        'stock_location_id' => 'stockLocationId',
        'stock_point_id' => 'stockPointId',
        'stock_taken_quantity' => 'stockTakenQuantity',
        'stock_taking_id' => 'stockTakingId',
        'stock_taking_row_id' => 'stockTakingRowId',
        'total_quantity_in_stock' => 'totalQuantityInStock'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'counted_by' => 'setCountedBy',
        'current_row_no' => 'setCurrentRowNo',
        'has_post_release_stock_changes' => 'setHasPostReleaseStockChanges',
        'id' => 'setId',
        'item_id' => 'setItemId',
        'stock_location_id' => 'setStockLocationId',
        'stock_point_id' => 'setStockPointId',
        'stock_taken_quantity' => 'setStockTakenQuantity',
        'stock_taking_id' => 'setStockTakingId',
        'stock_taking_row_id' => 'setStockTakingRowId',
        'total_quantity_in_stock' => 'setTotalQuantityInStock'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'counted_by' => 'getCountedBy',
        'current_row_no' => 'getCurrentRowNo',
        'has_post_release_stock_changes' => 'getHasPostReleaseStockChanges',
        'id' => 'getId',
        'item_id' => 'getItemId',
        'stock_location_id' => 'getStockLocationId',
        'stock_point_id' => 'getStockPointId',
        'stock_taken_quantity' => 'getStockTakenQuantity',
        'stock_taking_id' => 'getStockTakingId',
        'stock_taking_row_id' => 'getStockTakingRowId',
        'total_quantity_in_stock' => 'getTotalQuantityInStock'
    ];

    /**
     * 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('counted_by', $data ?? [], null);
        $this->setIfExists('current_row_no', $data ?? [], null);
        $this->setIfExists('has_post_release_stock_changes', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('item_id', $data ?? [], null);
        $this->setIfExists('stock_location_id', $data ?? [], null);
        $this->setIfExists('stock_point_id', $data ?? [], null);
        $this->setIfExists('stock_taken_quantity', $data ?? [], null);
        $this->setIfExists('stock_taking_id', $data ?? [], null);
        $this->setIfExists('stock_taking_row_id', $data ?? [], null);
        $this->setIfExists('total_quantity_in_stock', $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['counted_by']) && (mb_strlen($this->container['counted_by']) > 100)) {
            $invalidProperties[] = "invalid value for 'counted_by', the character length must be smaller than or equal to 100.";
        }

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

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

    /**
     * Sets item_id
     *
     * @param string|null $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 WarehouseStockTakingRow., must be smaller than or equal to 50.');
        }

        $this->container['item_id'] = $item_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;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


