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

Commit

Permalink
Add Card.Attachments() method
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVitek committed Aug 30, 2014
1 parent 6cd5195 commit 3ea2af8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,30 @@ func (c *Card) Members() (members []Member, err error) {
}
return
}

func (c *Card) Attachments() (attachments []Attachment, err error) {
req, err := http.NewRequest("GET", c.client.endpoint+"/cards/"+c.Id+"/attachments", nil)
if err != nil {
return
}

resp, err := c.client.client.Do(req)
if err != nil {
return
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
} else if resp.StatusCode != 200 {
err = fmt.Errorf("Received unexpected status %d while trying to retrieve the server data", resp.StatusCode)
return
}

err = json.Unmarshal(body, &attachments)
for i, _ := range attachments {
attachments[i].client = c.client
}
return
}

0 comments on commit 3ea2af8

Please sign in to comment.