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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'accounts' => 'int',
        'contact_delivery_address' => 'string',
        'contact_mailing_address' => 'string',
        'contact_name' => 'string',
        'contact_phone' => 'string',
        'cost_centers' => 'int',
        'date_of_generation' => 'string',
        'extent' => 'string',
        'incoming_balances' => 'int',
        'projects' => 'int',
        'term_budgets' => 'int',
        'type_of_sie' => 'string',
        'used_accounts' => 'int',
        'used_cost_centers' => 'int',
        'used_projects' => 'int',
        'verifications' => 'int',
        'verifications_intervals' => '\Fortnox\Model\FortnoxBfSieVerificationSeriesSingleItem[]'
    ];

    /**
      * 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 = [
        'accounts' => 'int32',
        'contact_delivery_address' => null,
        'contact_mailing_address' => null,
        'contact_name' => null,
        'contact_phone' => null,
        'cost_centers' => 'int32',
        'date_of_generation' => null,
        'extent' => null,
        'incoming_balances' => 'int32',
        'projects' => 'int32',
        'term_budgets' => 'int32',
        'type_of_sie' => null,
        'used_accounts' => 'int32',
        'used_cost_centers' => 'int32',
        'used_projects' => 'int32',
        'verifications' => 'int32',
        'verifications_intervals' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'accounts' => false,
        'contact_delivery_address' => false,
        'contact_mailing_address' => false,
        'contact_name' => false,
        'contact_phone' => false,
        'cost_centers' => false,
        'date_of_generation' => false,
        'extent' => false,
        'incoming_balances' => false,
        'projects' => false,
        'term_budgets' => false,
        'type_of_sie' => false,
        'used_accounts' => false,
        'used_cost_centers' => false,
        'used_projects' => false,
        'verifications' => false,
        'verifications_intervals' => 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 = [
        'accounts' => 'Accounts',
        'contact_delivery_address' => 'ContactDeliveryAddress',
        'contact_mailing_address' => 'ContactMailingAddress',
        'contact_name' => 'ContactName',
        'contact_phone' => 'ContactPhone',
        'cost_centers' => 'CostCenters',
        'date_of_generation' => 'DateOfGeneration',
        'extent' => 'Extent',
        'incoming_balances' => 'IncomingBalances',
        'projects' => 'Projects',
        'term_budgets' => 'TermBudgets',
        'type_of_sie' => 'TypeOfSie',
        'used_accounts' => 'UsedAccounts',
        'used_cost_centers' => 'UsedCostCenters',
        'used_projects' => 'UsedProjects',
        'verifications' => 'Verifications',
        'verifications_intervals' => 'VerificationsIntervals'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'accounts' => 'setAccounts',
        'contact_delivery_address' => 'setContactDeliveryAddress',
        'contact_mailing_address' => 'setContactMailingAddress',
        'contact_name' => 'setContactName',
        'contact_phone' => 'setContactPhone',
        'cost_centers' => 'setCostCenters',
        'date_of_generation' => 'setDateOfGeneration',
        'extent' => 'setExtent',
        'incoming_balances' => 'setIncomingBalances',
        'projects' => 'setProjects',
        'term_budgets' => 'setTermBudgets',
        'type_of_sie' => 'setTypeOfSie',
        'used_accounts' => 'setUsedAccounts',
        'used_cost_centers' => 'setUsedCostCenters',
        'used_projects' => 'setUsedProjects',
        'verifications' => 'setVerifications',
        'verifications_intervals' => 'setVerificationsIntervals'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'accounts' => 'getAccounts',
        'contact_delivery_address' => 'getContactDeliveryAddress',
        'contact_mailing_address' => 'getContactMailingAddress',
        'contact_name' => 'getContactName',
        'contact_phone' => 'getContactPhone',
        'cost_centers' => 'getCostCenters',
        'date_of_generation' => 'getDateOfGeneration',
        'extent' => 'getExtent',
        'incoming_balances' => 'getIncomingBalances',
        'projects' => 'getProjects',
        'term_budgets' => 'getTermBudgets',
        'type_of_sie' => 'getTypeOfSie',
        'used_accounts' => 'getUsedAccounts',
        'used_cost_centers' => 'getUsedCostCenters',
        'used_projects' => 'getUsedProjects',
        'verifications' => 'getVerifications',
        'verifications_intervals' => 'getVerificationsIntervals'
    ];

    /**
     * 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('accounts', $data ?? [], null);
        $this->setIfExists('contact_delivery_address', $data ?? [], null);
        $this->setIfExists('contact_mailing_address', $data ?? [], null);
        $this->setIfExists('contact_name', $data ?? [], null);
        $this->setIfExists('contact_phone', $data ?? [], null);
        $this->setIfExists('cost_centers', $data ?? [], null);
        $this->setIfExists('date_of_generation', $data ?? [], null);
        $this->setIfExists('extent', $data ?? [], null);
        $this->setIfExists('incoming_balances', $data ?? [], null);
        $this->setIfExists('projects', $data ?? [], null);
        $this->setIfExists('term_budgets', $data ?? [], null);
        $this->setIfExists('type_of_sie', $data ?? [], null);
        $this->setIfExists('used_accounts', $data ?? [], null);
        $this->setIfExists('used_cost_centers', $data ?? [], null);
        $this->setIfExists('used_projects', $data ?? [], null);
        $this->setIfExists('verifications', $data ?? [], null);
        $this->setIfExists('verifications_intervals', $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 accounts
     *
     * @return int|null
     */
    public function getAccounts()
    {
        return $this->container['accounts'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets verifications_intervals
     *
     * @return \Fortnox\Model\FortnoxBfSieVerificationSeriesSingleItem[]|null
     */
    public function getVerificationsIntervals()
    {
        return $this->container['verifications_intervals'];
    }

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

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


