1
0
mirror of https://github.com/nikoksr/notify.git synced 2024-12-04 09:43:04 +02:00
notify/service/lark/common.go

59 lines
1.6 KiB
Go
Raw Normal View History

2022-06-04 20:25:23 +02:00
package lark
// sender is an interface for sending a message to an already defined receiver.
type sender interface {
Send(subject, message string) error
}
// sender is an interface for sending a message to a specific receiver ID.
type sendToer interface {
SendTo(subject, message, id, idType string) error
}
// receiverID encapsulates a receiver ID and its type in Lark.
type receiverID struct {
id string
typ receiverIDType
}
// OpenID specifies an ID as a Lark Open ID.
func OpenID(s string) *receiverID {
return &receiverID{s, openID}
}
// UserID specifies an ID as a Lark User ID.
func UserID(s string) *receiverID {
return &receiverID{s, userID}
}
// UnionID specifies an ID as a Lark Union ID.
func UnionID(s string) *receiverID {
return &receiverID{s, unionID}
}
// Email specifies a receiver ID as an email.
func Email(s string) *receiverID {
return &receiverID{s, email}
}
// ChatID specifies an ID as a Lark Chat ID.
func ChatID(s string) *receiverID {
return &receiverID{s, chatID}
}
// receiverIDType represents the different ID types implemented by Lark. This
// information is required when sending a message. More information about the
// different ID types can be found in the "Query parameters" section of
// the https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create,
// or on
// https://open.larksuite.com/document/home/user-identity-introduction/introduction.
type receiverIDType string
const (
openID receiverIDType = "open_id"
userID = "user_id"
unionID = "union_id"
email = "email"
chatID = "chat_id"
)