forked from nukosuke/go-zendesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
credential.go
55 lines (46 loc) · 1.31 KB
/
credential.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 zendesk
// Credential is interface of API credential
type Credential interface {
Email() string
Secret() string
}
// BasicAuthCredential is type of credential for Basic authentication
type BasicAuthCredential struct {
email string
password string
}
// NewBasicAuthCredential creates BasicAuthCredential and returns its pointer
func NewBasicAuthCredential(email string, password string) *BasicAuthCredential {
return &BasicAuthCredential{
email: email,
password: password,
}
}
// Email is accessor which returns email address
func (c BasicAuthCredential) Email() string {
return c.email
}
// Secret is accessor which returns password
func (c BasicAuthCredential) Secret() string {
return c.password
}
// APITokenCredential is type of credential for API token authentication
type APITokenCredential struct {
email string
apiToken string
}
// NewAPITokenCredential creates APITokenCredential and returns its pointer
func NewAPITokenCredential(email string, apiToken string) *APITokenCredential {
return &APITokenCredential{
email: email,
apiToken: apiToken,
}
}
// Email is accessor which returns email address
func (c APITokenCredential) Email() string {
return c.email + "/token"
}
// Secret is accessor which returns API token
func (c APITokenCredential) Secret() string {
return c.apiToken
}