-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnote_builder.go
More file actions
49 lines (40 loc) · 949 Bytes
/
Copy pathnote_builder.go
File metadata and controls
49 lines (40 loc) · 949 Bytes
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
package activitystreams
import "time"
// Note builder
type NoteBuilder struct {
note Note
}
func NewNote() *NoteBuilder {
return &NoteBuilder{
note: Note{Type: "Note"},
}
}
func (nb *NoteBuilder) Content(content string) *NoteBuilder {
nb.note.Content = content
return nb
}
func (nb *NoteBuilder) ContentMap(contentMap map[string]string) *NoteBuilder {
nb.note.ContentMap = contentMap
return nb
}
func (nb *NoteBuilder) MediaType(mediaType string) *NoteBuilder {
nb.note.MediaType = mediaType
return nb
}
func (nb *NoteBuilder) Published(t *time.Time) *NoteBuilder {
nb.note.Published = t
return nb
}
func (nb *NoteBuilder) To(urls ...string) *NoteBuilder {
if len(urls) > 0 {
targets := make(ObjectOrLink, len(urls))
for i, url := range urls {
targets[i] = Link{Type: "Link", Href: url}
}
nb.note.To = &ObjectOrLinkOrString{Target: targets}
}
return nb
}
func (nb *NoteBuilder) Build() *Note {
return &nb.note
}