-
Notifications
You must be signed in to change notification settings - Fork 4
/
modify_folder.go
50 lines (40 loc) · 1.24 KB
/
modify_folder.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 wrike
import (
"fmt"
"strings"
"github.com/AkihikoITOH/wrike.go/parameters"
types "github.com/AkihikoITOH/wrike.go/types"
"github.com/google/go-querystring/query"
)
// ModifyFolder modifiies a folder with given parameters.
// For details refer to https://developers.wrike.com/documentation/api/methods/modify-folder
func (api *API) ModifyFolder(id types.FolderID, params parameters.ModifyFolder) (*types.Folders, error) {
path := fmt.Sprintf("/folders/%s", id)
body, err := query.Values(params)
if err != nil {
return nil, err
}
data, err := api.put(path, &body)
if err != nil {
return nil, err
}
return types.NewFoldersFromJSON(data)
}
// ModifyFolders modifiies folders with given parameters.
// For details refer to https://developers.wrike.com/documentation/api/methods/modify-folder
func (api *API) ModifyFolders(ids []types.FolderID, params parameters.ModifyFolders) (*types.Folders, error) {
s := make([]string, 0, len(ids))
for _, id := range ids {
s = append(s, string(id))
}
path := fmt.Sprintf("/folders/%s", strings.Join(s, ","))
body, err := query.Values(params)
if err != nil {
return nil, err
}
data, err := api.put(path, &body)
if err != nil {
return nil, err
}
return types.NewFoldersFromJSON(data)
}