-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathemergency.js
executable file
·53 lines (44 loc) · 1.56 KB
/
emergency.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
'use strict';
let chump = require('../lib/Chump');
let config = require('./config.json');
let client = new chump.Client(config.api_token);
let user = new chump.User(config.user_id, config.user_device);
let message = new chump.Message({
title: 'The roof is on fire!',
message: '<b>Put it out immediately!</b>',
enableHtml: true,
user: user,
priority: new chump.Priority('emergency'),
sound: new chump.Sound('siren')
})
console.log('Sending emergency message...');
client.sendMessage(message)
.then(receipt => {
console.log(`Retrieving receipt ${receipt}`);
return client.getReceipt(receipt);
})
.then(receipt => {
console.log(`Receipt: ${receipt.id}`);
console.log(`Acknowledged: ${receipt.isAcknowledged}`);
console.log(`Acknowledged by: ${receipt.acknowledgedBy}`);
console.log(`Last delivered at: ${receipt.lastDeliveredAt}`);
console.log(`Is expired: ${receipt.isExpired}`);
console.log(`Expires at: ${receipt.expiresAt}`);
console.log(`Has called back: ${receipt.hasCalledBack}`);
console.log(`Called back at: ${receipt.calledBackAt}`);
return receipt;
})
.then(receipt => {
console.log(`Cancelling emergency using receipt ${receipt.id}`);
return client.cancelEmergency(receipt.id);
})
.then(() => {
console.log(`Displaying app info:`);
console.log(`App limit: ${client.appLimit}`);
console.log(`App remaining: ${client.appRemaining}`);
console.log(`App reset: ${client.appReset}`);
})
.catch(error => {
console.log(error.stack);
});