forked from adlio/trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.go
58 lines (50 loc) · 1.23 KB
/
list.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
// Copyright © 2016 Aaron Longwell
//
// Use of this source code is governed by an MIT licese.
// Details in the LICENSE file.
package trello
import (
"fmt"
"time"
)
type List struct {
client *Client
ID string `json:"id"`
Name string `json:"name"`
IDBoard string `json:"idBoard,omitempty"`
Closed bool `json:"closed"`
Pos float32 `json:"pos,omitempty"`
Board *Board `json:"board,omitempty"`
Cards []*Card `json:"cards,omitempty"`
}
func (l *List) CreatedAt() time.Time {
t, _ := IDToTime(l.ID)
return t
}
func (c *Client) GetList(listID string, args Arguments) (list *List, err error) {
path := fmt.Sprintf("lists/%s", listID)
err = c.Get(path, args, &list)
if list != nil {
list.client = c
}
return
}
func (b *Board) GetLists(args Arguments) (lists []*List, err error) {
path := fmt.Sprintf("boards/%s/lists", b.ID)
err = b.client.Get(path, args, &lists)
for i := range lists {
lists[i].client = b.client
}
return
}
func (b *Board) CreateList(name string, args Arguments) (list *List, err error) {
path := fmt.Sprintf("lists")
args["name"] = name
args["idBoard"] = b.ID
err = b.client.Post(path, args, &list)
if err != nil {
return nil, err
}
list.client = b.client
return list, nil
}