DescribeTemplates.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package essapi
  2. import (
  3. "fmt"
  4. "mtp2_if/logger"
  5. "mtp2_if/utils"
  6. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
  7. essbasic "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/essbasic/v20210526"
  8. )
  9. func DescribeTemplates(agent *essbasic.Agent, templateName *string) (response *essbasic.DescribeTemplatesResponse, err error) {
  10. if utils.TencentESSClient == nil {
  11. err = fmt.Errorf("腾讯电子签客户端未初始化")
  12. logger.GetLogger().Errorf("DescribeTemplates failed: %s", err.Error())
  13. return
  14. }
  15. // 实例化一个请求对象,每个接口都会对应一个request对象
  16. request := essbasic.NewDescribeTemplatesRequest()
  17. request.Agent = agent
  18. if templateName != nil {
  19. request.TemplateName = templateName
  20. }
  21. // 返回的resp是一个DescribeTemplatesResponse的实例,与请求对象对应
  22. response, err = utils.TencentESSClient.DescribeTemplates(request)
  23. if _, ok := err.(*errors.TencentCloudSDKError); ok {
  24. logger.GetLogger().Errorf("DescribeTemplates failed: %s", err.Error())
  25. err = fmt.Errorf("电子签请求失败")
  26. return
  27. }
  28. return
  29. }