v3/src/Model/AlipayOpenAppMiniTemplatemessageSendModel.php
<?php
/**
 * AlipayOpenAppMiniTemplatemessageSendModel
 *
 * PHP version 7.4
 *
 * @category Class
 * @package  Alipay\OpenAPISDK
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * 支付宝开放平台API
 *
 * 支付宝开放平台v3协议文档
 *
 * The version of the OpenAPI document: 2025-08-26
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.2.1
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Alipay\OpenAPISDK\Model;

use \ArrayAccess;
use \Alipay\OpenAPISDK\ObjectSerializer;

/**
 * AlipayOpenAppMiniTemplatemessageSendModel Class Doc Comment
 *
 * @category Class
 * @package  Alipay\OpenAPISDK
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<TKey, TValue>
 * @template TKey int|null
 * @template TValue mixed|null
 */
class AlipayOpenAppMiniTemplatemessageSendModel implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'data' => 'string',
        'formId' => 'string',
        'page' => 'string',
        'toOpenId' => 'string',
        'toUserId' => 'string',
        'userTemplateId' => '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 = [
        'data' => null,
        'formId' => null,
        'page' => null,
        'toOpenId' => null,
        'toUserId' => null,
        'userTemplateId' => null
    ];

    /**
     * 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 attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'data' => 'data',
        'formId' => 'form_id',
        'page' => 'page',
        'toOpenId' => 'to_open_id',
        'toUserId' => 'to_user_id',
        'userTemplateId' => 'user_template_id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'data' => 'setData',
        'formId' => 'setFormId',
        'page' => 'setPage',
        'toOpenId' => 'setToOpenId',
        'toUserId' => 'setToUserId',
        'userTemplateId' => 'setUserTemplateId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'data' => 'getData',
        'formId' => 'getFormId',
        'page' => 'getPage',
        'toOpenId' => 'getToOpenId',
        'toUserId' => 'getToUserId',
        'userTemplateId' => 'getUserTemplateId'
    ];

    /**
     * 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->container['data'] = $data['data'] ?? null;
        $this->container['formId'] = $data['formId'] ?? null;
        $this->container['page'] = $data['page'] ?? null;
        $this->container['toOpenId'] = $data['toOpenId'] ?? null;
        $this->container['toUserId'] = $data['toUserId'] ?? null;
        $this->container['userTemplateId'] = $data['userTemplateId'] ?? null;
    }

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

    /**
     * Sets data
     *
     * @param string|null $data 模板消息内容。商家/开发者将模板占位符替换为自定义内容
     *
     * @return self
     */
    public function setData($data)
    {
        $this->container['data'] = $data;

        return $this;
    }

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

    /**
     * Sets formId
     *
     * @param string|null $formId 支付消息模板：需传入用户发生的交易行为的支付宝交易号 trade_no；</br>表单提交模板：需传入用户在小程序触发表单提交事件获得的表单号；</br>刷脸消息模板：需传入在IOT刷脸后得到的ftoken等，用于信息发送的校验。</br>
     *
     * @return self
     */
    public function setFormId($formId)
    {
        $this->container['formId'] = $formId;

        return $this;
    }

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

    /**
     * Sets page
     *
     * @param string|null $page 小程序的跳转页面。用于用户点击模板消息 进入小程序查看 按钮后，跳转至商家小程序对应页面。
     *
     * @return self
     */
    public function setPage($page)
    {
        $this->container['page'] = $page;

        return $this;
    }

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

    /**
     * Sets toOpenId
     *
     * @param string|null $toOpenId 支付宝openId，用于支付宝用户在当前应用下的用户标识。
     *
     * @return self
     */
    public function setToOpenId($toOpenId)
    {
        $this->container['toOpenId'] = $toOpenId;

        return $this;
    }

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

    /**
     * Sets toUserId
     *
     * @param string|null $toUserId 接收模板消息用户支付宝 user_id，可通过 <a href=\"https://opendocs.alipay.com/mini/api/openapi-authorize\">用户授权</a> 获取
     *
     * @return self
     */
    public function setToUserId($toUserId)
    {
        $this->container['toUserId'] = $toUserId;

        return $this;
    }

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

    /**
     * Sets userTemplateId
     *
     * @param string|null $userTemplateId 商家在商家自运营中心选用的消息模板ID，详情参见 <a href=\"https://opendocs.alipay.com/mini/03l9bb?pathHash=19d2e0aa&ref=api#%E9%A2%86%E7%94%A8%E8%AE%A2%E9%98%85%E6%B6%88%E6%81%AF%E6%A8%A1%E6%9D%BF\">选用消息模板</a> 。
     *
     * @return self
     */
    public function setUserTemplateId($userTemplateId)
    {
        $this->container['userTemplateId'] = $userTemplateId;

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


