get-packages-statistics.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (C) 2020 Tencent Cloud.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. 'use strict';
  17. const { request } = require('./utils');
  18. const { appId } = require('./config');
  19. /**
  20. * 获取腾讯云SMS产品套餐包状态
  21. * @param {object} params - 参数包装对象
  22. * @param {number} params.limit - 最大上限(需要拉取的套餐包个数)
  23. * @return {Promise<object>} 短信套餐包状态信息,详见文档 https://cloud.tencent.com/document/api/382/39533
  24. */
  25. async function getPackagesStatistics({ limit = 10 }) {
  26. // 配置校验
  27. if (!appId) {
  28. throw new Error('请在云函数SMS模块中配置appId');
  29. }
  30. // 调用腾讯云查询SMS状态接口
  31. const result = await request('SmsPackagesStatistics', {
  32. SmsSdkAppid: appId,
  33. Limit: limit,
  34. Offset: 0
  35. });
  36. return result;
  37. }
  38. module.exports = getPackagesStatistics;