<?php
/**
 * PartnerSubscriptionInfo
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  Vend202601
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * API 2026-01
 *
 * Lightspeed Retail (X-Series) API.
 *
 * The version of the OpenAPI document: 2026-01
 * Contact: x-series.api@lightspeedhq.com
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.21.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 Vend202601\Model;

use \ArrayAccess;
use \Vend202601\ObjectSerializer;

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'charge_interval' => 'int',
        'charge_interval_unit' => 'string',
        'components' => '\Vend202601\Model\ProductInfoComponent[]',
        'currency' => 'string',
        'id' => 'string',
        'next_assessment_at' => 'string',
        'price_in_cents' => 'string',
        'product_family_name' => 'string',
        'product_name' => 'string',
        'product_price_point_name' => 'string',
        'state' => '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 = [
        'charge_interval' => 'int64',
        'charge_interval_unit' => null,
        'components' => null,
        'currency' => null,
        'id' => null,
        'next_assessment_at' => null,
        'price_in_cents' => null,
        'product_family_name' => null,
        'product_name' => null,
        'product_price_point_name' => null,
        'state' => null
    ];

    /**
     * Array of nullable properties. Used for (de)serialization
     *
     * @var boolean[]
     */
    protected static array $openAPINullables = [
        'charge_interval' => false,
        'charge_interval_unit' => false,
        'components' => false,
        'currency' => false,
        'id' => false,
        'next_assessment_at' => false,
        'price_in_cents' => false,
        'product_family_name' => false,
        'product_name' => false,
        'product_price_point_name' => false,
        'state' => 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 = [
        'charge_interval' => 'charge_interval',
        'charge_interval_unit' => 'charge_interval_unit',
        'components' => 'components',
        'currency' => 'currency',
        'id' => 'id',
        'next_assessment_at' => 'next_assessment_at',
        'price_in_cents' => 'price_in_cents',
        'product_family_name' => 'product_family_name',
        'product_name' => 'product_name',
        'product_price_point_name' => 'product_price_point_name',
        'state' => 'state'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'charge_interval' => 'setChargeInterval',
        'charge_interval_unit' => 'setChargeIntervalUnit',
        'components' => 'setComponents',
        'currency' => 'setCurrency',
        'id' => 'setId',
        'next_assessment_at' => 'setNextAssessmentAt',
        'price_in_cents' => 'setPriceInCents',
        'product_family_name' => 'setProductFamilyName',
        'product_name' => 'setProductName',
        'product_price_point_name' => 'setProductPricePointName',
        'state' => 'setState'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'charge_interval' => 'getChargeInterval',
        'charge_interval_unit' => 'getChargeIntervalUnit',
        'components' => 'getComponents',
        'currency' => 'getCurrency',
        'id' => 'getId',
        'next_assessment_at' => 'getNextAssessmentAt',
        'price_in_cents' => 'getPriceInCents',
        'product_family_name' => 'getProductFamilyName',
        'product_name' => 'getProductName',
        'product_price_point_name' => 'getProductPricePointName',
        'state' => 'getState'
    ];

    /**
     * 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('charge_interval', $data ?? [], null);
        $this->setIfExists('charge_interval_unit', $data ?? [], null);
        $this->setIfExists('components', $data ?? [], null);
        $this->setIfExists('currency', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('next_assessment_at', $data ?? [], null);
        $this->setIfExists('price_in_cents', $data ?? [], null);
        $this->setIfExists('product_family_name', $data ?? [], null);
        $this->setIfExists('product_name', $data ?? [], null);
        $this->setIfExists('product_price_point_name', $data ?? [], null);
        $this->setIfExists('state', $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 charge_interval
     *
     * @return int|null
     */
    public function getChargeInterval()
    {
        return $this->container['charge_interval'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets components
     *
     * @return \Vend202601\Model\ProductInfoComponent[]|null
     */
    public function getComponents()
    {
        return $this->container['components'];
    }

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

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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


