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

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'installment_plan_number' => 'string',
        'ref_order_number' => 'string',
        'purchase_method' => '\Splitit\Model\PurchaseMethod',
        'status' => '\Splitit\Model\PlanStatus',
        'currency' => 'string',
        'amount' => 'float',
        'extended_params' => 'array<string,string>',
        'shopper' => '\Splitit\Model\ShopperData',
        'billing_address' => '\Splitit\Model\AddressData',
        'checkout_url' => '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 = [
        'installment_plan_number' => null,
        'ref_order_number' => null,
        'purchase_method' => null,
        'status' => null,
        'currency' => null,
        'amount' => 'decimal',
        'extended_params' => null,
        'shopper' => null,
        'billing_address' => null,
        'checkout_url' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static $openAPINullables = [
        'installment_plan_number' => false,
		'ref_order_number' => false,
		'purchase_method' => false,
		'status' => false,
		'currency' => false,
		'amount' => false,
		'extended_params' => false,
		'shopper' => false,
		'billing_address' => false,
		'checkout_url' => 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 = [
        'installment_plan_number' => 'InstallmentPlanNumber',
        'ref_order_number' => 'RefOrderNumber',
        'purchase_method' => 'PurchaseMethod',
        'status' => 'Status',
        'currency' => 'Currency',
        'amount' => 'Amount',
        'extended_params' => 'ExtendedParams',
        'shopper' => 'Shopper',
        'billing_address' => 'BillingAddress',
        'checkout_url' => 'CheckoutUrl'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'installment_plan_number' => 'setInstallmentPlanNumber',
        'ref_order_number' => 'setRefOrderNumber',
        'purchase_method' => 'setPurchaseMethod',
        'status' => 'setStatus',
        'currency' => 'setCurrency',
        'amount' => 'setAmount',
        'extended_params' => 'setExtendedParams',
        'shopper' => 'setShopper',
        'billing_address' => 'setBillingAddress',
        'checkout_url' => 'setCheckoutUrl'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'installment_plan_number' => 'getInstallmentPlanNumber',
        'ref_order_number' => 'getRefOrderNumber',
        'purchase_method' => 'getPurchaseMethod',
        'status' => 'getStatus',
        'currency' => 'getCurrency',
        'amount' => 'getAmount',
        'extended_params' => 'getExtendedParams',
        'shopper' => 'getShopper',
        'billing_address' => 'getBillingAddress',
        'checkout_url' => 'getCheckoutUrl'
    ];

    /**
     * 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('installment_plan_number', $data ?? [], null);
        $this->setIfExists('ref_order_number', $data ?? [], null);
        $this->setIfExists('purchase_method', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('currency', $data ?? [], null);
        $this->setIfExists('amount', $data ?? [], null);
        $this->setIfExists('extended_params', $data ?? [], null);
        $this->setIfExists('shopper', $data ?? [], null);
        $this->setIfExists('billing_address', $data ?? [], null);
        $this->setIfExists('checkout_url', $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 installment_plan_number
     *
     * @return string|null
     */
    public function getInstallmentPlanNumber()
    {
        return $this->container['installment_plan_number'];
    }

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

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

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

        return $this;
    }

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

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

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

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

        return $this;
    }

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

    /**
     * Sets purchase_method
     *
     * @param \Splitit\Model\PurchaseMethod|null $purchase_method purchase_method
     *
     * @return self
     */
    public function setPurchaseMethod($purchase_method)
    {

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

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

        return $this;
    }

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

    /**
     * Sets status
     *
     * @param \Splitit\Model\PlanStatus $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 currency
     *
     * @return string|null
     */
    public function getCurrency()
    {
        return $this->container['currency'];
    }

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

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

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

        return $this;
    }

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

    /**
     * Sets amount
     *
     * @param float|null $amount amount
     *
     * @return self
     */
    public function setAmount($amount)
    {

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

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

        return $this;
    }

    /**
     * Gets extended_params
     *
     * @return array<string,string>|null
     */
    public function getExtendedParams()
    {
        return $this->container['extended_params'];
    }

    /**
     * Sets extended_params
     *
     * @param array<string,string>|null $extended_params extended_params
     *
     * @return self
     */
    public function setExtendedParams($extended_params)
    {

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

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

        return $this;
    }

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

    /**
     * Sets shopper
     *
     * @param \Splitit\Model\ShopperData|null $shopper shopper
     *
     * @return self
     */
    public function setShopper($shopper)
    {

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

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

        return $this;
    }

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

    /**
     * Sets billing_address
     *
     * @param \Splitit\Model\AddressData|null $billing_address billing_address
     *
     * @return self
     */
    public function setBillingAddress($billing_address)
    {

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

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

        return $this;
    }

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

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

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

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

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


