<?php
/**
 * ApplicationProfileResponse
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Linnworks\Auth
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Authenticate API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: auth
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.11.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 Linnworks\Auth\Model;

use \ArrayAccess;
use \Linnworks\Auth\ObjectSerializer;

/**
 * ApplicationProfileResponse Class Doc Comment
 *
 * @category Class
 * @description Represents Linnworks.net application subscription profile
 * @package  Linnworks\Auth
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class ApplicationProfileResponse implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'plan_tag' => 'string',
        'plan_name' => 'string',
        'activation_date' => '\DateTime',
        'last_payment_date' => '\DateTime',
        'next_payment_date' => '\DateTime',
        'profile_expires' => '\DateTime',
        'is_profile_active' => 'bool'
    ];

    /**
      * 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 = [
        'plan_tag' => null,
        'plan_name' => null,
        'activation_date' => 'date-time',
        'last_payment_date' => 'date-time',
        'next_payment_date' => 'date-time',
        'profile_expires' => 'date-time',
        'is_profile_active' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'plan_tag' => false,
        'plan_name' => false,
        'activation_date' => false,
        'last_payment_date' => false,
        'next_payment_date' => false,
        'profile_expires' => false,
        'is_profile_active' => 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 = [
        'plan_tag' => 'PlanTag',
        'plan_name' => 'PlanName',
        'activation_date' => 'ActivationDate',
        'last_payment_date' => 'LastPaymentDate',
        'next_payment_date' => 'NextPaymentDate',
        'profile_expires' => 'ProfileExpires',
        'is_profile_active' => 'IsProfileActive'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'plan_tag' => 'setPlanTag',
        'plan_name' => 'setPlanName',
        'activation_date' => 'setActivationDate',
        'last_payment_date' => 'setLastPaymentDate',
        'next_payment_date' => 'setNextPaymentDate',
        'profile_expires' => 'setProfileExpires',
        'is_profile_active' => 'setIsProfileActive'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'plan_tag' => 'getPlanTag',
        'plan_name' => 'getPlanName',
        'activation_date' => 'getActivationDate',
        'last_payment_date' => 'getLastPaymentDate',
        'next_payment_date' => 'getNextPaymentDate',
        'profile_expires' => 'getProfileExpires',
        'is_profile_active' => 'getIsProfileActive'
    ];

    /**
     * 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('plan_tag', $data ?? [], null);
        $this->setIfExists('plan_name', $data ?? [], null);
        $this->setIfExists('activation_date', $data ?? [], null);
        $this->setIfExists('last_payment_date', $data ?? [], null);
        $this->setIfExists('next_payment_date', $data ?? [], null);
        $this->setIfExists('profile_expires', $data ?? [], null);
        $this->setIfExists('is_profile_active', $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 plan_tag
     *
     * @return string|null
     */
    public function getPlanTag()
    {
        return $this->container['plan_tag'];
    }

    /**
     * Sets plan_tag
     *
     * @param string|null $plan_tag Plan Tag as defined in your Application Configuration
     *
     * @return self
     */
    public function setPlanTag($plan_tag)
    {
        if (is_null($plan_tag)) {
            throw new \InvalidArgumentException('non-nullable plan_tag cannot be null');
        }
        $this->container['plan_tag'] = $plan_tag;

        return $this;
    }

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

    /**
     * Sets plan_name
     *
     * @param string|null $plan_name Plan Name as defined in your application Configuration
     *
     * @return self
     */
    public function setPlanName($plan_name)
    {
        if (is_null($plan_name)) {
            throw new \InvalidArgumentException('non-nullable plan_name cannot be null');
        }
        $this->container['plan_name'] = $plan_name;

        return $this;
    }

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

    /**
     * Sets activation_date
     *
     * @param \DateTime|null $activation_date Date when the profile was signed up for, or resubscribed
     *
     * @return self
     */
    public function setActivationDate($activation_date)
    {
        if (is_null($activation_date)) {
            throw new \InvalidArgumentException('non-nullable activation_date cannot be null');
        }
        $this->container['activation_date'] = $activation_date;

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

    /**
     * Sets profile_expires
     *
     * @param \DateTime|null $profile_expires When profile is due to expire
     *
     * @return self
     */
    public function setProfileExpires($profile_expires)
    {
        if (is_null($profile_expires)) {
            throw new \InvalidArgumentException('non-nullable profile_expires cannot be null');
        }
        $this->container['profile_expires'] = $profile_expires;

        return $this;
    }

    /**
     * Gets is_profile_active
     *
     * @return bool|null
     */
    public function getIsProfileActive()
    {
        return $this->container['is_profile_active'];
    }

    /**
     * Sets is_profile_active
     *
     * @param bool|null $is_profile_active Indicates whether the payment profile is active for the application, if this is set to false it means the customer canceled the profile but the profile is still active due last payment made in the last month.
     *
     * @return self
     */
    public function setIsProfileActive($is_profile_active)
    {
        if (is_null($is_profile_active)) {
            throw new \InvalidArgumentException('non-nullable is_profile_active cannot be null');
        }
        $this->container['is_profile_active'] = $is_profile_active;

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


