-
Notifications
You must be signed in to change notification settings - Fork 158
/
client.go
52 lines (39 loc) · 1.62 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 domain
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/openPlatform/authorizer/miniProgram/domain/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openPlatform/authorizer/miniProgram/domain/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/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/Server_Address_Configuration.html#请求地址
func (comp *Client) Modify(ctx context.Context, params *request.RequestModify) (*response.ResponseModify, error) {
result := &response.ResponseModify{}
_, err := comp.BaseClient.HttpPostJson(ctx, "wxa/modify_domain", params, nil, nil, result)
return result, err
}
// 设置业务域名
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/setwebviewdomain.html#请求地址
func (comp *Client) SetWebviewDomain(ctx context.Context, domains []string, action string) (*response2.ResponseOpenPlatform, error) {
result := &response2.ResponseOpenPlatform{}
params := &object.HashMap{
"action": action,
"webviewdomain": domains,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "wxa/setwebviewdomain", params, nil, nil, result)
return result, err
}