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.getuserriskrank.go

43 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package wechatopen
import (
"context"
"github.com/dtapps/go-library/utils/gojson"
"github.com/dtapps/go-library/utils/gorequest"
"net/http"
)
type WxaGetUserRiskRankResponse struct {
Errcode int `json:"errcode"` // 错误码
Errmsg string `json:"errmsg"` // 错误信息
RiskRank int `json:"risk_rank"` // 用户风险等级合法值为0,1,2,3,4数字越大风险越高。
UnoinId int64 `json:"unoin_id"` // 唯一请求标识,标记单次请求
}
type WxaGetUserRiskRankResult struct {
Result WxaGetUserRiskRankResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newWxaGetUserRiskRankResult(result WxaGetUserRiskRankResponse, body []byte, http gorequest.Response) *WxaGetUserRiskRankResult {
return &WxaGetUserRiskRankResult{Result: result, Body: body, Http: http}
}
// WxaGetUserRiskRank 获取用户安全等级
// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/sec-center/safety-control-capability/getUserRiskRank.html
func (c *Client) WxaGetUserRiskRank(ctx context.Context, authorizerAppid, authorizerAccessToken string, notMustParams ...gorequest.Params) (*WxaGetUserRiskRankResult, error) {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
params.Set("appid", authorizerAppid)
// 请求
request, err := c.request(ctx, apiUrl+"/wxa/getuserriskrank?access_token="+authorizerAccessToken, params, http.MethodPost)
if err != nil {
return newWxaGetUserRiskRankResult(WxaGetUserRiskRankResponse{}, request.ResponseBody, request), err
}
// 定义
var response WxaGetUserRiskRankResponse
err = gojson.Unmarshal(request.ResponseBody, &response)
return newWxaGetUserRiskRankResult(response, request.ResponseBody, request), err
}