-
Notifications
You must be signed in to change notification settings - Fork 151
/
client.go
55 lines (41 loc) · 1.19 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
package jssdk
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/basicService/jssdk"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
response2 "github.com/ArtisanCloud/PowerWeChat/v3/src/work/jssdk/response"
)
type Client struct {
*jssdk.Client
}
func NewClient(app *kernel.ApplicationInterface) (*Client, error) {
jssdkClient, err := jssdk.NewClient(app)
if err != nil {
return nil, err
}
client := &Client{
jssdkClient,
}
config := (*app).GetConfig()
baseURI := config.GetString("http.base_uri", "/")
client.TicketEndpoint = baseURI + "/cgi-bin/get_jsapi_ticket"
client.OverrideGetAppID()
return client, nil
}
func (comp *Client) OverrideGetAppID() {
comp.GetAppID = func() string {
config := (*comp.BaseClient.App).GetConfig()
return config.GetString("corp_id", "")
}
}
func (comp *Client) GetAgentConfigArray() {
}
func (comp *Client) GetTicket(ctx context.Context) (*response2.ResponseGetTicket, error) {
result := &response2.ResponseGetTicket{}
params := &object.StringMap{
"type": "agent_config",
}
_, err := comp.BaseClient.HttpGet(ctx, "cgi-bin/ticket/get", params, nil, result)
return result, err
}