-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathtemplate_folders.go
50 lines (38 loc) · 1.04 KB
/
template_folders.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
package gochimp3
const (
template_folders_path = "/template-folders"
// single folder endpoint not implemented
)
type TemplateFolderQueryParams struct {
ExtendedQueryParams
}
type ListOfTemplateFolders struct {
baseList
Folders []TemplateFolder `json:"folders"`
}
type TemplateFolder struct {
withLinks
Name string `json:"name"`
ID string `json:"id"`
Count uint `json:"count"`
api *API
}
type TemplateFolderCreationRequest struct {
Name string `json:"name"`
}
func (api *API) GetTemplateFolders(params *TemplateFolderQueryParams) (*ListOfTemplateFolders, error) {
response := new(ListOfTemplateFolders)
err := api.Request("GET", template_folders_path, params, nil, response)
if err != nil {
return nil, err
}
for _, l := range response.Folders {
l.api = api
}
return response, nil
}
func (api *API) CreateTemplateFolder(body *TemplateFolderCreationRequest) (*TemplateFolder, error) {
response := new(TemplateFolder)
response.api = api
return response, api.Request("POST", template_folders_path, nil, body, response)
}