pushy 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/device/info.js +15 -11
- package/api/device/presence.js +16 -12
- package/api/pubsub/subscribe.js +16 -12
- package/api/pubsub/subscribers.js +15 -11
- package/api/pubsub/topics.js +15 -11
- package/api/pubsub/unsubscribe.js +16 -12
- package/api/push/delete.js +15 -11
- package/api/push/send.js +16 -12
- package/api/push/status.js +15 -11
- package/index.d.ts +56 -9
- package/package.json +2 -3
package/api/device/info.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Device Info API
|
|
5
4
|
module.exports = function (deviceToken, callback) {
|
|
@@ -20,17 +19,14 @@ module.exports = function (deviceToken, callback) {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
// Make a request to the Device Info API
|
|
23
|
-
|
|
22
|
+
axios(
|
|
24
23
|
Object.assign({
|
|
25
|
-
|
|
24
|
+
url: that.getApiEndpoint() + '/devices/' + deviceToken + '?api_key=' + that.apiKey,
|
|
26
25
|
method: 'GET',
|
|
27
26
|
json: true
|
|
28
|
-
}, that.extraRequestOptions || {})
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
// Send to callback
|
|
32
|
-
return reject(err);
|
|
33
|
-
}
|
|
27
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
28
|
+
// API response
|
|
29
|
+
var body = res.data;
|
|
34
30
|
|
|
35
31
|
// Missing body?
|
|
36
32
|
if (!body) {
|
|
@@ -43,7 +39,7 @@ module.exports = function (deviceToken, callback) {
|
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
// Check for 200 OK
|
|
46
|
-
if (res.
|
|
42
|
+
if (res.status != 200) {
|
|
47
43
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
48
44
|
}
|
|
49
45
|
|
|
@@ -59,6 +55,14 @@ module.exports = function (deviceToken, callback) {
|
|
|
59
55
|
// Resolve the promise
|
|
60
56
|
resolve(deviceInfo);
|
|
61
57
|
}
|
|
58
|
+
}).catch(function (err) {
|
|
59
|
+
// Invoke callback/reject promise with Pushy error
|
|
60
|
+
if (err.response && err.response.data) {
|
|
61
|
+
reject(err.response.data);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
reject(err);
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
67
|
});
|
|
64
68
|
}
|
package/api/device/presence.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Device Presence API
|
|
5
4
|
module.exports = function (deviceTokens, callback) {
|
|
@@ -40,17 +39,14 @@ module.exports = function (deviceTokens, callback) {
|
|
|
40
39
|
postData.tokens = deviceTokens;
|
|
41
40
|
|
|
42
41
|
// Make a request to the Device Presence API
|
|
43
|
-
|
|
42
|
+
axios(
|
|
44
43
|
Object.assign({
|
|
45
|
-
|
|
44
|
+
url: that.getApiEndpoint() + '/devices/presence' + '?api_key=' + that.apiKey,
|
|
46
45
|
method: 'POST',
|
|
47
|
-
|
|
48
|
-
}, that.extraRequestOptions || {})
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
// Send to callback
|
|
52
|
-
return reject(err);
|
|
53
|
-
}
|
|
46
|
+
data: postData
|
|
47
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
48
|
+
// API response
|
|
49
|
+
var body = res.data;
|
|
54
50
|
|
|
55
51
|
// Missing body?
|
|
56
52
|
if (!body) {
|
|
@@ -63,7 +59,7 @@ module.exports = function (deviceTokens, callback) {
|
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
// Check for 200 OK
|
|
66
|
-
if (res.
|
|
62
|
+
if (res.status != 200) {
|
|
67
63
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
68
64
|
}
|
|
69
65
|
|
|
@@ -79,6 +75,14 @@ module.exports = function (deviceTokens, callback) {
|
|
|
79
75
|
// Resolve the promise
|
|
80
76
|
resolve(devicePresence);
|
|
81
77
|
}
|
|
78
|
+
}).catch(function (err) {
|
|
79
|
+
// Invoke callback/reject promise with Pushy error
|
|
80
|
+
if (err.response && err.response.data) {
|
|
81
|
+
reject(err.response.data);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
reject(err);
|
|
85
|
+
}
|
|
82
86
|
});
|
|
83
87
|
});
|
|
84
88
|
}
|
package/api/pubsub/subscribe.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Pub/Sub Subscribe API
|
|
5
4
|
module.exports = function (topics, deviceToken, callback) {
|
|
@@ -34,17 +33,14 @@ module.exports = function (topics, deviceToken, callback) {
|
|
|
34
33
|
postData.topics = Array.isArray(topics) ? topics : [topics];
|
|
35
34
|
|
|
36
35
|
// Make a request to the Pub/Sub Subscribe API
|
|
37
|
-
|
|
36
|
+
axios(
|
|
38
37
|
Object.assign({
|
|
39
|
-
|
|
38
|
+
url: that.getApiEndpoint() + '/topics/subscribe/' + '?api_key=' + that.apiKey,
|
|
40
39
|
method: 'POST',
|
|
41
|
-
|
|
42
|
-
}, that.extraRequestOptions || {})
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
// Send to callback
|
|
46
|
-
return reject(err);
|
|
47
|
-
}
|
|
40
|
+
data: postData
|
|
41
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
42
|
+
// API response
|
|
43
|
+
var body = res.data;
|
|
48
44
|
|
|
49
45
|
// Missing body?
|
|
50
46
|
if (!body) {
|
|
@@ -57,7 +53,7 @@ module.exports = function (topics, deviceToken, callback) {
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
// Check for 200 OK
|
|
60
|
-
if (res.
|
|
56
|
+
if (res.status != 200) {
|
|
61
57
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
62
58
|
}
|
|
63
59
|
|
|
@@ -70,6 +66,14 @@ module.exports = function (topics, deviceToken, callback) {
|
|
|
70
66
|
// Resolve the promise successfully
|
|
71
67
|
resolve();
|
|
72
68
|
}
|
|
69
|
+
}).catch(function (err) {
|
|
70
|
+
// Invoke callback/reject promise with Pushy error
|
|
71
|
+
if (err.response && err.response.data) {
|
|
72
|
+
reject(err.response.data);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
reject(err);
|
|
76
|
+
}
|
|
73
77
|
});
|
|
74
78
|
});
|
|
75
79
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Pub/Sub Subscribers API
|
|
5
4
|
module.exports = function (topic, callback) {
|
|
@@ -20,17 +19,14 @@ module.exports = function (topic, callback) {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
// Make a request to the Pub/Sub Subscribers API
|
|
23
|
-
|
|
22
|
+
axios(
|
|
24
23
|
Object.assign({
|
|
25
|
-
|
|
24
|
+
url: that.getApiEndpoint() + '/topics/' + topic + '?api_key=' + that.apiKey,
|
|
26
25
|
method: 'GET',
|
|
27
26
|
json: true
|
|
28
|
-
}, that.extraRequestOptions || {})
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
// Send to callback
|
|
32
|
-
return reject(err);
|
|
33
|
-
}
|
|
27
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
28
|
+
// API response
|
|
29
|
+
var body = res.data;
|
|
34
30
|
|
|
35
31
|
// Missing body?
|
|
36
32
|
if (!body) {
|
|
@@ -43,7 +39,7 @@ module.exports = function (topic, callback) {
|
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
// Check for 200 OK
|
|
46
|
-
if (res.
|
|
42
|
+
if (res.status != 200) {
|
|
47
43
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
48
44
|
}
|
|
49
45
|
|
|
@@ -59,6 +55,14 @@ module.exports = function (topic, callback) {
|
|
|
59
55
|
// Resolve the promise
|
|
60
56
|
resolve(body);
|
|
61
57
|
}
|
|
58
|
+
}).catch(function (err) {
|
|
59
|
+
// Invoke callback/reject promise with Pushy error
|
|
60
|
+
if (err.response && err.response.data) {
|
|
61
|
+
reject(err.response.data);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
reject(err);
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
67
|
});
|
|
64
68
|
}
|
package/api/pubsub/topics.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Pub/Sub Topics API
|
|
5
4
|
module.exports = function (callback) {
|
|
@@ -15,17 +14,14 @@ module.exports = function (callback) {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
// Make a request to the Pub/Sub Topics API
|
|
18
|
-
|
|
17
|
+
axios(
|
|
19
18
|
Object.assign({
|
|
20
|
-
|
|
19
|
+
url: that.getApiEndpoint() + '/topics/' + '?api_key=' + that.apiKey,
|
|
21
20
|
method: 'GET',
|
|
22
21
|
json: true
|
|
23
|
-
}, that.extraRequestOptions || {})
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
// Send to callback
|
|
27
|
-
return reject(err);
|
|
28
|
-
}
|
|
22
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
23
|
+
// API response
|
|
24
|
+
var body = res.data;
|
|
29
25
|
|
|
30
26
|
// Missing body?
|
|
31
27
|
if (!body) {
|
|
@@ -38,7 +34,7 @@ module.exports = function (callback) {
|
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
// Check for 200 OK
|
|
41
|
-
if (res.
|
|
37
|
+
if (res.status != 200) {
|
|
42
38
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
43
39
|
}
|
|
44
40
|
|
|
@@ -54,6 +50,14 @@ module.exports = function (callback) {
|
|
|
54
50
|
// Resolve the promise
|
|
55
51
|
resolve(body);
|
|
56
52
|
}
|
|
53
|
+
}).catch(function (err) {
|
|
54
|
+
// Invoke callback/reject promise with Pushy error
|
|
55
|
+
if (err.response && err.response.data) {
|
|
56
|
+
reject(err.response.data);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
57
61
|
});
|
|
58
62
|
});
|
|
59
63
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Pub/Sub Unsubscribe API
|
|
5
4
|
module.exports = function (topics, deviceToken, callback) {
|
|
@@ -34,17 +33,14 @@ module.exports = function (topics, deviceToken, callback) {
|
|
|
34
33
|
postData.topics = Array.isArray(topics) ? topics : [topics];
|
|
35
34
|
|
|
36
35
|
// Make a request to the Pub/Sub Unsubscribe API
|
|
37
|
-
|
|
36
|
+
axios(
|
|
38
37
|
Object.assign({
|
|
39
|
-
|
|
38
|
+
url: that.getApiEndpoint() + '/topics/unsubscribe/' + '?api_key=' + that.apiKey,
|
|
40
39
|
method: 'POST',
|
|
41
|
-
|
|
42
|
-
}, that.extraRequestOptions || {})
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
// Send to callback
|
|
46
|
-
return reject(err);
|
|
47
|
-
}
|
|
40
|
+
data: postData
|
|
41
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
42
|
+
// API response
|
|
43
|
+
var body = res.data;
|
|
48
44
|
|
|
49
45
|
// Missing body?
|
|
50
46
|
if (!body) {
|
|
@@ -57,7 +53,7 @@ module.exports = function (topics, deviceToken, callback) {
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
// Check for 200 OK
|
|
60
|
-
if (res.
|
|
56
|
+
if (res.status != 200) {
|
|
61
57
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
62
58
|
}
|
|
63
59
|
|
|
@@ -70,6 +66,14 @@ module.exports = function (topics, deviceToken, callback) {
|
|
|
70
66
|
// Resolve the promise successfully
|
|
71
67
|
resolve();
|
|
72
68
|
}
|
|
69
|
+
}).catch(function (err) {
|
|
70
|
+
// Invoke callback/reject promise with Pushy error
|
|
71
|
+
if (err.response && err.response.data) {
|
|
72
|
+
reject(err.response.data);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
reject(err);
|
|
76
|
+
}
|
|
73
77
|
});
|
|
74
78
|
});
|
|
75
79
|
}
|
package/api/push/delete.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird')
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Notification Deletion API
|
|
5
4
|
module.exports = function (pushId, callback) {
|
|
@@ -30,17 +29,14 @@ module.exports = function (pushId, callback) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
// Make a request to the Notification Deletion API
|
|
33
|
-
|
|
32
|
+
axios(
|
|
34
33
|
Object.assign({
|
|
35
|
-
|
|
34
|
+
url: that.getApiEndpoint() + '/pushes/' + pushId + '?api_key=' + that.apiKey,
|
|
36
35
|
method: 'DELETE',
|
|
37
36
|
json: true
|
|
38
|
-
}, that.extraRequestOptions || {})
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
// Send to callback
|
|
42
|
-
return reject(err);
|
|
43
|
-
}
|
|
37
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
38
|
+
// API response
|
|
39
|
+
var body = res.data;
|
|
44
40
|
|
|
45
41
|
// Missing body?
|
|
46
42
|
if (!body) {
|
|
@@ -53,7 +49,7 @@ module.exports = function (pushId, callback) {
|
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
// Check for 200 OK
|
|
56
|
-
if (res.
|
|
52
|
+
if (res.status != 200) {
|
|
57
53
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
58
54
|
}
|
|
59
55
|
|
|
@@ -66,6 +62,14 @@ module.exports = function (pushId, callback) {
|
|
|
66
62
|
// Resolve the promise
|
|
67
63
|
resolve();
|
|
68
64
|
}
|
|
65
|
+
}).catch(function (err) {
|
|
66
|
+
// Invoke callback/reject promise with Pushy error
|
|
67
|
+
if (err.response && err.response.data) {
|
|
68
|
+
reject(err.response.data);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
reject(err);
|
|
72
|
+
}
|
|
69
73
|
});
|
|
70
74
|
});
|
|
71
75
|
};
|
package/api/push/send.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Send Notifications API
|
|
5
4
|
module.exports = function (data, recipient, options, callback) {
|
|
@@ -59,17 +58,14 @@ module.exports = function (data, recipient, options, callback) {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
// Make a request to the Send Notifications API
|
|
62
|
-
|
|
61
|
+
axios(
|
|
63
62
|
Object.assign({
|
|
64
|
-
|
|
63
|
+
url: that.getApiEndpoint() + '/push?api_key=' + that.apiKey,
|
|
65
64
|
method: 'POST',
|
|
66
|
-
|
|
67
|
-
}, that.extraRequestOptions || {})
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
// Send to callback
|
|
71
|
-
return reject(err);
|
|
72
|
-
}
|
|
65
|
+
data: postData
|
|
66
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
67
|
+
// API response
|
|
68
|
+
var body = res.data;
|
|
73
69
|
|
|
74
70
|
// Missing body?
|
|
75
71
|
if (!body) {
|
|
@@ -82,7 +78,7 @@ module.exports = function (data, recipient, options, callback) {
|
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
// Check for 200 OK
|
|
85
|
-
if (res.
|
|
81
|
+
if (res.status != 200) {
|
|
86
82
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
87
83
|
}
|
|
88
84
|
|
|
@@ -95,6 +91,14 @@ module.exports = function (data, recipient, options, callback) {
|
|
|
95
91
|
// Resolve the promise with response body
|
|
96
92
|
resolve(body);
|
|
97
93
|
}
|
|
94
|
+
}).catch(function (err) {
|
|
95
|
+
// Invoke callback/reject promise with Pushy error
|
|
96
|
+
if (err.response && err.response.data) {
|
|
97
|
+
reject(err.response.data);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
reject(err);
|
|
101
|
+
}
|
|
98
102
|
});
|
|
99
103
|
});
|
|
100
104
|
};
|
package/api/push/status.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Promise = require('bluebird');
|
|
1
|
+
var axios = require('axios');
|
|
3
2
|
|
|
4
3
|
// Notification Status API
|
|
5
4
|
module.exports = function (pushId, callback) {
|
|
@@ -20,17 +19,14 @@ module.exports = function (pushId, callback) {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
// Make a request to the Notification Status API
|
|
23
|
-
|
|
22
|
+
axios(
|
|
24
23
|
Object.assign({
|
|
25
|
-
|
|
24
|
+
url: that.getApiEndpoint() + '/pushes/' + pushId + '?api_key=' + that.apiKey,
|
|
26
25
|
method: 'GET',
|
|
27
26
|
json: true
|
|
28
|
-
}, that.extraRequestOptions || {})
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
// Send to callback
|
|
32
|
-
return reject(err);
|
|
33
|
-
}
|
|
27
|
+
}, that.extraRequestOptions || {})).then(function (res) {
|
|
28
|
+
// API response
|
|
29
|
+
var body = res.data;
|
|
34
30
|
|
|
35
31
|
// Missing body?
|
|
36
32
|
if (!body) {
|
|
@@ -43,7 +39,7 @@ module.exports = function (pushId, callback) {
|
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
// Check for 200 OK
|
|
46
|
-
if (res.
|
|
42
|
+
if (res.status != 200) {
|
|
47
43
|
return reject(new Error('An invalid response code was received from the Pushy API.'));
|
|
48
44
|
}
|
|
49
45
|
|
|
@@ -59,6 +55,14 @@ module.exports = function (pushId, callback) {
|
|
|
59
55
|
// Resolve the promise
|
|
60
56
|
resolve(status);
|
|
61
57
|
}
|
|
58
|
+
}).catch(function (err) {
|
|
59
|
+
// Invoke callback/reject promise with Pushy error
|
|
60
|
+
if (err.response && err.response.data) {
|
|
61
|
+
reject(err.response.data);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
reject(err);
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
67
|
});
|
|
64
68
|
}
|
package/index.d.ts
CHANGED
|
@@ -110,6 +110,33 @@ declare module 'pushy' {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
interface SendPushNotificationResult {
|
|
114
|
+
/** Returned if the API request was successful. */
|
|
115
|
+
success: boolean;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The push notification unique ID.
|
|
119
|
+
*
|
|
120
|
+
* Use it to check delivery status using the Notification Status API.
|
|
121
|
+
*/
|
|
122
|
+
id: string;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Contains additional information about the notification, for debugging purposes.
|
|
126
|
+
*/
|
|
127
|
+
info: {
|
|
128
|
+
/**
|
|
129
|
+
* The number of devices that will potentially receive the notification.
|
|
130
|
+
*/
|
|
131
|
+
devices: number;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* An array of invalid device tokens passed in which could not be found in our
|
|
135
|
+
* database registered under the app with the Secret API Key used to authenticate this request.
|
|
136
|
+
*/
|
|
137
|
+
failed: Array<string>;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
113
140
|
interface NotificationStatus {
|
|
114
141
|
/** The creation date of the push notification (unix timestamp). */
|
|
115
142
|
date: number;
|
|
@@ -243,8 +270,8 @@ declare module 'pushy' {
|
|
|
243
270
|
data: unknown,
|
|
244
271
|
recipient: string | Array<string>,
|
|
245
272
|
options?: SendPushNotificationOptions,
|
|
246
|
-
callback?: (error: Error | null,
|
|
247
|
-
): Promise<
|
|
273
|
+
callback?: (error: Error | null, result: SendPushNotificationResult) => void
|
|
274
|
+
): Promise<SendPushNotificationResult>;
|
|
248
275
|
|
|
249
276
|
/**
|
|
250
277
|
* Check the delivery status of your push notifications to Android / Electron recipients.
|
|
@@ -252,7 +279,10 @@ declare module 'pushy' {
|
|
|
252
279
|
*
|
|
253
280
|
* @param pushId
|
|
254
281
|
*/
|
|
255
|
-
getNotificationStatus(
|
|
282
|
+
getNotificationStatus(
|
|
283
|
+
pushId: string,
|
|
284
|
+
callback?: (error: Error | null, status: NotificationStatus) => void
|
|
285
|
+
): Promise<NotificationStatus>;
|
|
256
286
|
|
|
257
287
|
/**
|
|
258
288
|
* Permanently delete a pending notification.
|
|
@@ -260,7 +290,7 @@ declare module 'pushy' {
|
|
|
260
290
|
*
|
|
261
291
|
* @param pushId
|
|
262
292
|
*/
|
|
263
|
-
deletePushNotification(pushId: string): Promise<void>;
|
|
293
|
+
deletePushNotification(pushId: string, callback?: (error: Error | null) => void): Promise<void>;
|
|
264
294
|
|
|
265
295
|
/**
|
|
266
296
|
* Check the presence and connectivity status of multiple devices.
|
|
@@ -268,7 +298,10 @@ declare module 'pushy' {
|
|
|
268
298
|
*
|
|
269
299
|
* @param deviceTokens
|
|
270
300
|
*/
|
|
271
|
-
getDevicePresence(
|
|
301
|
+
getDevicePresence(
|
|
302
|
+
deviceTokens: string | Array<string>,
|
|
303
|
+
callback?: (error: Error | null, presence: Array<DevicePresenceInfo>) => void
|
|
304
|
+
): Promise<Array<DevicePresenceInfo>>;
|
|
272
305
|
|
|
273
306
|
/**
|
|
274
307
|
* Fetch device info, presence, undelivered notifications, and more by device token.
|
|
@@ -277,7 +310,10 @@ declare module 'pushy' {
|
|
|
277
310
|
*
|
|
278
311
|
* @param deviceToken
|
|
279
312
|
*/
|
|
280
|
-
getDeviceInfo(
|
|
313
|
+
getDeviceInfo(
|
|
314
|
+
deviceToken: string,
|
|
315
|
+
callback?: (error: Error | null, device: DeviceInfo) => void
|
|
316
|
+
): Promise<DeviceInfo>;
|
|
281
317
|
|
|
282
318
|
/**
|
|
283
319
|
* Subscribe a device to one or more topics.
|
|
@@ -286,7 +322,11 @@ declare module 'pushy' {
|
|
|
286
322
|
* @param topics
|
|
287
323
|
* @param deviceToken
|
|
288
324
|
*/
|
|
289
|
-
subscribe(
|
|
325
|
+
subscribe(
|
|
326
|
+
topics: string | Array<string>,
|
|
327
|
+
deviceToken: string,
|
|
328
|
+
callback?: (error: Error | null) => void
|
|
329
|
+
): Promise<void>;
|
|
290
330
|
|
|
291
331
|
/**
|
|
292
332
|
* Unsubscribe a device from one or more topics.
|
|
@@ -295,7 +335,11 @@ declare module 'pushy' {
|
|
|
295
335
|
* @param topics
|
|
296
336
|
* @param deviceToken
|
|
297
337
|
*/
|
|
298
|
-
unsubscribe(
|
|
338
|
+
unsubscribe(
|
|
339
|
+
topics: string | Array<string>,
|
|
340
|
+
deviceToken: string,
|
|
341
|
+
callback?: (error: Error | null) => void
|
|
342
|
+
): Promise<void>;
|
|
299
343
|
|
|
300
344
|
/**
|
|
301
345
|
* Retrieve a list of your app's topics and subscribers count.
|
|
@@ -309,6 +353,9 @@ declare module 'pushy' {
|
|
|
309
353
|
*
|
|
310
354
|
* @param topic The Pub/Sub topic to retrieve subscribers for. Topics are case-sensitive and must match the following regular expression: [a-zA-Z0-9-_.]+.
|
|
311
355
|
*/
|
|
312
|
-
getSubscribers(
|
|
356
|
+
getSubscribers(
|
|
357
|
+
topic: string,
|
|
358
|
+
callback?: (error: Error | null, subscribers: TopicSuscribers) => void
|
|
359
|
+
): Promise<TopicSuscribers>;
|
|
313
360
|
}
|
|
314
361
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pushy",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "The official Node.js package for sending push notifications with Pushy.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/pushy/pushy-node#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"
|
|
21
|
-
"request": "^2.72.0"
|
|
20
|
+
"axios": "^0.27.2"
|
|
22
21
|
}
|
|
23
22
|
}
|