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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'agreement_type' => 'string',
        'approver_tenant_id' => 'int',
        'consultant_user_id' => 'int',
        'scheduled_for' => '\DateTime'
    ];

    /**
      * 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 = [
        'agreement_type' => null,
        'approver_tenant_id' => 'int64',
        'consultant_user_id' => 'int64',
        'scheduled_for' => 'date'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'agreement_type' => false,
        'approver_tenant_id' => false,
        'consultant_user_id' => false,
        'scheduled_for' => 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 = [
        'agreement_type' => 'agreementType',
        'approver_tenant_id' => 'approverTenantId',
        'consultant_user_id' => 'consultantUserId',
        'scheduled_for' => 'scheduledFor'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'agreement_type' => 'setAgreementType',
        'approver_tenant_id' => 'setApproverTenantId',
        'consultant_user_id' => 'setConsultantUserId',
        'scheduled_for' => 'setScheduledFor'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'agreement_type' => 'getAgreementType',
        'approver_tenant_id' => 'getApproverTenantId',
        'consultant_user_id' => 'getConsultantUserId',
        'scheduled_for' => 'getScheduledFor'
    ];

    /**
     * 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;
    }

    public const AGREEMENT_TYPE_BUREAU_INITIATED_CONNECTION = 'BUREAU_INITIATED_CONNECTION';
    public const AGREEMENT_TYPE_BUREAU_INITIATED_DISCONNECTION = 'BUREAU_INITIATED_DISCONNECTION';
    public const AGREEMENT_TYPE_BUREAU_INITIATED_DISCONTINUE = 'BUREAU_INITIATED_DISCONTINUE';
    public const AGREEMENT_TYPE_INTERNAL_INITIATED_DISCONNECTION = 'INTERNAL_INITIATED_DISCONNECTION';
    public const AGREEMENT_TYPE_INTERNAL_INITIATED_CONNECTION = 'INTERNAL_INITIATED_CONNECTION';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getAgreementTypeAllowableValues()
    {
        return [
            self::AGREEMENT_TYPE_BUREAU_INITIATED_CONNECTION,
            self::AGREEMENT_TYPE_BUREAU_INITIATED_DISCONNECTION,
            self::AGREEMENT_TYPE_BUREAU_INITIATED_DISCONTINUE,
            self::AGREEMENT_TYPE_INTERNAL_INITIATED_DISCONNECTION,
            self::AGREEMENT_TYPE_INTERNAL_INITIATED_CONNECTION,
        ];
    }

    /**
     * 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('agreement_type', $data ?? [], null);
        $this->setIfExists('approver_tenant_id', $data ?? [], null);
        $this->setIfExists('consultant_user_id', $data ?? [], null);
        $this->setIfExists('scheduled_for', $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['agreement_type'] === null) {
            $invalidProperties[] = "'agreement_type' can't be null";
        }
        $allowedValues = $this->getAgreementTypeAllowableValues();
        if (!is_null($this->container['agreement_type']) && !in_array($this->container['agreement_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'agreement_type', must be one of '%s'",
                $this->container['agreement_type'],
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['approver_tenant_id'] === null) {
            $invalidProperties[] = "'approver_tenant_id' 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 agreement_type
     *
     * @return string
     */
    public function getAgreementType()
    {
        return $this->container['agreement_type'];
    }

    /**
     * Sets agreement_type
     *
     * @param string $agreement_type agreement_type
     *
     * @return self
     */
    public function setAgreementType($agreement_type)
    {
        if (is_null($agreement_type)) {
            throw new \InvalidArgumentException('non-nullable agreement_type cannot be null');
        }
        $allowedValues = $this->getAgreementTypeAllowableValues();
        if (!in_array($agreement_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'agreement_type', must be one of '%s'",
                    $agreement_type,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['agreement_type'] = $agreement_type;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


