-
Notifications
You must be signed in to change notification settings - Fork 174
/
media.go
52 lines (39 loc) · 881 Bytes
/
media.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
package messages
import (
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
)
type Media struct {
*Message
}
func NewMedia(mediaID string, sType string, items *power.HashMap) *Media {
data := power.MergeHashMap(&power.HashMap{
"media_id": mediaID,
}, items)
m := &Media{
NewMessage(data),
}
m.SetType(sType)
m.Properties = []string{
"media_id",
}
m.SetAttribute("required", []string{
"media_id",
})
m.OverrideToXmlArray()
return m
}
func (msg *Media) GetMediaID() string {
_ = msg.CheckRequiredAttributes()
return msg.GetString("media_id", "")
}
// Override ToXmlArray
func (msg *Media) OverrideToXmlArray() {
msg.ToXmlArray = func() *object.HashMap {
return &object.HashMap{
object.Studly(msg.GetType()): &object.HashMap{
"MediaId": msg.GetString("media_id", ""),
},
}
}
}