forked from VojtechVitek/go-trello
-
Notifications
You must be signed in to change notification settings - Fork 3
/
label.go
44 lines (36 loc) · 828 Bytes
/
label.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
package trello
import (
"net/url"
"encoding/json"
)
type Label struct {
client *Client
Id string `json:"id"`
IdBoard string `json:"idBoard"`
Name string `json:"name"`
Color string `json:"color"`
Uses int `json:"uses"`
}
func (l *Label) UpdateName(name string) (err error) {
payload := url.Values{}
payload.Set("value", name)
body, err := l.client.Put("/labels/" + l.Id + "/name", payload)
if err != nil {
return
}
return json.Unmarshal(body, l)
}
//Color can be null
func (l *Label) UpdateColor(color string) (err error) {
payload := url.Values{}
payload.Set("value", color)
body, err := l.client.Put("/labels/" + l.Id + "/color", payload)
if err != nil {
return
}
return json.Unmarshal(body, l)
}
func (l *Label) DeleteLabel() error {
_, err := l.client.Delete("/labels/" + l.Id)
return err
}