-
Notifications
You must be signed in to change notification settings - Fork 174
/
pageClient.go
77 lines (56 loc) · 2.28 KB
/
pageClient.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
68
69
70
71
72
73
74
75
76
77
package shakeAround
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/shakeAround/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/shakeAround/response"
)
type PageClient struct {
BaseClient *kernel.BaseClient
}
func NewPageClient(app kernel.ApplicationInterface) (*PageClient, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &PageClient{
baseClient,
}, nil
}
// 新增摇一摇出来的页面信息
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Pages_management/Page_management.html
func (comp *PageClient) Create(ctx context.Context, data *request.RequestPageInfo) (*response.ResponsePage, error) {
result := &response.ResponsePage{}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/page/add", data, nil, nil, result)
return result, err
}
// 编辑摇一摇出来的页面信息
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Pages_management/Edit_page_information.html
func (comp *PageClient) Update(ctx context.Context, data request.RequestPageUpdate) (*response.ResponsePage, error) {
result := &response.ResponsePage{}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/page/update", data, nil, nil, result)
return result, err
}
// 更新设备分组
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Pages_management/Query_page_list.html
func (comp *PageClient) List(ctx context.Context, begin int, count int) (*response.ResponsePageList, error) {
result := &response.ResponsePageList{}
params := &object.HashMap{
"type": 2,
"begin": begin,
"count": count,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/page/search", params, nil, nil, result)
return result, err
}
// 删除已有的页面
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Pages_management/Delete_page.html
func (comp *PageClient) Delete(ctx context.Context, pageID string) (*response.ResponsePage, error) {
result := &response.ResponsePage{}
params := &object.HashMap{
"page_id": pageID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/page/delete", params, nil, nil, result)
return result, err
}