-
Notifications
You must be signed in to change notification settings - Fork 0
/
referents.go
79 lines (73 loc) · 2.77 KB
/
referents.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package genius
type ReferentsService service
type Referent struct {
Type string `json:"_type,omitempty"`
AnnotatorID int `json:"annotator_id,omitempty"`
AnnotatorLogin string `json:"annotator_login,omitempty"`
ApiPath string `json:"api_path,omitempty"`
Classification string `json:"classification,omitempty"`
Featured bool `json:"featured,omitempty"`
Fragment string `json:"fragment,omitempty"`
ID int `json:"id,omitempty"`
IsDescription bool `json:"is_description,omitempty"`
Path string `json:"path,omitempty"`
Range *struct {
Start string `json:"start,omitempty"`
StartOffset string `json:"startOffset,omitempty"`
End string `json:"end,omitempty"`
EndOffset string `json:"endOffset,omitempty"`
Before string `json:"before,omitempty"`
After string `json:"after,omitempty"`
Content string `json:"content,omitempty"`
} `json:"range,omitempty"`
SongID int `json:"song_id,omitempty"`
URL string `json:"url,omitempty"`
VerifiedAnnotatorIDs []int `json:"verified_annotator_ids,omitempty"`
Annotatable *struct {
ApiPath string `json:"api_path,omitempty"`
Context string `json:"context,omitempty"`
ID int `json:"id,omitempty"`
ImageURL string `json:"image_url,omitempty"`
LinkTitle string `json:"link_title,omitempty"`
Title string `json:"title,omitempty"`
Type string `json:"type,omitempty"`
URL string `json:"url,omitempty"`
} `json:"annotatable,omitempty"`
Annotations []Annotation `json:"annotations,omitempty"`
}
type ReferentsParams struct {
WebPageID int `url:"web_page_id,omitempty"`
CreatedByID int `url:"create_by_id,omitempty"`
SongID int `url:"song_id,omitempty"`
TextFormat string `url:"text_format,omitempty"`
}
func (s *ReferentsService) GetBySongID(ID int) ([]Referent, error) {
var err error
params := &ReferentsParams{SongID: ID, TextFormat: "plain"}
res := new(ApiResponse)
s.client.base.Get("referents").QueryStruct(params).Receive(res, err)
if err != nil {
return nil, err
}
return res.Response.Referents, nil
}
func (s *ReferentsService) GetByUserID(ID int) ([]Referent, error) {
var err error
params := &ReferentsParams{CreatedByID: ID, TextFormat: "plain"}
res := new(ApiResponse)
s.client.base.Get("referents").QueryStruct(params).Receive(res, err)
if err != nil {
return nil, err
}
return res.Response.Referents, nil
}
func (s *ReferentsService) GetByWebPageID(ID int) ([]Referent, error) {
var err error
params := &ReferentsParams{WebPageID: ID, TextFormat: "plain"}
res := new(ApiResponse)
s.client.base.Get("referents").QueryStruct(params).Receive(res, err)
if err != nil {
return nil, err
}
return res.Response.Referents, nil
}