intercom-client
Advanced tools
Comparing version 2.9.2 to 2.9.3
@@ -131,3 +131,3 @@ 'use strict'; | ||
if (err) { | ||
reject(new Error(JSON.stringify(err))); | ||
reject(err); | ||
} else { | ||
@@ -137,9 +137,9 @@ resolve(data); | ||
}; | ||
_this.request(args, function (_, r) { | ||
callbackHandler(resolver, r); | ||
_this.request(args, function (err, r) { | ||
callbackHandler(resolver, err, r); | ||
}); | ||
}); | ||
} else { | ||
this.request(args, function (_, r) { | ||
return _this.callback(f, r); | ||
this.request(args, function (err, r) { | ||
return _this.callback(f, err, r); | ||
}); | ||
@@ -218,3 +218,3 @@ } | ||
key: 'callback', | ||
value: function callback(f, data) { | ||
value: function callback(f, err, res) { | ||
if (!f) { | ||
@@ -224,10 +224,20 @@ return; | ||
if (f.length >= 2) { | ||
var hasErrors = data.error || data.body && data.body.type === 'error.list'; | ||
if (hasErrors) { | ||
f(data, null); | ||
if (res && res.body && res.body.type === 'error.list') { | ||
var message = null; | ||
if (Array.isArray(res.body.errors) && res.body.errors[0] && 'message' in res.body.errors) { | ||
// Try to use the first errors message | ||
message = res.body.errors[0].message; | ||
} | ||
err = new Error(message || 'Response error'); | ||
err.statusCode = res.statusCode; | ||
err.body = res.body; | ||
err.headers = res.headers; | ||
} | ||
if (err) { | ||
f(err, null); | ||
} else { | ||
f(null, data); | ||
f(null, res); | ||
} | ||
} else { | ||
f(data); | ||
f(res || null); | ||
} | ||
@@ -234,0 +244,0 @@ } |
{ | ||
"name": "intercom-client", | ||
"version": "2.9.2", | ||
"version": "2.9.3", | ||
"description": "Official Node bindings to the Intercom API", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/intercom/intercom-node", |
@@ -355,2 +355,7 @@ # intercom-node | ||
``` | ||
// Find admin by ID | ||
client.admins.find('123456789', callback); | ||
``` | ||
## Tags | ||
@@ -476,2 +481,26 @@ | ||
```node | ||
// Assign a conversation to an admin | ||
var assignment = { | ||
id: '13879167940', | ||
type: 'admin', | ||
admin_id: '1309092', | ||
assignee_id: '1723471', | ||
message_type: 'assignment' | ||
}; | ||
client.conversations.reply(assignment, callback); | ||
// Assign a conversation to unassigned | ||
var assignment = { | ||
id: '13879167940', | ||
type: 'admin', | ||
admin_id: '1309092', | ||
assignee_id: '0', | ||
message_type: 'assignment' | ||
} | ||
client.conversations.reply(assignment, callback); | ||
``` | ||
```node | ||
// Mark a conversation as read | ||
@@ -478,0 +507,0 @@ client.conversations.markAsRead({ id: '1039067180' }, callback); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
57104
22
1042
581
2
1