-
Notifications
You must be signed in to change notification settings - Fork 152
/
deviceClient.go
109 lines (76 loc) · 3.16 KB
/
deviceClient.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
package wifi
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/officialAccount/wifi/response"
)
type DeviceClient struct {
*kernel.BaseClient
}
func NewDeviceClient(app kernel.ApplicationInterface) (*DeviceClient, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &DeviceClient{
baseClient,
}, nil
}
// 调用此接口向指定门店添加密码型设备的 Wi-Fi 信息
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Devices_Management/Adding_password-protected_devices.html
func (comp *DeviceClient) AddPasswordDevice(shopID int, ssid string, password string) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
params := &object.HashMap{
"shop_id": shopID,
"ssid": ssid,
"password": password,
}
_, err := comp.HttpPostJson("bizwifi/device/add", params, nil, nil, result)
return result, err
}
// 调用此接口向指定门店添加密码型设备的 Wi-Fi 信息
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Devices_Management/Adding_password-protected_devices.html
func (comp *DeviceClient) AddPortalDevice(shopID int, ssid string, reset string) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
params := &object.HashMap{
"shop_id": shopID,
"ssid": ssid,
"reset": reset,
}
_, err := comp.HttpPostJson("bizwifi/apportal/register", params, nil, nil, result)
return result, err
}
// 调用此接口向指定门店删除密码型设备的 Wi-Fi 信息
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Devices_Management/Adding_password-protected_devices.html
func (comp *DeviceClient) Delete(macAddress string) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
params := &object.HashMap{
"bssid": macAddress,
}
_, err := comp.HttpPostJson("bizwifi/device/delete", params, nil, nil, result)
return result, err
}
// 调用此接口向指定门店添加密码型设备的 Wi-Fi 信息
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Devices_Management/Query_devices.html
func (comp *DeviceClient) List(page int, size int) (*response.ResponseWifiDeviceList, error) {
result := &response.ResponseWifiDeviceList{}
params := &object.HashMap{
"pageindex": page,
"pagesize": size,
}
_, err := comp.HttpPostJson("bizwifi/device/List", params, nil, nil, result)
return result, err
}
// 调用此接口向指定门店添加密码型设备的 Wi-Fi 信息
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Devices_Management/Query_devices.html
func (comp *DeviceClient) listByShopID(shopID int, page int, size int) (*response.ResponseWifiDeviceList, error) {
result := &response.ResponseWifiDeviceList{}
params := &object.HashMap{
"shop_id": shopID,
"pageindex": page,
"pagesize": size,
}
_, err := comp.HttpPostJson("bizwifi/device/List", params, nil, nil, result)
return result, err
}