Skip to content

Commit

Permalink
Get subscriptions list
Browse files Browse the repository at this point in the history
  • Loading branch information
kariudo committed Feb 6, 2015
1 parent 7ecd0cd commit 8428734
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gopushbullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ type Subscription struct {
Channel Channel `json:"channel"`
}

//SubscriptionList describes a list of subscribed channels
type SubscriptionList struct {
Subscriptions []Subscription `json:"subscriptions"`
}

//Channel describes a channel on a subscription.
type Channel struct {
ID string `json:"iden"`
Expand Down Expand Up @@ -427,6 +432,20 @@ func (c *Client) SubscribeChannel(channel string) error {
return nil
}

//ListSubscriptions returns a list of channels to which the user is subscribed
func (c *Client) ListSubscriptions() (subscriptions SubscriptionList, err error) {
responseBody, apiError, err := c.makeCall("GET", "subscriptions", nil)
if err != nil {
log.Println("Failed to add subscription: ", err, apiError.String())
return
}
err = json.Unmarshal(responseBody, &subscriptions)
if err != nil {
return
}
return
}

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 8428734

Please sign in to comment.