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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'at_url' => 'string',
        'balance_include_fees' => 'float',
        'balance_include_fees_currency' => 'float',
        'current_capital_balance' => 'float',
        'current_capital_balance_currency' => 'float',
        'invoice_document_url' => 'string',
        'invoice_number' => 'int',
        'next_event' => 'string',
        'next_event_date' => '\DateTime',
        'ocr_number' => 'string',
        'service' => 'string',
        'service_name' => 'string',
        'status' => '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 = [
        'at_url' => null,
        'balance_include_fees' => 'float',
        'balance_include_fees_currency' => 'float',
        'current_capital_balance' => 'float',
        'current_capital_balance_currency' => 'float',
        'invoice_document_url' => null,
        'invoice_number' => 'int32',
        'next_event' => null,
        'next_event_date' => 'date',
        'ocr_number' => null,
        'service' => null,
        'service_name' => null,
        'status' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'at_url' => false,
        'balance_include_fees' => false,
        'balance_include_fees_currency' => false,
        'current_capital_balance' => false,
        'current_capital_balance_currency' => false,
        'invoice_document_url' => false,
        'invoice_number' => false,
        'next_event' => false,
        'next_event_date' => false,
        'ocr_number' => false,
        'service' => false,
        'service_name' => false,
        'status' => 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 = [
        'at_url' => '@url',
        'balance_include_fees' => 'BalanceIncludeFees',
        'balance_include_fees_currency' => 'BalanceIncludeFeesCurrency',
        'current_capital_balance' => 'CurrentCapitalBalance',
        'current_capital_balance_currency' => 'CurrentCapitalBalanceCurrency',
        'invoice_document_url' => 'InvoiceDocumentURL',
        'invoice_number' => 'InvoiceNumber',
        'next_event' => 'NextEvent',
        'next_event_date' => 'NextEventDate',
        'ocr_number' => 'OCRNumber',
        'service' => 'Service',
        'service_name' => 'ServiceName',
        'status' => 'Status'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'at_url' => 'setAtUrl',
        'balance_include_fees' => 'setBalanceIncludeFees',
        'balance_include_fees_currency' => 'setBalanceIncludeFeesCurrency',
        'current_capital_balance' => 'setCurrentCapitalBalance',
        'current_capital_balance_currency' => 'setCurrentCapitalBalanceCurrency',
        'invoice_document_url' => 'setInvoiceDocumentUrl',
        'invoice_number' => 'setInvoiceNumber',
        'next_event' => 'setNextEvent',
        'next_event_date' => 'setNextEventDate',
        'ocr_number' => 'setOcrNumber',
        'service' => 'setService',
        'service_name' => 'setServiceName',
        'status' => 'setStatus'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'at_url' => 'getAtUrl',
        'balance_include_fees' => 'getBalanceIncludeFees',
        'balance_include_fees_currency' => 'getBalanceIncludeFeesCurrency',
        'current_capital_balance' => 'getCurrentCapitalBalance',
        'current_capital_balance_currency' => 'getCurrentCapitalBalanceCurrency',
        'invoice_document_url' => 'getInvoiceDocumentUrl',
        'invoice_number' => 'getInvoiceNumber',
        'next_event' => 'getNextEvent',
        'next_event_date' => 'getNextEventDate',
        'ocr_number' => 'getOcrNumber',
        'service' => 'getService',
        'service_name' => 'getServiceName',
        'status' => 'getStatus'
    ];

    /**
     * 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('at_url', $data ?? [], null);
        $this->setIfExists('balance_include_fees', $data ?? [], null);
        $this->setIfExists('balance_include_fees_currency', $data ?? [], null);
        $this->setIfExists('current_capital_balance', $data ?? [], null);
        $this->setIfExists('current_capital_balance_currency', $data ?? [], null);
        $this->setIfExists('invoice_document_url', $data ?? [], null);
        $this->setIfExists('invoice_number', $data ?? [], null);
        $this->setIfExists('next_event', $data ?? [], null);
        $this->setIfExists('next_event_date', $data ?? [], null);
        $this->setIfExists('ocr_number', $data ?? [], null);
        $this->setIfExists('service', $data ?? [], null);
        $this->setIfExists('service_name', $data ?? [], null);
        $this->setIfExists('status', $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['at_url'] === null) {
            $invalidProperties[] = "'at_url' can't be null";
        }
        if ($this->container['balance_include_fees'] === null) {
            $invalidProperties[] = "'balance_include_fees' can't be null";
        }
        if ($this->container['balance_include_fees_currency'] === null) {
            $invalidProperties[] = "'balance_include_fees_currency' can't be null";
        }
        if ($this->container['current_capital_balance'] === null) {
            $invalidProperties[] = "'current_capital_balance' can't be null";
        }
        if ($this->container['current_capital_balance_currency'] === null) {
            $invalidProperties[] = "'current_capital_balance_currency' can't be null";
        }
        if ($this->container['invoice_number'] === null) {
            $invalidProperties[] = "'invoice_number' can't be null";
        }
        if ($this->container['next_event'] === null) {
            $invalidProperties[] = "'next_event' can't be null";
        }
        if ($this->container['next_event_date'] === null) {
            $invalidProperties[] = "'next_event_date' can't be null";
        }
        if ($this->container['ocr_number'] === null) {
            $invalidProperties[] = "'ocr_number' can't be null";
        }
        if ($this->container['service'] === null) {
            $invalidProperties[] = "'service' can't be null";
        }
        if ($this->container['service_name'] === null) {
            $invalidProperties[] = "'service_name' can't be null";
        }
        if ($this->container['status'] === null) {
            $invalidProperties[] = "'status' can't be null";
        }
        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 at_url
     *
     * @return string
     */
    public function getAtUrl()
    {
        return $this->container['at_url'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets invoice_number
     *
     * @return int
     */
    public function getInvoiceNumber()
    {
        return $this->container['invoice_number'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets next_event_date
     *
     * @return \DateTime
     */
    public function getNextEventDate()
    {
        return $this->container['next_event_date'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


