-
Notifications
You must be signed in to change notification settings - Fork 147
/
client.go
154 lines (108 loc) · 4.14 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package living
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
response2 "github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/response"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/oa/living/request"
"github.com/ArtisanCloud/PowerWeChat/v2/src/work/oa/living/response"
)
type Client struct {
*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://work.weixin.qq.com/api/doc/90000/90135/93637
func (comp *Client) Create(options *request.RequestLivingCreate) (*response.ResponseLivingCreate, error) {
result := &response.ResponseLivingCreate{}
_, err := comp.HttpPostJson("cgi-bin/living/create", options, nil, nil, result)
return result, err
}
// 修改预约直播
// https://work.weixin.qq.com/api/doc/90000/90135/93640
func (comp *Client) Modify(options *request.RequestLivingModify) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
_, err := comp.HttpPostJson("cgi-bin/living/modify", options, nil, nil, result)
return result, err
}
// 取消预约直播
// https://work.weixin.qq.com/api/doc/90000/90135/93638
func (comp *Client) Cancel(livingID string) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
options := &object.HashMap{
"livingid": livingID,
}
_, err := comp.HttpPostJson("cgi-bin/living/cancel", options, nil, nil, result)
return result, err
}
// 删除直播回放
// https://work.weixin.qq.com/api/doc/90000/90135/93874
func (comp *Client) DeleteReplayData(livingID string) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
options := &object.HashMap{
"livingid": livingID,
}
_, err := comp.HttpPostJson("cgi-bin/living/delete_replay_data", options, nil, nil, result)
return result, err
}
// 在微信中观看直播或直播回放
// https://work.weixin.qq.com/api/doc/90000/90135/93641
func (comp *Client) GetLivingCode(livingID string, openID string) (*response.ResponseLivingGetLivingCode, error) {
result := &response.ResponseLivingGetLivingCode{}
options := &object.HashMap{
"livingid": livingID,
"openid": openID,
}
_, err := comp.HttpPostJson("cgi-bin/living/get_living_code", options, nil, nil, result)
return result, err
}
// 获取成员直播ID列表
// https://work.weixin.qq.com/api/doc/90000/90135/93634
func (comp *Client) GetUserAllLivingID(userID string, cursor string, limit int) (*response.ResponseLivingGetUserAllLivingID, error) {
result := &response.ResponseLivingGetUserAllLivingID{}
options := &object.HashMap{
"userid": userID,
"cursor": cursor,
"limit": limit,
}
_, err := comp.HttpPostJson("cgi-bin/living/get_user_all_livingid", options, nil, nil, result)
return result, err
}
// 获取直播详情
// https://work.weixin.qq.com/api/doc/90000/90135/93635
func (comp *Client) GetLivingInfo(livingID string) (*response.ResponseLivingGetLivingInfo, error) {
result := &response.ResponseLivingGetLivingInfo{}
options := &object.HashMap{
"livingid": livingID,
}
_, err := comp.HttpPostJson("cgi-bin/living/get_living_info", options, nil, nil, result)
return result, err
}
// 获取直播观看明细
// https://work.weixin.qq.com/api/doc/90000/90135/93636
func (comp *Client) GetWatchStat(livingID string, nextKey string) (*response.ResponseLivingGetWatchStat, error) {
result := &response.ResponseLivingGetWatchStat{}
options := &object.HashMap{
"livingid": livingID,
"next_key": nextKey,
}
_, err := comp.HttpPostJson("cgi-bin/living/get_watch_stat", options, nil, nil, result)
return result, err
}
// 获取跳转小程序商城的直播观众信息
// https://work.weixin.qq.com/api/doc/90000/90135/94442
func (comp *Client) GetLivingShareInfo(wwShareCode string) (*response.ResponseLivingGetLivingShareInfo, error) {
result := &response.ResponseLivingGetLivingShareInfo{}
options := &object.HashMap{
"ww_share_code": wwShareCode,
}
_, err := comp.HttpPostJson("cgi-bin/living/get_living_share_info", options, nil, nil, result)
return result, err
}