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

/**
 * GlobalPaymentType Class Doc Comment
 *
 * @category Class
 * @description The global (platform-level) payment type definition associated with a retailer payment type.
 * @package  Vend202601
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class GlobalPaymentType implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'badge' => 'string',
        'category' => 'string',
        'configuration_url' => 'string',
        'description' => 'string',
        'header' => 'string',
        'id' => 'int',
        'internal' => 'bool',
        'logo' => 'string',
        'name' => 'string',
        'online_only' => 'bool',
        'platforms' => 'string[]',
        'referred_inactive' => 'bool',
        'show_banner' => 'bool',
        'subcategory' => 'string',
        'subtext' => '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 = [
        'badge' => null,
        'category' => null,
        'configuration_url' => null,
        'description' => null,
        'header' => null,
        'id' => 'int64',
        'internal' => null,
        'logo' => null,
        'name' => null,
        'online_only' => null,
        'platforms' => null,
        'referred_inactive' => null,
        'show_banner' => null,
        'subcategory' => null,
        'subtext' => null
    ];

    /**
     * Array of nullable properties. Used for (de)serialization
     *
     * @var boolean[]
     */
    protected static array $openAPINullables = [
        'badge' => true,
        'category' => false,
        'configuration_url' => true,
        'description' => true,
        'header' => true,
        'id' => false,
        'internal' => false,
        'logo' => true,
        'name' => false,
        'online_only' => false,
        'platforms' => false,
        'referred_inactive' => false,
        'show_banner' => false,
        'subcategory' => false,
        'subtext' => true
    ];

    /**
     * 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 = [
        'badge' => 'badge',
        'category' => 'category',
        'configuration_url' => 'configuration_url',
        'description' => 'description',
        'header' => 'header',
        'id' => 'id',
        'internal' => 'internal',
        'logo' => 'logo',
        'name' => 'name',
        'online_only' => 'online_only',
        'platforms' => 'platforms',
        'referred_inactive' => 'referred_inactive',
        'show_banner' => 'show_banner',
        'subcategory' => 'subcategory',
        'subtext' => 'subtext'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'badge' => 'setBadge',
        'category' => 'setCategory',
        'configuration_url' => 'setConfigurationUrl',
        'description' => 'setDescription',
        'header' => 'setHeader',
        'id' => 'setId',
        'internal' => 'setInternal',
        'logo' => 'setLogo',
        'name' => 'setName',
        'online_only' => 'setOnlineOnly',
        'platforms' => 'setPlatforms',
        'referred_inactive' => 'setReferredInactive',
        'show_banner' => 'setShowBanner',
        'subcategory' => 'setSubcategory',
        'subtext' => 'setSubtext'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'badge' => 'getBadge',
        'category' => 'getCategory',
        'configuration_url' => 'getConfigurationUrl',
        'description' => 'getDescription',
        'header' => 'getHeader',
        'id' => 'getId',
        'internal' => 'getInternal',
        'logo' => 'getLogo',
        'name' => 'getName',
        'online_only' => 'getOnlineOnly',
        'platforms' => 'getPlatforms',
        'referred_inactive' => 'getReferredInactive',
        'show_banner' => 'getShowBanner',
        'subcategory' => 'getSubcategory',
        'subtext' => 'getSubtext'
    ];

    /**
     * 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('badge', $data ?? [], null);
        $this->setIfExists('category', $data ?? [], null);
        $this->setIfExists('configuration_url', $data ?? [], null);
        $this->setIfExists('description', $data ?? [], null);
        $this->setIfExists('header', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('internal', $data ?? [], null);
        $this->setIfExists('logo', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('online_only', $data ?? [], null);
        $this->setIfExists('platforms', $data ?? [], null);
        $this->setIfExists('referred_inactive', $data ?? [], null);
        $this->setIfExists('show_banner', $data ?? [], null);
        $this->setIfExists('subcategory', $data ?? [], null);
        $this->setIfExists('subtext', $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['category'] === null) {
            $invalidProperties[] = "'category' can't be null";
        }
        if ($this->container['id'] === null) {
            $invalidProperties[] = "'id' can't be null";
        }
        if ($this->container['internal'] === null) {
            $invalidProperties[] = "'internal' can't be null";
        }
        if ($this->container['name'] === null) {
            $invalidProperties[] = "'name' can't be null";
        }
        if ($this->container['online_only'] === null) {
            $invalidProperties[] = "'online_only' can't be null";
        }
        if ($this->container['platforms'] === null) {
            $invalidProperties[] = "'platforms' can't be null";
        }
        if ($this->container['referred_inactive'] === null) {
            $invalidProperties[] = "'referred_inactive' can't be null";
        }
        if ($this->container['show_banner'] === null) {
            $invalidProperties[] = "'show_banner' can't be null";
        }
        if ($this->container['subcategory'] === null) {
            $invalidProperties[] = "'subcategory' 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 badge
     *
     * @return string|null
     */
    public function getBadge()
    {
        return $this->container['badge'];
    }

    /**
     * Sets badge
     *
     * @param string|null $badge URL of the payment type badge image.
     *
     * @return self
     */
    public function setBadge($badge)
    {
        if (is_null($badge)) {
            array_push($this->openAPINullablesSetToNull, 'badge');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('badge', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['badge'] = $badge;

        return $this;
    }

    /**
     * Gets category
     *
     * @return string
     */
    public function getCategory()
    {
        return $this->container['category'];
    }

    /**
     * Sets category
     *
     * @param string $category The category of the payment type.
     *
     * @return self
     */
    public function setCategory($category)
    {
        if (is_null($category)) {
            throw new \InvalidArgumentException('non-nullable category cannot be null');
        }
        $this->container['category'] = $category;

        return $this;
    }

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

    /**
     * Sets configuration_url
     *
     * @param string|null $configuration_url URL for configuring this payment type.
     *
     * @return self
     */
    public function setConfigurationUrl($configuration_url)
    {
        if (is_null($configuration_url)) {
            array_push($this->openAPINullablesSetToNull, 'configuration_url');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('configuration_url', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['configuration_url'] = $configuration_url;

        return $this;
    }

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

    /**
     * Sets description
     *
     * @param string|null $description A description of the payment type.
     *
     * @return self
     */
    public function setDescription($description)
    {
        if (is_null($description)) {
            array_push($this->openAPINullablesSetToNull, 'description');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('description', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['description'] = $description;

        return $this;
    }

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

    /**
     * Sets header
     *
     * @param string|null $header The display header for the payment type.
     *
     * @return self
     */
    public function setHeader($header)
    {
        if (is_null($header)) {
            array_push($this->openAPINullablesSetToNull, 'header');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('header', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['header'] = $header;

        return $this;
    }

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

    /**
     * Sets id
     *
     * @param int $id The global payment type 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 internal
     *
     * @return bool
     */
    public function getInternal()
    {
        return $this->container['internal'];
    }

    /**
     * Sets internal
     *
     * @param bool $internal Indicates if this is an internal payment type.
     *
     * @return self
     */
    public function setInternal($internal)
    {
        if (is_null($internal)) {
            throw new \InvalidArgumentException('non-nullable internal cannot be null');
        }
        $this->container['internal'] = $internal;

        return $this;
    }

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

    /**
     * Sets logo
     *
     * @param string|null $logo URL of the payment type logo.
     *
     * @return self
     */
    public function setLogo($logo)
    {
        if (is_null($logo)) {
            array_push($this->openAPINullablesSetToNull, 'logo');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('logo', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['logo'] = $logo;

        return $this;
    }

    /**
     * Gets name
     *
     * @return string
     */
    public function getName()
    {
        return $this->container['name'];
    }

    /**
     * Sets name
     *
     * @param string $name The name of the global payment type.
     *
     * @return self
     */
    public function setName($name)
    {
        if (is_null($name)) {
            throw new \InvalidArgumentException('non-nullable name cannot be null');
        }
        $this->container['name'] = $name;

        return $this;
    }

    /**
     * Gets online_only
     *
     * @return bool
     */
    public function getOnlineOnly()
    {
        return $this->container['online_only'];
    }

    /**
     * Sets online_only
     *
     * @param bool $online_only Indicates if this payment type is available online only.
     *
     * @return self
     */
    public function setOnlineOnly($online_only)
    {
        if (is_null($online_only)) {
            throw new \InvalidArgumentException('non-nullable online_only cannot be null');
        }
        $this->container['online_only'] = $online_only;

        return $this;
    }

    /**
     * Gets platforms
     *
     * @return string[]
     */
    public function getPlatforms()
    {
        return $this->container['platforms'];
    }

    /**
     * Sets platforms
     *
     * @param string[] $platforms The platforms on which this payment type is supported.
     *
     * @return self
     */
    public function setPlatforms($platforms)
    {
        if (is_null($platforms)) {
            throw new \InvalidArgumentException('non-nullable platforms cannot be null');
        }
        $this->container['platforms'] = $platforms;

        return $this;
    }

    /**
     * Gets referred_inactive
     *
     * @return bool
     */
    public function getReferredInactive()
    {
        return $this->container['referred_inactive'];
    }

    /**
     * Sets referred_inactive
     *
     * @param bool $referred_inactive Indicates if the payment type was referred but is inactive.
     *
     * @return self
     */
    public function setReferredInactive($referred_inactive)
    {
        if (is_null($referred_inactive)) {
            throw new \InvalidArgumentException('non-nullable referred_inactive cannot be null');
        }
        $this->container['referred_inactive'] = $referred_inactive;

        return $this;
    }

    /**
     * Gets show_banner
     *
     * @return bool
     */
    public function getShowBanner()
    {
        return $this->container['show_banner'];
    }

    /**
     * Sets show_banner
     *
     * @param bool $show_banner Indicates if a banner should be shown for this payment type.
     *
     * @return self
     */
    public function setShowBanner($show_banner)
    {
        if (is_null($show_banner)) {
            throw new \InvalidArgumentException('non-nullable show_banner cannot be null');
        }
        $this->container['show_banner'] = $show_banner;

        return $this;
    }

    /**
     * Gets subcategory
     *
     * @return string
     */
    public function getSubcategory()
    {
        return $this->container['subcategory'];
    }

    /**
     * Sets subcategory
     *
     * @param string $subcategory The subcategory of the payment type.
     *
     * @return self
     */
    public function setSubcategory($subcategory)
    {
        if (is_null($subcategory)) {
            throw new \InvalidArgumentException('non-nullable subcategory cannot be null');
        }
        $this->container['subcategory'] = $subcategory;

        return $this;
    }

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

    /**
     * Sets subtext
     *
     * @param string|null $subtext Additional display text shown below the payment type name.
     *
     * @return self
     */
    public function setSubtext($subtext)
    {
        if (is_null($subtext)) {
            array_push($this->openAPINullablesSetToNull, 'subtext');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('subtext', $nullablesSetToNull);
            if ($index !== FALSE) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['subtext'] = $subtext;

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


