forked from CatchZeng/dingtalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
link.go
45 lines (39 loc) · 861 Bytes
/
link.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
package dingtalk
import "encoding/json"
// LinkMessage link message struct
type LinkMessage struct {
MsgType MsgType `json:"msgtype"`
Link Link `json:"link"`
}
// Link link struct
type Link struct {
Title string `json:"title"`
Text string `json:"text"`
PicURL string `json:"picUrl"`
MessageURL string `json:"messageUrl"`
}
// ToByte to byte
func (m *LinkMessage) ToByte() ([]byte, error) {
m.MsgType = MsgTypeLink
jsonByte, err := json.Marshal(m)
return jsonByte, err
}
// NewLinkMessage new message
func NewLinkMessage() *LinkMessage {
msg := LinkMessage{}
return &msg
}
// SetLink set link
func (m *LinkMessage) SetLink(
title string,
text string,
picURL string,
messageURL string) *LinkMessage {
m.Link = Link{
Title: title,
Text: text,
PicURL: picURL,
MessageURL: messageURL,
}
return m
}