-
Notifications
You must be signed in to change notification settings - Fork 1
/
board.go
71 lines (63 loc) · 1.26 KB
/
board.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
package monday
import (
"encoding/json"
"fmt"
"io"
)
func BoardQuery(boardID string) Query {
return Query{
Wrap: true,
Object: "boards",
Where: map[string]string{
"ids": boardID},
Select: Queries{
{Object: "name"},
{Object: "state"},
{Object: "columns", Select: Queries{
{Object: "id"},
{Object: "title"},
{Object: "type"},
}},
{Object: "owner", Select: Queries{
{Object: "id"},
}},
{Object: "items", Select: Queries{
{Object: "id"},
{Object: "name"},
{Object: "state"},
{Object: "column_values", Select: Queries{
{Object: "title"},
{Object: "id"},
{Object: "value"},
{Object: "text"},
}},
}},
},
}
}
/*
gql := "query {
boards (ids: 12345) {
name
columns { id title type }
owner {id}
items{id name state column_values {title id value text } } state
}
}"
*/
func QueryBoard(c Client, boardID string) (*Response, error) {
gql := BoardQuery(boardID)
httpResp, err := c.DoGraphQL(gql)
if err != nil {
return nil, err
}
if httpResp.StatusCode >= 300 {
return nil, fmt.Errorf("http status code [%d]", httpResp.StatusCode)
}
data, err := io.ReadAll(httpResp.Body)
if err != nil {
return nil, err
}
var brds Response
return &brds, json.Unmarshal(data, &brds)
}