<?php
/**
 * PaymentsGetAvailablePaymentMethods200ResponseInner
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * Simply.in API
 *
 * Swagger documentation for SIMPLY.IN
 *
 * The version of the OpenAPI document: 1.99.21 (preprod)
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.14.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 *
 * EXCEPTION: the "slug" field's enum validation (SLUG_* constants, getSlugAllowableValues(),
 * and the enum-membership checks in setSlug()/listInvalidProperties()) was hand-removed on
 * top of the last regen, because the backend's contract for this field is no longer a
 * closed enum. The spec snapshots under openapi/ are stale and still declare it as one — a
 * future regen from those snapshots (or an unrefreshed live spec) will silently reintroduce
 * this validation. Refresh the spec from the live backend first, confirm "slug" is a plain
 * string in it, and only then regenerate this model.
 */

namespace Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model;

use \ArrayAccess;
use \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\ObjectSerializer;

/**
 * PaymentsGetAvailablePaymentMethods200ResponseInner Class Doc Comment
 *
 * @category Class
 * @package  Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class PaymentsGetAvailablePaymentMethods200ResponseInner implements ModelInterface, ArrayAccess, \JsonSerializable {

	public const DISCRIMINATOR = null;

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

	/**
	 * Array of property to type mappings. Used for (de)serialization
	 *
	 * @var string[]
	 */
	protected static $openAPITypes = [
		'payment_method_id'  => 'string',
		'type'               => 'string',
		'type_name'          => 'string',
		'name'               => 'string',
		'slug'               => 'string',
		'logo_thumbnail_url' => 'string',
		'payment_provider'   => '\Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerPaymentProvider',
		'card'               => '\Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerCard',
		'add_card'           => '\Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerAddCard',
	];

	/**
	 * 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 = [
		'payment_method_id'  => 'uuid',
		'type'               => null,
		'type_name'          => null,
		'name'               => null,
		'slug'               => null,
		'logo_thumbnail_url' => 'uri',
		'payment_provider'   => null,
		'card'               => null,
		'add_card'           => null,
	];

	/**
	 * Array of nullable properties. Used for (de)serialization
	 *
	 * @var boolean[]
	 */
	protected static array $openAPINullables = [
		'payment_method_id'  => false,
		'type'               => false,
		'type_name'          => false,
		'name'               => false,
		'slug'               => false,
		'logo_thumbnail_url' => false,
		'payment_provider'   => false,
		'card'               => true,
		'add_card'           => 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 = [
		'payment_method_id'  => 'paymentMethodId',
		'type'               => 'type',
		'type_name'          => 'typeName',
		'name'               => 'name',
		'slug'               => 'slug',
		'logo_thumbnail_url' => 'logoThumbnailUrl',
		'payment_provider'   => 'paymentProvider',
		'card'               => 'card',
		'add_card'           => 'addCard',
	];

	/**
	 * Array of attributes to setter functions (for deserialization of responses)
	 *
	 * @var string[]
	 */
	protected static $setters = [
		'payment_method_id'  => 'setPaymentMethodId',
		'type'               => 'setType',
		'type_name'          => 'setTypeName',
		'name'               => 'setName',
		'slug'               => 'setSlug',
		'logo_thumbnail_url' => 'setLogoThumbnailUrl',
		'payment_provider'   => 'setPaymentProvider',
		'card'               => 'setCard',
		'add_card'           => 'setAddCard',
	];

	/**
	 * Array of attributes to getter functions (for serialization of requests)
	 *
	 * @var string[]
	 */
	protected static $getters = [
		'payment_method_id'  => 'getPaymentMethodId',
		'type'               => 'getType',
		'type_name'          => 'getTypeName',
		'name'               => 'getName',
		'slug'               => 'getSlug',
		'logo_thumbnail_url' => 'getLogoThumbnailUrl',
		'payment_provider'   => 'getPaymentProvider',
		'card'               => 'getCard',
		'add_card'           => 'getAddCard',
	];

	/**
	 * 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;
	}

	public const TYPE_CARD = 'card';

	public const TYPE_ADD_CARD = 'add_card';

	public const TYPE_BLIK = 'blik';

	public const TYPE_PAY_BY_LINK = 'pay_by_link';

	public const TYPE_APPLEPAY = 'applepay';

	public const TYPE_GOOGLEPAY = 'googlepay';

	public const TYPE_PAYWALL = 'paywall';

	public const TYPE_OTHER = 'other';

	/**
	 * Gets allowable values of the enum
	 *
	 * @return string[]
	 */
	public function getTypeAllowableValues() {
		return [
			self::TYPE_CARD,
			self::TYPE_ADD_CARD,
			self::TYPE_BLIK,
			self::TYPE_PAY_BY_LINK,
			self::TYPE_APPLEPAY,
			self::TYPE_GOOGLEPAY,
			self::TYPE_PAYWALL,
			self::TYPE_OTHER,
		];
	}

	/**
	 * 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( 'payment_method_id', $data ?? [], null );
		$this->setIfExists( 'type', $data ?? [], null );
		$this->setIfExists( 'type_name', $data ?? [], null );
		$this->setIfExists( 'name', $data ?? [], null );
		$this->setIfExists( 'slug', $data ?? [], null );
		$this->setIfExists( 'logo_thumbnail_url', $data ?? [], null );
		$this->setIfExists( 'payment_provider', $data ?? [], null );
		$this->setIfExists( 'card', $data ?? [], null );
		$this->setIfExists( 'add_card', $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['payment_method_id'] === null ) {
			$invalidProperties[] = "'payment_method_id' can't be null";
		}
		if ( $this->container['type'] === null ) {
			$invalidProperties[] = "'type' can't be null";
		}
		$allowedValues = $this->getTypeAllowableValues();
		if ( ! is_null( $this->container['type'] ) && ! in_array( $this->container['type'],
				$allowedValues,
				true ) ) {
			$invalidProperties[] = sprintf(
				"invalid value '%s' for 'type', must be one of '%s'",
				$this->container['type'],
				implode( "', '", $allowedValues )
			);
		}

		if ( $this->container['type_name'] === null ) {
			$invalidProperties[] = "'type_name' can't be null";
		}
		if ( $this->container['name'] === null ) {
			$invalidProperties[] = "'name' can't be null";
		}
		if ( $this->container['slug'] === null ) {
			$invalidProperties[] = "'slug' can't be null";
		}

		if ( $this->container['payment_provider'] === null ) {
			$invalidProperties[] = "'payment_provider' 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 payment_method_id
	 *
	 * @return string
	 */
	public function getPaymentMethodId() {
		return $this->container['payment_method_id'];
	}

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

		return $this;
	}

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

	/**
	 * Sets type
	 *
	 * @param string $type type
	 *
	 * @return self
	 */
	public function setType( $type ) {
		if ( is_null( $type ) ) {
			throw new \InvalidArgumentException( 'non-nullable type cannot be null' );
		}
		$allowedValues = $this->getTypeAllowableValues();
		if ( ! in_array( $type, $allowedValues, true ) ) {
			throw new \InvalidArgumentException(
				esc_html( sprintf(
						"Invalid value '%s' for 'type', must be one of '%s'",
						$type,
						implode( "', '", $allowedValues )
					)
				) );
		}
		$this->container['type'] = $type;

		return $this;
	}

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

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

		return $this;
	}

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

	/**
	 * Sets name
	 *
	 * @param string $name name
	 *
	 * @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 slug
	 *
	 * @return string
	 */
	public function getSlug() {
		return $this->container['slug'];
	}

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

		return $this;
	}

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

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

		return $this;
	}

	/**
	 * Gets payment_provider
	 *
	 * @return \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerPaymentProvider
	 */
	public function getPaymentProvider() {
		return $this->container['payment_provider'];
	}

	/**
	 * Sets payment_provider
	 *
	 * @param \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerPaymentProvider $payment_provider payment_provider
	 *
	 * @return self
	 */
	public function setPaymentProvider( $payment_provider ) {
		if ( is_null( $payment_provider ) ) {
			throw new \InvalidArgumentException( 'non-nullable payment_provider cannot be null' );
		}
		$this->container['payment_provider'] = $payment_provider;

		return $this;
	}

	/**
	 * Gets card
	 *
	 * @return \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerCard|null
	 */
	public function getCard() {
		return $this->container['card'];
	}

	/**
	 * Sets card
	 *
	 * @param \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerCard|null $card card
	 *
	 * @return self
	 */
	public function setCard( $card ) {
		if ( is_null( $card ) ) {
			array_push( $this->openAPINullablesSetToNull, 'card' );
		} else {
			$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
			$index              = array_search( 'card', $nullablesSetToNull );
			if ( $index !== false ) {
				unset( $nullablesSetToNull[ $index ] );
				$this->setOpenAPINullablesSetToNull( $nullablesSetToNull );
			}
		}
		$this->container['card'] = $card;

		return $this;
	}

	/**
	 * Gets add_card
	 *
	 * @return \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerAddCard|null
	 */
	public function getAddCard() {
		return $this->container['add_card'];
	}

	/**
	 * Sets add_card
	 *
	 * @param \Simplyin\Simplyin_W_Plugin\Lib\Remote\SimplyInApi\Model\PaymentsGetAvailablePaymentMethods200ResponseInnerAddCard|null $add_card add_card
	 *
	 * @return self
	 */
	public function setAddCard( $add_card ) {
		if ( is_null( $add_card ) ) {
			array_push( $this->openAPINullablesSetToNull, 'add_card' );
		} else {
			$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
			$index              = array_search( 'add_card',
				$nullablesSetToNull );
			if ( $index !== false ) {
				unset( $nullablesSetToNull[ $index ] );
				$this->setOpenAPINullablesSetToNull( $nullablesSetToNull );
			}
		}
		$this->container['add_card'] = $add_card;

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