getCredentialList(data: GetCredentialListParams)

版本要求:
@tuya-miniapp/cloud-api≥1.5.0

描述

查询用户的增值服务凭证,用于判断指定服务是否已开通,并获取凭证有效期、使用状态和剩余额度。

参数

参数类型必填说明
是请求参数

返回值

类型:Promise<GetCredentialListResult>
增值服务凭证数组,每项包含有效期、状态、计量规则、额度使用情况和关联订单信息

引用对象

typeGetCredentialListResult查询用户服务凭证结果
ServiceCredential[]

示例代码

请求示例

import { getCredentialList } from '@tuya-miniapp/cloud-api';

getCredentialList({
  catalogCode: 'your_catalog_code',
})
  .then(credentials => {
    console.log('服务凭证:', credentials);
  })
  .catch(error => {
    console.error('查询服务凭证失败:', error);
  });

返回示例

[
  {
    "catalogCode": "your_catalog_code",
    "externalCode": "your_external_code",
    "effectiveStartDate": 1699977600000,
    "effectiveEndDate": 1731600000000,
    "objectType": 3,
    "objectId": "your_user_id",
    "state": 2,
    "usageState": "using",
    "metering": {
      "meteringType": 1,
      "meteringUnit": 10,
      "quotaPeriodUnit": 0,
      "quota": 10000
    },
    "performance": {
      "consumeType": 1,
      "consumeInCurrentMonth": true
    },
    "quotaUsage": {
      "leftQuantity": 9000,
      "usedQuantity": 1000
    },
    "order": {
      "orderId": "your_order_id",
      "commodityCode": "your_commodity_code",
      "skuCode": "your_sku_code",
      "subscribeOrder": true
    }
  }
]