-
Notifications
You must be signed in to change notification settings - Fork 4
/
application.go
96 lines (84 loc) · 2.56 KB
/
application.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package ganboard
import "encoding/json"
// GetVersion https://docs.kanboard.org/en/latest/api/application_procedures.html#getversion
func (c *Client) GetVersion() (string, error) {
query := request{
Client: c,
Method: "getVersion",
}
response, err := query.decodeString()
return response, err
}
// GetTimezone https://docs.kanboard.org/en/latest/api/application_procedures.html#gettimezone
func (c *Client) GetTimezone() (string, error) {
query := request{
Client: c,
Method: "getTimezone",
}
response, err := query.decodeString()
return response, err
}
// GetDefaultTaskColors https://docs.kanboard.org/en/latest/api/application_procedures.html#getDefaultTaskColors
func (c *Client) GetDefaultTaskColors() (map[string]Color, error) {
query := request{
Client: c,
Method: "getDefaultTaskColors",
}
response, err := query.decodeTaskColors()
return response, err
}
// GetDefaultTaskColor https://docs.kanboard.org/en/latest/api/application_procedures.html#getDefaultTaskColor
func (c *Client) GetDefaultTaskColor() (string, error) {
query := request{
Client: c,
Method: "getDefaultTaskColor",
}
response, err := query.decodeString()
return response, err
}
// GetColorList https://docs.kanboard.org/en/latest/api/application_procedures.html#getColorList
func (c *Client) GetColorList() (map[string]string, error) {
query := request{
Client: c,
Method: "getColorList",
}
response, err := query.decodeMapStringString()
return response, err
}
// GetApplicationRoles https://docs.kanboard.org/en/latest/api/application_procedures.html#getApplicationRoles
func (c *Client) GetApplicationRoles() (map[string]string, error) {
query := request{
Client: c,
Method: "getApplicationRoles",
}
response, err := query.decodeMapStringString()
return response, err
}
// GetProjectRoles https://docs.kanboard.org/en/latest/api/application_procedures.html#getProjectRoles
func (c *Client) GetProjectRoles() (map[string]string, error) {
query := request{
Client: c,
Method: "getProjectRoles",
}
response, err := query.decodeMapStringString()
return response, err
}
// Color definition
type Color struct {
Name string `json:"name"`
Background string `json:"background"`
Border string `json:"border"`
}
func (r *request) decodeTaskColors() (map[string]Color, error) {
rsp, err := r.Client.Request(*r)
if err != nil {
return nil, err
}
body := struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Result map[string]Color `json:"result"`
}{}
err = json.NewDecoder(rsp.Body).Decode(&body)
return body.Result, err
}