-
Notifications
You must be signed in to change notification settings - Fork 0
/
wecom.go
83 lines (69 loc) · 2.26 KB
/
wecom.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
package wecom
import (
"github.com/EricJSanchez/wecom/application"
"github.com/EricJSanchez/wecom/config"
"github.com/EricJSanchez/wecom/contact"
"github.com/EricJSanchez/wecom/context"
"github.com/EricJSanchez/wecom/conversation"
"github.com/EricJSanchez/wecom/credential"
"github.com/EricJSanchez/wecom/externalcontact"
"github.com/EricJSanchez/wecom/material"
"github.com/EricJSanchez/wecom/message"
"github.com/EricJSanchez/wecom/oauth"
"github.com/EricJSanchez/wecom/platform"
)
type Wecom struct {
ctx *context.Context
}
func NewWecom(cfg *config.Config) *Wecom {
defaultAkHandle := credential.NewWorkAccessToken(cfg.CorpID, cfg.CorpSecret, credential.CacheKeyWorkPrefix, cfg.Cache)
ctx := &context.Context{
Config: cfg,
AccessTokenHandle: defaultAkHandle,
}
return &Wecom{ctx: ctx}
}
// GetContext get Context
func (w *Wecom) GetContext() *context.Context {
return w.ctx
}
// GetContact get contact
func (w *Wecom) GetContact() (*contact.Client, error) {
return contact.NewClient(w.ctx.Config)
}
// GetApplication get application
func (w *Wecom) GetApplication() (*application.Client, error) {
return application.NewClient(w.ctx.Config)
}
// GetExternalContact get external contact
func (w *Wecom) GetExternalContact() (*externalcontact.Client, error) {
return externalcontact.NewClient(w.ctx.Config)
}
// GetConversation get conversation
func (w *Wecom) GetConversation() (*conversation.Client, error) {
return conversation.NewClient(w.ctx.Config)
}
// GetOAuth get oauth
func (w *Wecom) GetOAuth() (*oauth.Client, error) {
return oauth.NewClient(w.ctx.Config)
}
// GetMassage get message
func (w *Wecom) GetMassage() (*message.Client, error) {
return message.NewClient(w.ctx.Config)
}
// GetMaterial get material
func (w *Wecom) GetMaterial() (*material.Client, error) {
return material.NewClient(w.ctx.Config)
}
// GetPlatform 管理后台的接口
func (w *Wecom) GetPlatform() (*platform.Client, error) {
return platform.NewClient(w.ctx.Config)
}
//
//func (w *Wework) GetTicket() (*credential.WeworkTicket, error) {
// return credential.NewTicket(w.ctx.Config)
//}
//func (w *Wework) GetCredential() (ticket string, err error) {
// accessToken, err := w.ctx.GetAccessToken()
// return credential.NewWeworkJsTicket().GetTicket(accessToken)
//}