Skip to content

Commit

Permalink
Add un/muteSubscription functions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwhitman committed Jan 4, 2016
1 parent 9c3649e commit 99151b9
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Rename `updatePush` to `dismissPush`.
- Add `updateDevice` function.
- Change signature of `createDevice` to take an Object of device options.
- Add `muteSubscription` and `unmuteSubscription` functions.

### 1.4.3

Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ Subscribe to a channel.
pusher.unsubscribe('udprOsjAsLtNTRAG', function(error, response) {});
```

### PushBullet.muteSubscription(subscriptionIden, callback)

Mute a subscription.

```javascript
pusher.muteSubscription('udprOsjAsLtNTRAG', function(error, response) {});
```

### PushBullet.unmuteSubscription(subscriptionIden, callback)

Mute a subscription.

```javascript
pusher.unmuteSubscription('udprOsjAsLtNTRAG', function(error, response) {});
```

### PushBullet.channelInfo(channelTag, callback)

Get information about a channel.
Expand Down
43 changes: 43 additions & 0 deletions lib/pushbullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,49 @@ PushBullet.prototype.unsubscribe = function unsubscribe(subscriptionIden, callba
});
};

/**
* Mute a subscription.
*
* @param {String} subscriptionIden The iden of the subscription to mute.
* @param {Function} callback Called when the request is complete.
*/
PushBullet.prototype.muteSubscription = function muteSubscription(subscriptionIden, callback) {
this.updateSubscription(subscriptionIden, { muted: true }, callback);
};

/**
* Unmute subscription.
*
* @param {String} subscriptionIden The iden of the subscription to unmute.
* @param {Function} callback Called when the request is complete.
*/
PushBullet.prototype.unmuteSubscription = function unmuteSubscription(subscriptionIden, callback) {
this.updateSubscription(subscriptionIden, { muted: false }, callback);
};

/**
* Update a subscription.
*
* @param {String} subscriptionIden The iden of the subscription to ubsubscribe from.
* @param {Object} updates Updates to make to subscription.
* @param {Function} callback Called when the request is complete.
*/
PushBullet.prototype.updateSubscription = function updateSubscription(subscriptionIden, updates, callback) {
var self = this;

if ( ! callback) {
callback = updates;
}

var options = {
json: updates
};

self.request.post(SUBS_END_POINT + '/' + subscriptionIden, options, function(error, response, body) {
self.handleResponse(error, response, body, callback);
});
};

/**
* Get information about a channel.
*
Expand Down

0 comments on commit 99151b9

Please sign in to comment.