-
Notifications
You must be signed in to change notification settings - Fork 5
/
media.go
43 lines (36 loc) · 904 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
package whatsapp
var (
MediaAudio = "audio"
MediaDocument = "document"
MediaImage = "image"
MediaSticker = "sticker"
MediaVideo = "video"
)
type Media struct {
File string `json:"file"`
IsItAnID bool `json:"is_it_an_id"`
Type string `json:"type"`
api *API
}
type MediaId struct {
Type string `json:"type"`
Id string `json:"id"`
api *API
}
type MediaLink struct {
Type string `json:"type"`
Link string `json:"link"`
api *API
}
func (obj *Media) ToId() *MediaId {
return &MediaId{api: obj.api, Type: obj.Type, Id: obj.File}
}
func (obj *Media) ToLink() *MediaLink {
return &MediaLink{api: obj.api, Type: obj.Type, Link: obj.File}
}
func (m *MediaLink) ToMedia() *Media {
return &Media{api: m.api, Type: m.Type, File: m.Link, IsItAnID: false}
}
func (m *MediaId) ToMedia() *Media {
return &Media{api: m.api, Type: m.Type, File: m.Id, IsItAnID: true}
}