Skip to content
This repository was archived by the owner on Apr 2, 2022. It is now read-only.

Commit ad6249f

Browse files
committed
Allow cards to get closed (archived)
1 parent 4a7db23 commit ad6249f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

card.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,12 @@ func (c *Card) AddComment(text string) ([]byte, error) {
179179
body, err := c.client.Post("/cards/"+c.Id+"/actions/comments", payload)
180180
return body, err
181181
}
182+
183+
// Archive will archive the card
184+
// https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink-closed
185+
func (c *Card) Archive() ([]byte, error) {
186+
payload := url.Values{}
187+
payload.Set("value", "true")
188+
189+
return c.client.Put("/cards/"+c.Id+"/closed", payload)
190+
}

client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ func (c *Client) Post(resource string, data url.Values) ([]byte, error) {
6666
return c.do(req)
6767
}
6868

69+
func (c *Client) Put(resource string, data url.Values) ([]byte, error) {
70+
req, err := http.NewRequest("PUT", c.endpoint+resource, strings.NewReader(data.Encode()))
71+
if err != nil {
72+
return nil, err
73+
}
74+
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
75+
76+
return c.do(req)
77+
}
78+
6979
func (c *Client) Delete(resource string) ([]byte, error) {
7080
req, err := http.NewRequest("DELETE", c.endpoint+resource, nil)
7181
if err != nil {

0 commit comments

Comments
 (0)