-
Notifications
You must be signed in to change notification settings - Fork 160
/
relationClient.go
70 lines (55 loc) · 2.29 KB
/
relationClient.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
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 RelationClient struct {
BaseClient *kernel.BaseClient
}
func NewRelationClient(app kernel.ApplicationInterface) (*RelationClient, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &RelationClient{
baseClient,
}, nil
}
// 新增摇一摇出来的页面信息
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Pages_management/Page_management.html
func (comp *RelationClient) BindPages(ctx context.Context, data *request.RequestDeviceIdentifier, pageIDs []int) (*response.ResponsePage, error) {
result := &response.ResponsePage{}
params := &object.HashMap{
"device_identifier": data,
"page_ids": pageIDs,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/device/bindpage", params, nil, nil, result)
return result, err
}
// 查询设备与页面的关联关系
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Relationship_between_pages_and_devices/Querying_Device_and_Page_Associations.html
func (comp *RelationClient) ListByDeviceID(ctx context.Context, data *request.RequestDeviceIdentifier) (*response.ResponseRelationSearch, error) {
result := &response.ResponseRelationSearch{}
params := &object.HashMap{
"type": 1,
"device_identifier": data,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/relation/search", params, nil, nil, result)
return result, err
}
// 查询设备与页面的关联关系
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Relationship_between_pages_and_devices/Querying_Device_and_Page_Associations.html
func (comp *RelationClient) ListByPageId(ctx context.Context, pageID int, begin int, count int) (*response.ResponseRelationSearch, error) {
result := &response.ResponseRelationSearch{}
params := &object.HashMap{
"type": 2,
"page_id": pageID,
"begin": begin,
"count": count,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/relation/search", params, nil, nil, result)
return result, err
}