-
Notifications
You must be signed in to change notification settings - Fork 157
/
client.go
89 lines (63 loc) · 3.02 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
package wifi
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/officialAccount/wifi/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount/wifi/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
}
// 查询一定时间范围内的 WiFi 连接总人数、微信方式连 Wi-Fi 人数、商家主页访问人数、连网后消息发送人数、新增公众号关注人数和累计公众号关注人数。
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Wi-Fi_data_statistics.html
func (comp *Client) Summary(ctx context.Context, beginDate string, endDate string, shopID int) (*response.ResponseWifiSummary, error) {
result := &response.ResponseWifiSummary{}
params := &object.HashMap{
"begin_date": beginDate,
"end_date": endDate,
"shop_id": shopID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/statistics/list", params, nil, nil, result)
return result, err
}
// 添加设备后,通过此接口可以获取物料。
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Connecting/Get_materials_QR_Code.html
func (comp *Client) GetQrCodeUrl(ctx context.Context, bShopID int, ssid string, ImageID int) (*response.ResponseWifiQrCodeURL, error) {
result := &response.ResponseWifiQrCodeURL{}
params := &object.HashMap{
"shop_id": bShopID,
"ssid": ssid,
"img_id": ImageID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/qrcode/get", params, nil, nil, result)
return result, err
}
// 当顾客使用微信连 Wi-Fi 方式连网成功时,点击页面右上角“完成”按钮,即可进入已设置的连网完成页。
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Home_Page_management/Set_up_the_Wi-Fi_Connection_Completion_page.html
func (comp *Client) SetFinishPage(ctx context.Context, bShopID int, finishPageURL string) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
params := &object.HashMap{
"shop_id": bShopID,
"finishpage_url": finishPageURL,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/finishpage/set", params, nil, nil, result)
return result, err
}
// 设置商户主页后,点击微信聊首页欢迎语,即可进入设置的商户主页。
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Home_Page_management/Set_up_a_merchant_home_page.html
func (comp *Client) SetHomePage(ctx context.Context, data *request.RequestWifiSetHomePage) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/homepage/set", data, nil, nil, result)
return result, err
}