forked from go-lark/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_notification.go
41 lines (35 loc) · 1.2 KB
/
api_notification.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
package lark
// PostNotificationResp response of PostNotification
type PostNotificationResp struct {
Ok bool `json:"ok,omitempty"`
}
// PostNotificationV2Resp response of PostNotificationV2
type PostNotificationV2Resp struct {
BaseResponse
StatusCode int `json:"StatusCode"`
StatusMessage string `json:"StatusMessage"`
}
// PostNotification send message to a webhook
// deprecated: legacy version, please use PostNotificationV2 instead
func (bot *Bot) PostNotification(title, text string) (*PostNotificationResp, error) {
if !bot.requireType(NotificationBot) {
return nil, ErrBotTypeError
}
params := map[string]interface{}{
"title": title,
"text": text,
}
var respData PostNotificationResp
err := bot.PostAPIRequest("PostNotification", bot.webhook, false, params, &respData)
return &respData, err
}
// PostNotificationV2 support v2 format
func (bot *Bot) PostNotificationV2(om OutcomingMessage) (*PostNotificationV2Resp, error) {
if !bot.requireType(NotificationBot) {
return nil, ErrBotTypeError
}
params := buildOutcomingNotification(om)
var respData PostNotificationV2Resp
err := bot.PostAPIRequest("PostNotificationV2", bot.webhook, false, params, &respData)
return &respData, err
}