<?php
/**
 * StockItemBatchAudit
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Linnworks\Inventory
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Inventory API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: inventory
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.11.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 Linnworks\Inventory\Model;

use \ArrayAccess;
use \Linnworks\Inventory\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'batch_id' => 'int',
        'batch_inventory_id' => 'int',
        'quantity_delta' => 'int',
        'stock_value_delta' => 'float',
        'change_note' => 'string',
        'username' => 'string',
        'change_date' => '\DateTime',
        'bin_rack' => 'string',
        'batch_number' => 'string',
        'location' => 'string',
        'fk_job_id' => 'int',
        'order_id' => 'int'
    ];

    /**
      * 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 = [
        'batch_id' => 'int32',
        'batch_inventory_id' => 'int32',
        'quantity_delta' => 'int32',
        'stock_value_delta' => 'double',
        'change_note' => null,
        'username' => null,
        'change_date' => 'date-time',
        'bin_rack' => null,
        'batch_number' => null,
        'location' => null,
        'fk_job_id' => 'int32',
        'order_id' => 'int32'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'batch_id' => false,
        'batch_inventory_id' => false,
        'quantity_delta' => false,
        'stock_value_delta' => false,
        'change_note' => false,
        'username' => false,
        'change_date' => false,
        'bin_rack' => false,
        'batch_number' => false,
        'location' => false,
        'fk_job_id' => false,
        'order_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 = [
        'batch_id' => 'BatchId',
        'batch_inventory_id' => 'BatchInventoryId',
        'quantity_delta' => 'QuantityDelta',
        'stock_value_delta' => 'StockValueDelta',
        'change_note' => 'ChangeNote',
        'username' => 'Username',
        'change_date' => 'ChangeDate',
        'bin_rack' => 'BinRack',
        'batch_number' => 'BatchNumber',
        'location' => 'Location',
        'fk_job_id' => 'fkJobId',
        'order_id' => 'OrderId'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'batch_id' => 'setBatchId',
        'batch_inventory_id' => 'setBatchInventoryId',
        'quantity_delta' => 'setQuantityDelta',
        'stock_value_delta' => 'setStockValueDelta',
        'change_note' => 'setChangeNote',
        'username' => 'setUsername',
        'change_date' => 'setChangeDate',
        'bin_rack' => 'setBinRack',
        'batch_number' => 'setBatchNumber',
        'location' => 'setLocation',
        'fk_job_id' => 'setFkJobId',
        'order_id' => 'setOrderId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'batch_id' => 'getBatchId',
        'batch_inventory_id' => 'getBatchInventoryId',
        'quantity_delta' => 'getQuantityDelta',
        'stock_value_delta' => 'getStockValueDelta',
        'change_note' => 'getChangeNote',
        'username' => 'getUsername',
        'change_date' => 'getChangeDate',
        'bin_rack' => 'getBinRack',
        'batch_number' => 'getBatchNumber',
        'location' => 'getLocation',
        'fk_job_id' => 'getFkJobId',
        'order_id' => 'getOrderId'
    ];

    /**
     * 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('batch_id', $data ?? [], null);
        $this->setIfExists('batch_inventory_id', $data ?? [], null);
        $this->setIfExists('quantity_delta', $data ?? [], null);
        $this->setIfExists('stock_value_delta', $data ?? [], null);
        $this->setIfExists('change_note', $data ?? [], null);
        $this->setIfExists('username', $data ?? [], null);
        $this->setIfExists('change_date', $data ?? [], null);
        $this->setIfExists('bin_rack', $data ?? [], null);
        $this->setIfExists('batch_number', $data ?? [], null);
        $this->setIfExists('location', $data ?? [], null);
        $this->setIfExists('fk_job_id', $data ?? [], null);
        $this->setIfExists('order_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 = [];

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($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 $offset Offset
     *
     * @return void
     */
    public function offsetUnset($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));
    }
}


