-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for SMS, clipboard and dismissal
- Loading branch information
1 parent
ca8affe
commit e75096a
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var clone = require('clone'); | ||
|
||
var PushBullet = require('../pushbullet'); | ||
|
||
/** | ||
* Send an SMS. | ||
* | ||
* The options require source_user_iden, target_device_iden, conversation_iden and message. | ||
* See https://docs.pushbullet.com/#send-sms for details. | ||
* | ||
* @param {Object} smsOptions SMS options. | ||
* @param {Function} callback Callback for when the request is complete. | ||
*/ | ||
PushBullet.prototype.sendSMS = function sendSMS(smsOptions, callback) { | ||
var options = clone(smsOptions); | ||
|
||
options.package_name = 'com.pushbullet.android'; | ||
options.type = 'messaging_extension_reply'; | ||
|
||
this.sendEphemeral(options, callback); | ||
}; | ||
|
||
/** | ||
* Send clipboard content. | ||
* | ||
* The options require body, source_user_iden and source_device_iden. | ||
* See https://docs.pushbullet.com/#universal-copypaste for details. | ||
* | ||
* @param {Object} clipOptions Clipboard options. | ||
* @param {Function} callback Callback for when the request is complete. | ||
*/ | ||
PushBullet.prototype.sendClipboard = function sendClipboard(clipOptions, callback) { | ||
var options = clone(clipOptions); | ||
|
||
options.type = 'clip'; | ||
|
||
this.sendEphemeral(options, callback); | ||
}; | ||
|
||
/** | ||
* Dismiss an ephemeral. | ||
* | ||
* The options require package_name, notification_id, notification_tag and source_user_iden. | ||
* See https://docs.pushbullet.com/#dismissal-ephemeral for details. | ||
* | ||
* @param {Object} ephemerealOptions Ephemeral dismissal options. | ||
* @param {Function} callback Callback for when the request is complete. | ||
*/ | ||
PushBullet.prototype.dismissEphemeral = function dismissEphemeral(ephemerealOptions, callback) { | ||
var options = clone(ephemerealOptions); | ||
|
||
options.type = 'dismissal'; | ||
|
||
this.sendEphemeral(options, callback); | ||
}; | ||
|
||
/** | ||
* Send an ephemeral. | ||
* | ||
* @param {Object} ephemerealOptions Ephemeral options. | ||
* @param {Function} callback Callback for when the request is complete. | ||
*/ | ||
PushBullet.prototype.sendEphemeral = function sendEphemeral(ephemerealOptions, callback) { | ||
var self = this; | ||
|
||
var options = { | ||
json: { | ||
type: 'push', | ||
push: ephemerealOptions | ||
} | ||
}; | ||
|
||
self.request.post(PushBullet.EPHEMERALS_END_POINT, options, function(error, response, body) { | ||
self.handleResponse(error, response, body, callback); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"author": "Alex Whitman <[email protected]>", | ||
"license": "BSD", | ||
"dependencies": { | ||
"clone": "^1.0.2", | ||
"mime": "~1.2.11", | ||
"request": "~2.44.0", | ||
"websocket": "~1.0.8" | ||
|