-
Notifications
You must be signed in to change notification settings - Fork 156
/
client.go
52 lines (36 loc) · 1.69 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
package base
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/base/response"
)
type Client struct {
BaseClient *kernel.BaseClient
}
// https://developers.weixin.qq.com/doc/offiaccount/Message_Management/API_Call_Limits.html
func (comp *Client) ClearQuota(ctx context.Context) (*response2.ResponseOfficialAccount, error) {
result := &response2.ResponseOfficialAccount{}
config := (*comp.BaseClient.App).GetConfig()
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/clear_quota", &object.HashMap{
"appid": config.GetString("app_id", ""),
}, nil, nil, result)
return result, err
}
// https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html#2.%20%E8%8E%B7%E5%8F%96%E5%BE%AE%E4%BF%A1callback%20IP%E5%9C%B0%E5%9D%80
func (comp *Client) GetCallbackIP(ctx context.Context) (*response.ResponseGetCallBackIP, error) {
result := &response.ResponseGetCallBackIP{}
_, err := comp.BaseClient.HttpGet(ctx, "cgi-bin/getcallbackip", nil, nil, result)
return result, err
}
// https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Network_Detection.html
func (comp *Client) CheckCallbackURL(ctx context.Context, action string, checkOperator string) (*response.ResponseGetAPIDomainIP, error) {
result := &response.ResponseGetAPIDomainIP{}
options := &object.HashMap{
"action": action,
"check_operator": checkOperator,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/callbacks/check", options, nil, nil, result)
return result, err
}