-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.go
62 lines (49 loc) · 1.38 KB
/
config.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
package teambitionapi
import "time"
type Options struct {
baseUrl string //https://open.teambition.com/api
orgId string //企业ID
appID string
appSecret string
tokenExpies int64 //token过期时间
isCacheToken bool //是否缓存token
tokenCacheExecutor TokenCacheExecutor //token缓存执行器
}
func NewOptions(orgId, appId, appSecret string) *Options {
return &Options{
baseUrl: "https://open.teambition.com/api",
orgId: orgId,
appID: appId,
appSecret: appSecret,
tokenExpies: 1 * 3600 * 1000,
isCacheToken: true,
tokenCacheExecutor: &DefaultTokenCacheExecutor{},
}
}
func (c *Options) SetBaseUrl(baseUrl string) {
c.baseUrl = baseUrl
}
func (c *Options) SetTokenExpies(tokenExpies int64) {
c.tokenExpies = tokenExpies
}
func (c *Options) SetIsCacheToken(isCacheToken bool) {
c.isCacheToken = isCacheToken
}
func (c *Options) SetTokenCacheExecutor(tokenCacheExecutor TokenCacheExecutor) {
c.tokenCacheExecutor = tokenCacheExecutor
}
func (c *Options) GetBaseUrl() string {
return c.baseUrl
}
func (c *Options) GetOrgId() string {
return c.orgId
}
func (c *Options) GetAppId() string {
return c.appID
}
func (c *Options) GetAppSecret() string {
return c.appSecret
}
func (c *Options) GetTokenExpies() time.Duration {
return time.Duration(c.tokenExpies)
}