<?php
/**
 * AuthorizationModel
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Splitit
 * @author   Konfig
 * @link     https://konfigthis.com
 */

/**
 * splitit-web-api-v3
 *
 * Splitit's Web API
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://konfigthis.com
 */


namespace Splitit\Model;

use \ArrayAccess;
use \Splitit\ObjectSerializer;

/**
 * AuthorizationModel Class Doc Comment
 *
 * @category Class
 * @package  Splitit
 * @implements \ArrayAccess<string, mixed>
 */
class AuthorizationModel implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'status' => '\Splitit\Model\GwAuthorizationStatus',
        'date' => '\DateTime',
        'splitit_error_result_code' => 'string',
        'gateway_transaction_id' => 'string',
        'gateway_result_code' => 'string',
        'gateway_result_message' => 'string',
        'three_ds_redirect' => '\Splitit\Model\ThreeDsRedirectDataV3',
        'cavv' => 'string',
        'eci' => 'string',
        'gateway_source_response' => '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 = [
        'status' => null,
        'date' => 'date-time',
        'splitit_error_result_code' => null,
        'gateway_transaction_id' => null,
        'gateway_result_code' => null,
        'gateway_result_message' => null,
        'three_ds_redirect' => null,
        'cavv' => null,
        'eci' => null,
        'gateway_source_response' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static $openAPINullables = [
        'status' => false,
		'date' => false,
		'splitit_error_result_code' => false,
		'gateway_transaction_id' => false,
		'gateway_result_code' => false,
		'gateway_result_message' => false,
		'three_ds_redirect' => false,
		'cavv' => false,
		'eci' => false,
		'gateway_source_response' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected $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 = [
        'status' => 'Status',
        'date' => 'Date',
        'splitit_error_result_code' => 'SplititErrorResultCode',
        'gateway_transaction_id' => 'GatewayTransactionID',
        'gateway_result_code' => 'GatewayResultCode',
        'gateway_result_message' => 'GatewayResultMessage',
        'three_ds_redirect' => 'ThreeDSRedirect',
        'cavv' => 'CAVV',
        'eci' => 'ECI',
        'gateway_source_response' => 'GatewaySourceResponse'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'status' => 'setStatus',
        'date' => 'setDate',
        'splitit_error_result_code' => 'setSplititErrorResultCode',
        'gateway_transaction_id' => 'setGatewayTransactionId',
        'gateway_result_code' => 'setGatewayResultCode',
        'gateway_result_message' => 'setGatewayResultMessage',
        'three_ds_redirect' => 'setThreeDsRedirect',
        'cavv' => 'setCavv',
        'eci' => 'setEci',
        'gateway_source_response' => 'setGatewaySourceResponse'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'status' => 'getStatus',
        'date' => 'getDate',
        'splitit_error_result_code' => 'getSplititErrorResultCode',
        'gateway_transaction_id' => 'getGatewayTransactionId',
        'gateway_result_code' => 'getGatewayResultCode',
        'gateway_result_message' => 'getGatewayResultMessage',
        'three_ds_redirect' => 'getThreeDsRedirect',
        'cavv' => 'getCavv',
        'eci' => 'getEci',
        'gateway_source_response' => 'getGatewaySourceResponse'
    ];

    /**
     * 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[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('date', $data ?? [], null);
        $this->setIfExists('splitit_error_result_code', $data ?? [], null);
        $this->setIfExists('gateway_transaction_id', $data ?? [], null);
        $this->setIfExists('gateway_result_code', $data ?? [], null);
        $this->setIfExists('gateway_result_message', $data ?? [], null);
        $this->setIfExists('three_ds_redirect', $data ?? [], null);
        $this->setIfExists('cavv', $data ?? [], null);
        $this->setIfExists('eci', $data ?? [], null);
        $this->setIfExists('gateway_source_response', $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['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 status
     *
     * @return \Splitit\Model\GwAuthorizationStatus
     */
    public function getStatus()
    {
        return $this->container['status'];
    }

    /**
     * Sets status
     *
     * @param \Splitit\Model\GwAuthorizationStatus $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;
    }

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

    /**
     * Sets splitit_error_result_code
     *
     * @param string|null $splitit_error_result_code splitit_error_result_code
     *
     * @return self
     */
    public function setSplititErrorResultCode($splitit_error_result_code)
    {

        if (is_null($splitit_error_result_code)) {
            throw new \InvalidArgumentException('non-nullable splitit_error_result_code cannot be null');
        }

        $this->container['splitit_error_result_code'] = $splitit_error_result_code;

        return $this;
    }

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

    /**
     * Sets gateway_transaction_id
     *
     * @param string|null $gateway_transaction_id gateway_transaction_id
     *
     * @return self
     */
    public function setGatewayTransactionId($gateway_transaction_id)
    {

        if (is_null($gateway_transaction_id)) {
            throw new \InvalidArgumentException('non-nullable gateway_transaction_id cannot be null');
        }

        $this->container['gateway_transaction_id'] = $gateway_transaction_id;

        return $this;
    }

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

    /**
     * Sets gateway_result_code
     *
     * @param string|null $gateway_result_code gateway_result_code
     *
     * @return self
     */
    public function setGatewayResultCode($gateway_result_code)
    {

        if (is_null($gateway_result_code)) {
            throw new \InvalidArgumentException('non-nullable gateway_result_code cannot be null');
        }

        $this->container['gateway_result_code'] = $gateway_result_code;

        return $this;
    }

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

    /**
     * Sets gateway_result_message
     *
     * @param string|null $gateway_result_message gateway_result_message
     *
     * @return self
     */
    public function setGatewayResultMessage($gateway_result_message)
    {

        if (is_null($gateway_result_message)) {
            throw new \InvalidArgumentException('non-nullable gateway_result_message cannot be null');
        }

        $this->container['gateway_result_message'] = $gateway_result_message;

        return $this;
    }

    /**
     * Gets three_ds_redirect
     *
     * @return \Splitit\Model\ThreeDsRedirectDataV3|null
     */
    public function getThreeDsRedirect()
    {
        return $this->container['three_ds_redirect'];
    }

    /**
     * Sets three_ds_redirect
     *
     * @param \Splitit\Model\ThreeDsRedirectDataV3|null $three_ds_redirect three_ds_redirect
     *
     * @return self
     */
    public function setThreeDsRedirect($three_ds_redirect)
    {

        if (is_null($three_ds_redirect)) {
            throw new \InvalidArgumentException('non-nullable three_ds_redirect cannot be null');
        }

        $this->container['three_ds_redirect'] = $three_ds_redirect;

        return $this;
    }

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

    /**
     * Sets cavv
     *
     * @param string|null $cavv cavv
     *
     * @return self
     */
    public function setCavv($cavv)
    {

        if (is_null($cavv)) {
            throw new \InvalidArgumentException('non-nullable cavv cannot be null');
        }

        $this->container['cavv'] = $cavv;

        return $this;
    }

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

    /**
     * Sets eci
     *
     * @param string|null $eci eci
     *
     * @return self
     */
    public function setEci($eci)
    {

        if (is_null($eci)) {
            throw new \InvalidArgumentException('non-nullable eci cannot be null');
        }

        $this->container['eci'] = $eci;

        return $this;
    }

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

    /**
     * Sets gateway_source_response
     *
     * @param string|null $gateway_source_response gateway_source_response
     *
     * @return self
     */
    public function setGatewaySourceResponse($gateway_source_response)
    {

        if (is_null($gateway_source_response)) {
            throw new \InvalidArgumentException('non-nullable gateway_source_response cannot be null');
        }

        $this->container['gateway_source_response'] = $gateway_source_response;

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


