<?php
/**
 * AlipayTradeOrderSettleDefaultResponse
 *
 * 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: 2023-12-20
 * 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;

/**
 * AlipayTradeOrderSettleDefaultResponse 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 AlipayTradeOrderSettleDefaultResponse implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

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

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

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'code' => 'setCode',
        'links' => 'setLinks',
        'message' => 'setMessage'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'code' => 'getCode',
        'links' => 'getLinks',
        'message' => 'getMessage'
    ];

    /**
     * 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 CODE_SYSTEM_ERROR = 'ACQ.SYSTEM_ERROR';
    public const CODE_INVALID_PARAMETER = 'ACQ.INVALID_PARAMETER';
    public const CODE_TRADE_NOT_EXIST = 'ACQ.TRADE_NOT_EXIST';
    public const CODE_TRADE_STATUS_ERROR = 'ACQ.TRADE_STATUS_ERROR';
    public const CODE_PARTNER_ERROR = 'ACQ.PARTNER_ERROR';
    public const CODE_DISCORDANT_REPEAT_REQUEST = 'ACQ.DISCORDANT_REPEAT_REQUEST';
    public const CODE_TRADE_SETTLE_ERROR = 'ACQ.TRADE_SETTLE_ERROR';
    public const CODE_USER_LOGONID_DUP = 'ACQ.USER_LOGONID_DUP';
    public const CODE_ROYALTY_RECEIVER_INVALID = 'ACQ.ROYALTY_RECEIVER_INVALID';
    public const CODE_ALLOC_AMOUNT_VALIDATE_ERROR = 'ACQ.ALLOC_AMOUNT_VALIDATE_ERROR';
    public const CODE_FREQUENCY_LIMITED = 'ACQ.FREQUENCY_LIMITED';
    public const CODE_CUSTOMER_VALIDATE_ERROR = 'ACQ.CUSTOMER_VALIDATE_ERROR';
    public const CODE_USER_ACCOUNT_HAD_FREEZEN = 'ACQ.USER_ACCOUNT_HAD_FREEZEN';
    public const CODE_ILLEGAL_SETTLE_STATE = 'ACQ.ILLEGAL_SETTLE_STATE';
    public const CODE_TXN_RESULT_ACCOUNT_BALANCE_NOT_ENOUGH = 'ACQ.TXN_RESULT_ACCOUNT_BALANCE_NOT_ENOUGH';
    public const CODE_REASON_TRADE_STATUS_INVALID = 'ACQ.REASON_TRADE_STATUS_INVALID';
    public const CODE_NOT_SUPPORT_ROYALTY = 'ACQ.NOT_SUPPORT_ROYALTY';
    public const CODE_ROYALTY_ACCOUNT_NOT_EXIST = 'ACQ.ROYALTY_ACCOUNT_NOT_EXIST';
    public const CODE_ROYALTY_ACCOUNT_INVALID = 'ACQ.ROYALTY_ACCOUNT_INVALID';
    public const CODE_SETTLE_ENTITY_ID_INVALID = 'ACQ.SETTLE_ENTITY_ID_INVALID';
    public const CODE_ROYALTY_ACCOUNTS_EQUAL = 'ACQ.ROYALTY_ACCOUNTS_EQUAL';
    public const CODE_DUP_OUT_REQUEST_NO = 'ACQ.DUP_OUT_REQUEST_NO';
    public const CODE_MERCHANT_RISK_LIMIT = 'ACQ.MERCHANT_RISK_LIMIT';
    public const CODE_ROYALTY_PAYER_ACCOUNT_NOT_EXIST = 'ACQ.ROYALTY_PAYER_ACCOUNT_NOT_EXIST';
    public const CODE_ROYALTY_RECEIVER_ACCOUNT_NOT_EXIST = 'ACQ.ROYALTY_RECEIVER_ACCOUNT_NOT_EXIST';
    public const CODE_ROYALTY_PAYER_ACCOUNT_NOT_CERTIFY = 'ACQ.ROYALTY_PAYER_ACCOUNT_NOT_CERTIFY';
    public const CODE_ROYALTY_RECEIVER_ACCOUNT_NOT_CERTIFY = 'ACQ.ROYALTY_RECEIVER_ACCOUNT_NOT_CERTIFY';
    public const CODE_ROYALTY_PAYER_ACCOUNT_NO_BALANCE = 'ACQ.ROYALTY_PAYER_ACCOUNT_NO_BALANCE';
    public const CODE_ROYALTY_RECEIVER_ACCOUNT_NO_BALANCE = 'ACQ.ROYALTY_RECEIVER_ACCOUNT_NO_BALANCE';
    public const CODE_ROYALTY_ACCOUNT_NAME_NOT_MATCH = 'ACQ.ROYALTY_ACCOUNT_NAME_NOT_MATCH';
    public const CODE_SETTLE_TO_CARD_NOT_SUPPORT = 'ACQ.SETTLE_TO_CARD_NOT_SUPPORT';
    public const CODE_REPLENISH_ACCOUNT_INVALID = 'ACQ.REPLENISH_ACCOUNT_INVALID';
    public const CODE_INVALID_REPLENISH_AMOUNT = 'ACQ.INVALID_REPLENISH_AMOUNT';
    public const CODE_ASYNC_ALLOC_NOT_SUPPORT_IN_PERIOD = 'ACQ.ASYNC_ALLOC_NOT_SUPPORT_IN_PERIOD';
    public const CODE_SECONDARY_MERCHANT_ID_INVALID = 'ACQ.SECONDARY_MERCHANT_ID_INVALID';
    public const CODE_MUST_ALLOC_FROM_ROOT_ACCOUNT = 'ACQ.MUST_ALLOC_FROM_ROOT_ACCOUNT';
    public const CODE_UN_SUPPORT_BIZ_TYPE = 'ACQ.UN_SUPPORT_BIZ_TYPE';
    public const CODE_ACCESS_FORBIDDEN = 'ACQ.ACCESS_FORBIDDEN';
    public const CODE_ILLEGAL_REQUEST = 'ACQ.ILLEGAL_REQUEST';
    public const CODE_SETTLE_SCENE_NOT_SUPPORT = 'ACQ.SETTLE_SCENE_NOT_SUPPORT';
    public const CODE_ALLOC_REFUSE_BEFORE_SETTLE = 'ACQ.ALLOC_REFUSE_BEFORE_SETTLE';
    public const CODE_ALLOC_REFUSE_AFTER_REFUND = 'ACQ.ALLOC_REFUSE_AFTER_REFUND';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getCodeAllowableValues()
    {
        return [
            self::CODE_SYSTEM_ERROR,
            self::CODE_INVALID_PARAMETER,
            self::CODE_TRADE_NOT_EXIST,
            self::CODE_TRADE_STATUS_ERROR,
            self::CODE_PARTNER_ERROR,
            self::CODE_DISCORDANT_REPEAT_REQUEST,
            self::CODE_TRADE_SETTLE_ERROR,
            self::CODE_USER_LOGONID_DUP,
            self::CODE_ROYALTY_RECEIVER_INVALID,
            self::CODE_ALLOC_AMOUNT_VALIDATE_ERROR,
            self::CODE_FREQUENCY_LIMITED,
            self::CODE_CUSTOMER_VALIDATE_ERROR,
            self::CODE_USER_ACCOUNT_HAD_FREEZEN,
            self::CODE_ILLEGAL_SETTLE_STATE,
            self::CODE_TXN_RESULT_ACCOUNT_BALANCE_NOT_ENOUGH,
            self::CODE_REASON_TRADE_STATUS_INVALID,
            self::CODE_NOT_SUPPORT_ROYALTY,
            self::CODE_ROYALTY_ACCOUNT_NOT_EXIST,
            self::CODE_ROYALTY_ACCOUNT_INVALID,
            self::CODE_SETTLE_ENTITY_ID_INVALID,
            self::CODE_ROYALTY_ACCOUNTS_EQUAL,
            self::CODE_DUP_OUT_REQUEST_NO,
            self::CODE_MERCHANT_RISK_LIMIT,
            self::CODE_ROYALTY_PAYER_ACCOUNT_NOT_EXIST,
            self::CODE_ROYALTY_RECEIVER_ACCOUNT_NOT_EXIST,
            self::CODE_ROYALTY_PAYER_ACCOUNT_NOT_CERTIFY,
            self::CODE_ROYALTY_RECEIVER_ACCOUNT_NOT_CERTIFY,
            self::CODE_ROYALTY_PAYER_ACCOUNT_NO_BALANCE,
            self::CODE_ROYALTY_RECEIVER_ACCOUNT_NO_BALANCE,
            self::CODE_ROYALTY_ACCOUNT_NAME_NOT_MATCH,
            self::CODE_SETTLE_TO_CARD_NOT_SUPPORT,
            self::CODE_REPLENISH_ACCOUNT_INVALID,
            self::CODE_INVALID_REPLENISH_AMOUNT,
            self::CODE_ASYNC_ALLOC_NOT_SUPPORT_IN_PERIOD,
            self::CODE_SECONDARY_MERCHANT_ID_INVALID,
            self::CODE_MUST_ALLOC_FROM_ROOT_ACCOUNT,
            self::CODE_UN_SUPPORT_BIZ_TYPE,
            self::CODE_ACCESS_FORBIDDEN,
            self::CODE_ILLEGAL_REQUEST,
            self::CODE_SETTLE_SCENE_NOT_SUPPORT,
            self::CODE_ALLOC_REFUSE_BEFORE_SETTLE,
            self::CODE_ALLOC_REFUSE_AFTER_REFUND,
        ];
    }

    /**
     * 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['code'] = $data['code'] ?? null;
        $this->container['links'] = $data['links'] ?? null;
        $this->container['message'] = $data['message'] ?? null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['code'] === null) {
            $invalidProperties[] = "'code' can't be null";
        }
        $allowedValues = $this->getCodeAllowableValues();
        if (!is_null($this->container['code']) && !in_array($this->container['code'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'code', must be one of '%s'",
                $this->container['code'],
                implode("', '", $allowedValues)
            );
        }

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

    /**
     * Sets code
     *
     * @param string $code 错误码
     *
     * @return self
     */
    public function setCode($code)
    {
        $allowedValues = $this->getCodeAllowableValues();
        if (!in_array($code, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'code', must be one of '%s'",
                    $code,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['code'] = $code;

        return $this;
    }

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

    /**
     * Sets links
     *
     * @param string|null $links 解决方案链接
     *
     * @return self
     */
    public function setLinks($links)
    {
        $this->container['links'] = $links;

        return $this;
    }

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

    /**
     * Sets message
     *
     * @param string $message 错误描述
     *
     * @return self
     */
    public function setMessage($message)
    {
        $this->container['message'] = $message;

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


