-
Notifications
You must be signed in to change notification settings - Fork 2
/
controls.go
54 lines (46 loc) · 1.32 KB
/
controls.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
package coda
import (
"fmt"
"log"
)
type ControlReference struct {
Id string `json:"id"`
Type string `json:"type"`
Href string `json:"href"`
Name string `json:"name"`
Parent PageReference `json:"parent"`
}
type Control struct {
ControlReference
ControlType string `json:"controlType"`
Value interface{} `json:"value"`
}
type ListControlsResponse struct {
Controls []ControlReference `json:"items"`
PaginationResponse
}
type ListControlsPayload struct {
SortBy string `json:"sortBy" url:"sortBy,omitEmpty"`
PaginationPayload
}
type GetControlResponse struct {
Control
}
func (c *Client) ListControls(docId string, payload ListControlsPayload) (ListControlsResponse, error) {
docPath := fmt.Sprintf("docs/%s/controls", docId)
var controlsResp ListControlsResponse
err := c.apiCall("GET", docPath, payload, &controlsResp)
if err != nil {
log.Print("Unable to make api call with error.")
}
return controlsResp, err
}
func (c *Client) GetControl(docId string, controlIdOrName string) (GetControlResponse, error) {
docPath := fmt.Sprintf("docs/%s/controls/%s", docId, controlIdOrName)
var controlResp GetControlResponse
err := c.apiCall("GET", docPath, nil, &controlResp)
if err != nil {
log.Print("Unable to make api call with error.")
}
return controlResp, err
}