Skip to content

Commit

Permalink
Added Create Contact
Browse files Browse the repository at this point in the history
  • Loading branch information
kariudo committed Feb 5, 2015
1 parent c454e87 commit 6593fce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ primary feature development still in progress, see below for current status:
* Get Contacts

### Todo :
* Create Contacts
* Set User preferences
* Subscriptions
* Web Sockets
Expand Down
13 changes: 13 additions & 0 deletions gopushbullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"log"
"net/http"
"net/url"
)

//Error (any non-200 error code) contain information on the kind of error that happened.
Expand Down Expand Up @@ -383,6 +384,18 @@ func (c *Client) GetContacts() (ContactList, error) {
return l, err
}

//CreateContact creates a new contact with the specified name and email
func (c *Client) CreateContact(name, email string) error {
u := url.Values{}
u.Add("name", name)
u.Add("email", email)
_, err := c.HTTPClient.PostForm(c.BaseURL+"contacts", u)
if err != nil {
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 6593fce

Please sign in to comment.