-
Notifications
You must be signed in to change notification settings - Fork 80
/
campaign_folders.go
50 lines (38 loc) · 1.04 KB
/
campaign_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 (
campaign_folders_path = "/campaign-folders"
// single folder endpoint not implemented
)
type CampaignFolderQueryParams struct {
ExtendedQueryParams
}
type ListOfCampaignFolders struct {
baseList
Folders []CampaignFolder `json:"folders"`
}
type CampaignFolder struct {
withLinks
Name string `json:"name"`
ID string `json:"id"`
Count uint `json:"count"`
api *API
}
type CampaignFolderCreationRequest struct {
Name string `json:"name"`
}
func (api *API) GetCampaignFolders(params *CampaignFolderQueryParams) (*ListOfCampaignFolders, error) {
response := new(ListOfCampaignFolders)
err := api.Request("GET", campaign_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) CreateCampaignFolder(body *CampaignFolderCreationRequest) (*CampaignFolder, error) {
response := new(CampaignFolder)
response.api = api
return response, api.Request("POST", campaign_folders_path, nil, body, response)
}