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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'completed' => 'bool',
        'date' => '\DateTime',
        'delivery_note_id' => 'string',
        'has_delivery_note' => 'bool',
        'id' => 'int',
        'note' => 'string',
        'released' => 'bool',
        'stock_point_id' => 'string',
        'supplier_name' => 'string',
        'supplier_number' => 'string',
        'unmatched_value' => 'float',
        'voided' => '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 = [
        'completed' => null,
        'date' => 'date',
        'delivery_note_id' => null,
        'has_delivery_note' => null,
        'id' => 'int64',
        'note' => null,
        'released' => null,
        'stock_point_id' => 'uuid',
        'supplier_name' => null,
        'supplier_number' => null,
        'unmatched_value' => null,
        'voided' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'completed' => false,
        'date' => false,
        'delivery_note_id' => false,
        'has_delivery_note' => false,
        'id' => false,
        'note' => false,
        'released' => false,
        'stock_point_id' => false,
        'supplier_name' => false,
        'supplier_number' => false,
        'unmatched_value' => false,
        'voided' => 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 = [
        'completed' => 'completed',
        'date' => 'date',
        'delivery_note_id' => 'deliveryNoteId',
        'has_delivery_note' => 'hasDeliveryNote',
        'id' => 'id',
        'note' => 'note',
        'released' => 'released',
        'stock_point_id' => 'stockPointId',
        'supplier_name' => 'supplierName',
        'supplier_number' => 'supplierNumber',
        'unmatched_value' => 'unmatchedValue',
        'voided' => 'voided'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'completed' => 'setCompleted',
        'date' => 'setDate',
        'delivery_note_id' => 'setDeliveryNoteId',
        'has_delivery_note' => 'setHasDeliveryNote',
        'id' => 'setId',
        'note' => 'setNote',
        'released' => 'setReleased',
        'stock_point_id' => 'setStockPointId',
        'supplier_name' => 'setSupplierName',
        'supplier_number' => 'setSupplierNumber',
        'unmatched_value' => 'setUnmatchedValue',
        'voided' => 'setVoided'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'completed' => 'getCompleted',
        'date' => 'getDate',
        'delivery_note_id' => 'getDeliveryNoteId',
        'has_delivery_note' => 'getHasDeliveryNote',
        'id' => 'getId',
        'note' => 'getNote',
        'released' => 'getReleased',
        'stock_point_id' => 'getStockPointId',
        'supplier_name' => 'getSupplierName',
        'supplier_number' => 'getSupplierNumber',
        'unmatched_value' => 'getUnmatchedValue',
        'voided' => 'getVoided'
    ];

    /**
     * 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('completed', $data ?? [], null);
        $this->setIfExists('date', $data ?? [], null);
        $this->setIfExists('delivery_note_id', $data ?? [], null);
        $this->setIfExists('has_delivery_note', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('note', $data ?? [], null);
        $this->setIfExists('released', $data ?? [], null);
        $this->setIfExists('stock_point_id', $data ?? [], null);
        $this->setIfExists('supplier_name', $data ?? [], null);
        $this->setIfExists('supplier_number', $data ?? [], null);
        $this->setIfExists('unmatched_value', $data ?? [], null);
        $this->setIfExists('voided', $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 completed
     *
     * @return bool|null
     */
    public function getCompleted()
    {
        return $this->container['completed'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param int|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 note
     *
     * @return string|null
     */
    public function getNote()
    {
        return $this->container['note'];
    }

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


