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

Commit

Permalink
Merge pull request #7 from eparis/new-helpers
Browse files Browse the repository at this point in the history
New functions AddComment and Attachment
  • Loading branch information
VojtechVitek committed Dec 14, 2015
2 parents 002ec26 + 57262ce commit 241f5b8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ func (c *Card) Attachments() (attachments []Attachment, err error) {
return
}

// Attachment will return the specified attachment on the card
// https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-attachments-idattachment
func (c *Card) Attachment(attachmentId string) (*Attachment, error) {
body, err := c.client.Get("/cards/" + c.Id + "/attachments/" + attachmentId)
if err != nil {
return nil, err
}

attachment := &Attachment{}
err = json.Unmarshal(body, attachment)
attachment.client = c.client
return attachment, err
}

func (c *Card) Actions() (actions []Action, err error) {
body, err := c.client.Get("/cards/" + c.Id + "/actions")
if err != nil {
Expand Down Expand Up @@ -155,3 +169,13 @@ func (c *Card) AddChecklist(name string) (*Checklist, error) {
// the new list has no items, no need to walk those adding client
return newList, err
}

// AddComment will add a new comment to the card
// https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-actions-comments
func (c *Card) AddComment(text string) ([]byte, error) {
payload := url.Values{}
payload.Set("text", text)

body, err := c.client.Post("/cards/"+c.Id+"/actions/comments", payload)
return body, err
}

0 comments on commit 241f5b8

Please sign in to comment.