-
Notifications
You must be signed in to change notification settings - Fork 165
/
client.go
66 lines (47 loc) · 2.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
package shakeAround
import (
"context"
"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 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
}
// 申请开通摇一摇周边功能
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Apply/Application_for_opening_function.html
func (comp *Client) Register(ctx context.Context, data *request.RequestShakeAroundAccountRegister) (*response.ResponseShakeAroundAccountRegister, error) {
result := &response.ResponseShakeAroundAccountRegister{}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/account/register", data, nil, nil, result)
return result, err
}
// 查询审核状态
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Apply/Application_for_opening_function.html
func (comp *Client) Status(ctx context.Context) (*response.ResponseShakeAroundAccountRegister, error) {
result := &response.ResponseShakeAroundAccountRegister{}
_, err := comp.BaseClient.HttpGet(ctx, "shakearound/account/auditstatus", nil, nil, result)
return result, err
}
// 获取设备信息
// https://developers.weixin.qq.com/doc/offiaccount/Shake_Nearby/Getting_Device_and_User_Information.html
func (comp *Client) User(ctx context.Context, data *request.RequestShakeAroundUser) (*response.ResponseShakeAroundUser, error) {
result := &response.ResponseShakeAroundUser{}
_, err := comp.BaseClient.HttpPostJson(ctx, "shakearound/user/getshakeinfo", data, nil, nil, result)
return result, err
}
func (comp *Client) UserWithPoi(ctx context.Context, ticket string) (*response.ResponseShakeAroundUser, error) {
data := &request.RequestShakeAroundUser{
Ticket: ticket,
NeedPoi: 1,
}
return comp.User(ctx, data)
}