-
Notifications
You must be signed in to change notification settings - Fork 174
/
client.go
67 lines (48 loc) · 2.05 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
64
65
66
67
package privacy
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/privacy/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/privacy/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/privacy_config/get_privacy_setting.html#请求地址
func (comp *Client) Get(ctx context.Context) (*response.ResponseGet, error) {
result := &response.ResponseGet{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/component/getprivacysetting", nil, nil, nil, result)
return result, err
}
// 配置小程序用户隐私保护指引
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/set_privacy_setting.html
func (comp *Client) Set(ctx context.Context, params *request.RequestSet) (*response2.ResponseOpenPlatform, error) {
result := &response2.ResponseOpenPlatform{}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/component/setprivacysetting", params, nil, nil, result)
return result, err
}
// 上传小程序用户隐私保护指引
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/upload_privacy_exfile.html#请求地址
func (comp *Client) Upload(ctx context.Context, path string) (*response.ResponseUpload, error) {
result := &response.ResponseUpload{}
var files *object.HashMap
if path != "" {
files = &object.HashMap{
"file": path,
}
}
_, err := comp.BaseClient.HttpUpload(ctx, "cgi-bin/component/uploadprivacyextfile", files, nil, nil, nil, result)
return result, err
}