-
Notifications
You must be signed in to change notification settings - Fork 155
/
client.go
63 lines (46 loc) · 1.92 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package tester
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
response2 "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/tester/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/tester/response"
)
type Client struct {
BaseClient *kernel.BaseClient
}
func NewClient(app *kernel.ApplicationInterface) (*Client, error) {
baseClient, err := kernel.NewBaseClient(app, nil)
if err != nil {
return nil, err
}
return &Client{
baseClient,
}, nil
}
// 绑定微信用户为体验者
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/Admin.html
func (comp *Client) Bind(ctx context.Context, wechatID string) (*response.ResponseBind, error) {
result := &response.ResponseBind{}
_, err := comp.BaseClient.HttpPostJson(ctx, "wxa/bind_tester", &object.HashMap{
"wechatid": wechatID,
}, nil, nil, result)
return result, err
}
// 解除绑定体验者
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/unbind_tester.html
func (comp *Client) Unbind(ctx context.Context, params *request.RequestUnbind) (*response2.ResponseOpenPlatform, error) {
result := &response2.ResponseOpenPlatform{}
_, err := comp.BaseClient.HttpPostJson(ctx, "wxa/unbind_tester", params, nil, nil, result)
return result, err
}
// 获取体验者列表
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/memberauth.html
func (comp *Client) List(ctx context.Context) (*response.ResponseList, error) {
result := &response.ResponseList{}
_, err := comp.BaseClient.HttpPostJson(ctx, "wxa/memberauth", &object.HashMap{
"action": "get_experiencer",
}, nil, nil, result)
return result, err
}