You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/service/wechatopen/wxa.deletetemplate.go

50 lines
1.7 KiB

2 years ago
package wechatopen
import (
2 years ago
"context"
1 year ago
"github.com/dtapps/go-library/utils/gojson"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
2 years ago
"net/http"
)
type WxaDeleteTemplateResponse struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
}
type WxaDeleteTemplateResult struct {
Result WxaDeleteTemplateResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
2 years ago
}
2 years ago
func newWxaDeleteTemplateResult(result WxaDeleteTemplateResponse, body []byte, http gorequest.Response) *WxaDeleteTemplateResult {
return &WxaDeleteTemplateResult{Result: result, Body: body, Http: http}
2 years ago
}
// WxaDeleteTemplate 删除指定代码模板
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/deletetemplate.html
func (c *Client) WxaDeleteTemplate(ctx context.Context, componentAccessToken, templateId string, notMustParams ...gorequest.Params) (*WxaDeleteTemplateResult, error) {
2 years ago
// 参数
params := gorequest.NewParamsWith(notMustParams...)
2 years ago
params.Set("template_id", templateId)
// 请求
request, err := c.request(ctx, apiUrl+"/wxa/deletetemplate?access_token="+componentAccessToken, params, http.MethodPost)
2 years ago
if err != nil {
return newWxaDeleteTemplateResult(WxaDeleteTemplateResponse{}, request.ResponseBody, request), err
2 years ago
}
2 years ago
// 定义
var response WxaDeleteTemplateResponse
1 year ago
err = gojson.Unmarshal(request.ResponseBody, &response)
return newWxaDeleteTemplateResult(response, request.ResponseBody, request), err
2 years ago
}
// ErrcodeInfo 错误描述
func (resp *WxaDeleteTemplateResult) ErrcodeInfo() string {
switch resp.Result.Errcode {
case 85064:
return "找不到模板请检查模板id是否输入正确"
}
return "系统繁忙"
}