intercom-client
Advanced tools
Comparing version 2.7.0 to 2.8.0
@@ -76,9 +76,14 @@ 'use strict'; | ||
if (args.length === 2) { | ||
this.appId = args[0]; | ||
this.appApiKey = args[1]; | ||
this.usernamePart = args[0]; | ||
this.passwordPart = args[1]; | ||
} else if (args.length === 1) { | ||
this.appId = args[0].appId; | ||
this.appApiKey = args[0].appApiKey; | ||
if (args[0].token) { | ||
this.usernamePart = args[0].token; | ||
this.passwordPart = ''; | ||
} else { | ||
this.usernamePart = args[0].appId; | ||
this.passwordPart = args[0].appApiKey; | ||
} | ||
} | ||
if (!this.appId || !this.appApiKey) { | ||
if (!this.usernamePart || this.passwordPart === undefined) { | ||
throw new Error('Could not construct a client with those parameters'); | ||
@@ -112,3 +117,3 @@ } | ||
if (this.promises) { | ||
if (this.promises || !f) { | ||
var _ret = function () { | ||
@@ -142,3 +147,3 @@ var callbackHandler = _this.callback; | ||
value: function ping(f) { | ||
_unirest2.default.get('https://api.intercom.io/admins').auth(this.appId, this.appApiKey).type('json').header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0').end(function (r) { | ||
_unirest2.default.get('https://api.intercom.io/admins').auth(this.usernamePart, this.passwordPart).type('json').header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0').end(function (r) { | ||
return f(r.status); | ||
@@ -150,3 +155,3 @@ }); | ||
value: function put(endpoint, data, f) { | ||
return this.promiseProxy(f, _unirest2.default.put('https://api.intercom.io' + endpoint).auth(this.appId, this.appApiKey).type('json').send(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
return this.promiseProxy(f, _unirest2.default.put('https://api.intercom.io' + endpoint).auth(this.usernamePart, this.passwordPart).type('json').send(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
} | ||
@@ -156,3 +161,3 @@ }, { | ||
value: function post(endpoint, data, f) { | ||
return this.promiseProxy(f, _unirest2.default.post('https://api.intercom.io' + endpoint).auth(this.appId, this.appApiKey).type('json').send(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
return this.promiseProxy(f, _unirest2.default.post('https://api.intercom.io' + endpoint).auth(this.usernamePart, this.passwordPart).type('json').send(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
} | ||
@@ -162,3 +167,3 @@ }, { | ||
value: function get(endpoint, data, f) { | ||
return this.promiseProxy(f, _unirest2.default.get('https://api.intercom.io' + endpoint).auth(this.appId, this.appApiKey).type('json').query(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
return this.promiseProxy(f, _unirest2.default.get('https://api.intercom.io' + endpoint).auth(this.usernamePart, this.passwordPart).type('json').query(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
} | ||
@@ -168,3 +173,3 @@ }, { | ||
value: function nextPage(paginationObject, f) { | ||
return this.promiseProxy(f, _unirest2.default.get(paginationObject.next).auth(this.appId, this.appApiKey).type('json').header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
return this.promiseProxy(f, _unirest2.default.get(paginationObject.next).auth(this.usernamePart, this.passwordPart).type('json').header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
} | ||
@@ -174,3 +179,3 @@ }, { | ||
value: function _delete(endpoint, data, f) { | ||
return this.promiseProxy(f, _unirest2.default.delete('https://api.intercom.io' + endpoint).auth(this.appId, this.appApiKey).type('json').query(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
return this.promiseProxy(f, _unirest2.default.delete('https://api.intercom.io' + endpoint).auth(this.usernamePart, this.passwordPart).type('json').query(data).header('Accept', 'application/json').header('User-Agent', 'intercom-node-client/2.0.0')); | ||
} | ||
@@ -177,0 +182,0 @@ }, { |
{ | ||
"name": "intercom-client", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "Official Node bindings to the Intercom API", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/intercom/intercom-node", |
@@ -50,2 +50,6 @@ # intercom-node | ||
var client = new Intercom.Client({ appId: 'app_id', appApiKey: 'app_api_key' }); | ||
// Or with an OAuth token: | ||
var client = new Intercom.Client({ token: 'my_token' }); | ||
``` | ||
@@ -52,0 +56,0 @@ |
37933
647
438