-
Notifications
You must be signed in to change notification settings - Fork 146
/
shopClient.go
91 lines (66 loc) · 2.62 KB
/
shopClient.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
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/response"
)
type ShopClient struct {
*kernel.BaseClient
}
func NewShopClient(app kernel.ApplicationInterface) (*ShopClient, error) {
baseClient, err := kernel.NewBaseClient(&app, nil)
if err != nil {
return nil, err
}
return &ShopClient{
baseClient,
}, nil
}
// 查询门店 WiFi 信息接口
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/WiFi_mini_programs.html
func (comp *ShopClient) Get(ctx context.Context, shopID int) (*response.ResponseWifiShopGet, error) {
result := &response.ResponseWifiShopGet{}
params := &object.HashMap{
"shop_id": shopID,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/shop/get", params, nil, nil, result)
return result, err
}
// 通过此接口获取 WiFi 的门店列表
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Stores_management/Get_a_Wi-Fi_store_list.html
func (comp *ShopClient) List(ctx context.Context, page int, size int) (*response.ResponseWifiShopList, error) {
result := &response.ResponseWifiShopList{}
params := &object.HashMap{
"pageindex": page,
"pagesize": size,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/shop/List", params, nil, nil, result)
return result, err
}
// 通过此接口修改门店的网络信息
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Stores_management/Modify_the_store_network_information.html
func (comp *ShopClient) Update(ctx context.Context, shopID int, oldSSID string, ssid string) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
params := &object.HashMap{
"shop_id": shopID,
"old_ssid": oldSSID,
"ssid": ssid,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/shop/update", params, nil, nil, result)
return result, err
}
// 通过此接口清空门店的网络配置及所有设备,恢复空门店状态。
// https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/Stores_management/Empty_the_store_network_and_devices.html
func (comp *ShopClient) ClearDevice(ctx context.Context, shopID int, ssid string) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
params := &object.HashMap{
"shop_id": shopID,
}
if ssid != "" {
(*params)["ssid"] = ssid
}
_, err := comp.BaseClient.HttpPostJson(ctx, "bizwifi/shop/clean", params, nil, nil, result)
return result, err
}