-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
user.go
48 lines (40 loc) · 1.01 KB
/
user.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
package lark
// UID types
const (
UIDEmail = "email"
UIDUserID = "user_id"
UIDOpenID = "open_id"
UIDChatID = "chat_id"
UIDUnionID = "union_id"
)
// OptionalUserID to contain openID, chatID, userID, email
type OptionalUserID struct {
UIDType string
RealID string
}
func withOneID(uidType, realID string) *OptionalUserID {
return &OptionalUserID{
UIDType: uidType,
RealID: realID,
}
}
// WithEmail uses email as userID
func WithEmail(email string) *OptionalUserID {
return withOneID(UIDEmail, email)
}
// WithUserID uses userID as userID
func WithUserID(userID string) *OptionalUserID {
return withOneID(UIDUserID, userID)
}
// WithOpenID uses openID as userID
func WithOpenID(openID string) *OptionalUserID {
return withOneID(UIDOpenID, openID)
}
// WithChatID uses chatID as userID
func WithChatID(chatID string) *OptionalUserID {
return withOneID(UIDChatID, chatID)
}
// WithUnionID uses chatID as userID
func WithUnionID(unionID string) *OptionalUserID {
return withOneID(UIDUnionID, unionID)
}