Skip to content

Commit

Permalink
Add get contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
kariudo committed Feb 5, 2015
1 parent 0e3977b commit c454e87
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ primary feature development still in progress, see below for current status:
* Checklist
* File
* Get Devices
* Get Contacts

### Todo :
* Set User preferences
* Contacts
* Subscriptions
* Web Sockets
* Upload Requests (upload files)
Expand Down
20 changes: 20 additions & 0 deletions gopushbullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ type Contact struct {
Active bool `json:"active"`
}

//ContactList describes an array of contacts
type ContactList struct {
Contacts []Contact `json:"contacts"`
}

//Subscription describes a channel subscription.
type Subscription struct {
ID string `json:"iden"`
Expand Down Expand Up @@ -363,6 +368,21 @@ func (c *Client) GetDevices() (DeviceList, error) {
return d, nil
}

//GetContacts obtains a list of your contacts
func (c *Client) GetContacts() (ContactList, error) {
var l ContactList
res, apiError, err := c.makeCall("GET", "contacts", nil)
if err != nil {
log.Println("Failed to get contacts: ", err, apiError.String())
return l, err
}
err = json.Unmarshal(res, &l)
if err != nil {
return l, err
}
return l, err
}

func (c *Client) makeCall(method string, call string, data interface{}) (responseBody []byte, apiError *Error, err error) {
// make sure API key seems ok
if len(c.APIKey) == 0 {
Expand Down

0 comments on commit c454e87

Please sign in to comment.