Comparing version 3.0.0 to 3.0.1
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -23,13 +22,10 @@ // Device Info API | ||
// Make a request to the Device Info API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/devices/' + deviceToken + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/devices/' + deviceToken + '?api_key=' + that.apiKey, | ||
method: 'GET', | ||
json: true | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -47,3 +43,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -64,4 +60,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -43,13 +42,10 @@ // Device Presence API | ||
// Make a request to the Device Presence API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/devices/presence' + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/devices/presence' + '?api_key=' + that.apiKey, | ||
method: 'POST', | ||
json: postData | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
data: postData | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -67,3 +63,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -84,4 +80,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -37,13 +36,10 @@ // Pub/Sub Subscribe API | ||
// Make a request to the Pub/Sub Subscribe API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/topics/subscribe/' + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/topics/subscribe/' + '?api_key=' + that.apiKey, | ||
method: 'POST', | ||
json: postData | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
data: postData | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -61,3 +57,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -75,4 +71,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -23,13 +22,10 @@ // Pub/Sub Subscribers API | ||
// Make a request to the Pub/Sub Subscribers API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/topics/' + topic + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/topics/' + topic + '?api_key=' + that.apiKey, | ||
method: 'GET', | ||
json: true | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -47,3 +43,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -64,4 +60,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -18,13 +17,10 @@ // Pub/Sub Topics API | ||
// Make a request to the Pub/Sub Topics API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/topics/' + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/topics/' + '?api_key=' + that.apiKey, | ||
method: 'GET', | ||
json: true | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -42,3 +38,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -59,4 +55,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -37,13 +36,10 @@ // Pub/Sub Unsubscribe API | ||
// Make a request to the Pub/Sub Unsubscribe API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/topics/unsubscribe/' + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/topics/unsubscribe/' + '?api_key=' + that.apiKey, | ||
method: 'POST', | ||
json: postData | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
data: postData | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -61,3 +57,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -75,4 +71,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird') | ||
var axios = require('axios'); | ||
@@ -33,13 +32,10 @@ // Notification Deletion API | ||
// Make a request to the Notification Deletion API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/pushes/' + pushId + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/pushes/' + pushId + '?api_key=' + that.apiKey, | ||
method: 'DELETE', | ||
json: true | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -57,3 +53,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -71,4 +67,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
}; |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -62,13 +61,10 @@ // Send Notifications API | ||
// Make a request to the Send Notifications API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/push?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/push?api_key=' + that.apiKey, | ||
method: 'POST', | ||
json: postData | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
data: postData | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -86,3 +82,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -100,4 +96,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
}; |
@@ -1,3 +0,2 @@ | ||
var request = require('request'); | ||
var Promise = require('bluebird'); | ||
var axios = require('axios'); | ||
@@ -23,13 +22,10 @@ // Notification Status API | ||
// Make a request to the Notification Status API | ||
request( | ||
axios( | ||
Object.assign({ | ||
uri: that.getApiEndpoint() + '/pushes/' + pushId + '?api_key=' + that.apiKey, | ||
url: that.getApiEndpoint() + '/pushes/' + pushId + '?api_key=' + that.apiKey, | ||
method: 'GET', | ||
json: true | ||
}, that.extraRequestOptions || {}), function (err, res, body) { | ||
// Request error? | ||
if (err) { | ||
// Send to callback | ||
return reject(err); | ||
} | ||
}, that.extraRequestOptions || {})).then(function (res) { | ||
// API response | ||
var body = res.data; | ||
@@ -47,3 +43,3 @@ // Missing body? | ||
// Check for 200 OK | ||
if (res.statusCode != 200) { | ||
if (res.status != 200) { | ||
return reject(new Error('An invalid response code was received from the Pushy API.')); | ||
@@ -64,4 +60,12 @@ } | ||
} | ||
}).catch(function (err) { | ||
// Invoke callback/reject promise with Pushy error | ||
if (err.response && err.response.data) { | ||
reject(err.response.data); | ||
} | ||
else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
@@ -113,2 +113,29 @@ declare module 'pushy' { | ||
interface SendPushNotificationResult { | ||
/** Returned if the API request was successful. */ | ||
success: boolean; | ||
/** | ||
* The push notification unique ID. | ||
* | ||
* Use it to check delivery status using the Notification Status API. | ||
*/ | ||
id: string; | ||
/** | ||
* Contains additional information about the notification, for debugging purposes. | ||
*/ | ||
info: { | ||
/** | ||
* The number of devices that will potentially receive the notification. | ||
*/ | ||
devices: number; | ||
/** | ||
* An array of invalid device tokens passed in which could not be found in our | ||
* database registered under the app with the Secret API Key used to authenticate this request. | ||
*/ | ||
failed: Array<string>; | ||
}; | ||
} | ||
interface NotificationStatus { | ||
@@ -247,4 +274,4 @@ /** The creation date of the push notification (unix timestamp). */ | ||
options?: SendPushNotificationOptions, | ||
callback?: (error: Error | null, pushId: string) => void | ||
): Promise<string>; | ||
callback?: (error: Error | null, result: SendPushNotificationResult) => void | ||
): Promise<SendPushNotificationResult>; | ||
@@ -257,3 +284,6 @@ /** | ||
*/ | ||
getNotificationStatus(pushId: string): Promise<NotificationStatus>; | ||
getNotificationStatus( | ||
pushId: string, | ||
callback?: (error: Error | null, status: NotificationStatus) => void | ||
): Promise<NotificationStatus>; | ||
@@ -266,3 +296,3 @@ /** | ||
*/ | ||
deletePushNotification(pushId: string): Promise<void>; | ||
deletePushNotification(pushId: string, callback?: (error: Error | null) => void): Promise<void>; | ||
@@ -275,3 +305,6 @@ /** | ||
*/ | ||
getDevicePresence(deviceTokens: string | Array<string>): Promise<Array<DevicePresenceInfo>>; | ||
getDevicePresence( | ||
deviceTokens: string | Array<string>, | ||
callback?: (error: Error | null, presence: Array<DevicePresenceInfo>) => void | ||
): Promise<Array<DevicePresenceInfo>>; | ||
@@ -285,3 +318,6 @@ /** | ||
*/ | ||
getDeviceInfo(deviceToken: string): Promise<DeviceInfo>; | ||
getDeviceInfo( | ||
deviceToken: string, | ||
callback?: (error: Error | null, device: DeviceInfo) => void | ||
): Promise<DeviceInfo>; | ||
@@ -295,3 +331,7 @@ /** | ||
*/ | ||
subscribe(topics: string | Array<string>, deviceToken: string): Promise<void>; | ||
subscribe( | ||
topics: string | Array<string>, | ||
deviceToken: string, | ||
callback?: (error: Error | null) => void | ||
): Promise<void>; | ||
@@ -305,3 +345,7 @@ /** | ||
*/ | ||
unsubscribe(topics: string | Array<string>, deviceToken: string): Promise<void>; | ||
unsubscribe( | ||
topics: string | Array<string>, | ||
deviceToken: string, | ||
callback?: (error: Error | null) => void | ||
): Promise<void>; | ||
@@ -320,4 +364,7 @@ /** | ||
*/ | ||
getSubscribers(topic: string): Promise<TopicSuscribers>; | ||
getSubscribers( | ||
topic: string, | ||
callback?: (error: Error | null, subscribers: TopicSuscribers) => void | ||
): Promise<TopicSuscribers>; | ||
} | ||
} |
{ | ||
"name": "pushy", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "The official Node.js package for sending push notifications with Pushy.", | ||
@@ -20,5 +20,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"bluebird": "^3.4.1", | ||
"request": "^2.72.0" | ||
"axios": "^0.27.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74428
1
1046
+ Addedaxios@^0.27.2
+ Addedaxios@0.27.2(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
- Removedbluebird@^3.4.1
- Removedrequest@^2.72.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.14.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)