Skip to content

Commit

Permalink
Update and delete contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
kariudo committed Feb 6, 2015
1 parent 3f2115d commit 0c9cab9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ primary feature development still in progress, see below for current status:
* Get Devices
* Get Contacts
* Create Contacts
* Update Contact
* Delete Contact

### Todo :
* Update Contact
* Set User preferences
* Subscriptions
* Web Sockets
Expand Down
21 changes: 21 additions & 0 deletions gopushbullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,27 @@ func (c *Client) CreateContact(name, email string) error {
return nil
}

//UpdateContact creates a new contact with the specified name and email
func (c *Client) UpdateContact(contactID, name string) error {
u := url.Values{}
u.Add("name", name)
_, err := c.HTTPClient.PostForm(c.BaseURL+"contacts/"+contactID, u)
if err != nil {
return err
}
return nil
}

//DeleteContact creates a new contact with the specified name and email
func (c *Client) DeleteContact(contactID string) error {
_, apiError, err := c.makeCall("DELETE", "contacts/"+contactID, nil)
if err != nil {
log.Println("Failed to delete contact: ", err, apiError.String())
return err
}
return nil
}

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 0c9cab9

Please sign in to comment.