Chump - Pushover.net client for Node.js
Chump is a client for the popular Pushover.net real-time notification service.
Use Chump to send Android, iOS, watchOS, and desktop notifications.
Chump makes full use of Pushover.net's API.
Installation
Chump was written for Node.js 4+.
npm install --save chump
Basic Usage
It is easy to send messages via Pushover.net using Chump.
Sending Messages
let chump = ; // Instantiate client with your api tokenlet client = 'yourApiToken'; // Instantiate a destination userlet user = 'userIdHere' 'optionalUserDeviceHere'; // Instantiate a messagelet message = title: 'Example title' message: 'Example message' enableHtml: false user: user url: 'http://example.org' urlTitle: 'Example.org' priority: 'low' sound: 'magic'; // Send the message, handle result within a Promiseclient ;
All client methods that send a command return a Promise.
Sending Messages With Emergency Priority
An emergency priority can be attached to a message. This requires that the message is acknowledged by the user, and can renotify the user on failure to acknowledge. Pushover.net can also call an optional callback URL after the user acknowledges the message. A message receipt is returned to the resolved Promise on successful delivery of emergency priority messages.
let priority = 'emergency' retry: 300 // Optional: Notify user every 5 minutes (300 seconds) until acknowledged expire: 3600 // Optional: Expire the message in 1 hour (3600 seconds) callback: 'http://example.org' // Optional: Callback URL; let message = title: 'Example emergency' message: 'Super important message' user: user priority: priority; client ;
Advanced Usage
Chump supports the entire Pushover.net API. The client offers convenience methods that correspond to each Pushover.net endpoint.
As documented earlier, all client methods that send a command return a Promise.
.verifyUser
Verify that a user (and optionally, the user's device) exists on Pushover.net
let user = 'userIdHere' 'optionalUserDeviceHere'; // Verify the user existsclient ;
.getReceipt
Additional receipt information can be retrieved from Pushover.net. Receipts are only returned for messages sent with an emergency priority.
client ;
.cancelEmergency
A message with an emergency priority can be cancelled.
client;
.getGroupDetails
Pushover.net supports managing users within groups. Creating groups can only be done through Pushover.net's website. Assuming you know the group Id, you can use Chump to retrieve information for the group from Pushover.net.
let group = groupId; client ;
.addUserToGroup
Add a user to a known group.
let user = userId;let group = groupId; client;
.removeUserFromGroup
Remove a user from a known group.
let user = userId;let group = groupId; client;
.enableGroupUser
Enable a user in a known group.
let user = userId;let group = groupId; client;
.disableGroupUser
Disable a user in a known group.
let user = userId;let group = groupId; client;
.renameGroup
Rename a known group.
let group = groupId; client;
Track Application Limitations
Pushover.net limits the number of messages emitted from its service. Chump keeps track of these limitations after each successful message sent. You can access app limitations from the following client properties:
// Maximum number of messages that can be sentlet appLimit = clientappLimit; // Number of messages remaining in time periodlet appRemaining = clientappRemaining; // Date when app remaining resets to app limitlet appReset = clientappReset;
Examples
Want to see more examples? View them in the examples directory included in this repository.
Logo
Chump's initial logo was designed by scorpion6 on Fiverr. Font used is Lato Bold.
License
This software is licensed under the MIT License. View the license.
Copyright © 2015 Michael K. Squires