intercom-client
Advanced tools
Comparing version 2.10.3 to 2.10.4
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _util = require('util'); | ||
var _request2 = require('request'); | ||
@@ -18,2 +20,6 @@ | ||
var _lodash = require('lodash.merge'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _user = require('./user'); | ||
@@ -73,2 +79,4 @@ | ||
function Client() { | ||
var _this = this; | ||
_classCallCheck(this, Client); | ||
@@ -109,3 +117,9 @@ | ||
this.promises = false; | ||
this.baseUrl = 'https://api.intercom.io'; | ||
this.requestOpts = { | ||
baseUrl: 'https://api.intercom.io' | ||
}; | ||
this.useBaseUrl = (0, _util.deprecate)(function (baseUrl) { | ||
return _this.useRequestOpts({ baseUrl: baseUrl }); | ||
}, 'intercom-client - client.useBaseUrl(url): Use client.useRequestOpts({ baseUrl: url }) instead'); | ||
} | ||
@@ -120,5 +134,5 @@ | ||
}, { | ||
key: 'useBaseUrl', | ||
value: function useBaseUrl(baseUrl) { | ||
this.baseUrl = baseUrl; | ||
key: 'useRequestOpts', | ||
value: function useRequestOpts(opts) { | ||
this.requestOpts = Object.assign(this.requestOpts, opts); | ||
return this; | ||
@@ -129,3 +143,3 @@ } | ||
value: function promiseProxy(f, args) { | ||
var _this = this; | ||
var _this2 = this; | ||
@@ -142,3 +156,3 @@ if (this.promises || !f) { | ||
}; | ||
_this.request(args, function (err, r) { | ||
_this2.request(args, function (err, r) { | ||
callbackHandler(resolver, err, r); | ||
@@ -149,3 +163,3 @@ }); | ||
this.request(args, function (err, r) { | ||
return _this.callback(f, err, r); | ||
return _this2.callback(f, err, r); | ||
}); | ||
@@ -212,3 +226,2 @@ } | ||
var defaultArgs = { | ||
baseUrl: this.baseUrl, | ||
json: true, | ||
@@ -220,4 +233,6 @@ headers: { | ||
}; | ||
return (0, _request3.default)(Object.assign({}, defaultArgs, args), callback).auth(this.usernamePart, this.passwordPart); | ||
// Don't just use Object.assign(requestArgs, args) here because we need to handle special cases like .headers | ||
// Per request args should take prededence over the default, and both of these over the user specified args via .useRequestOpts | ||
var requestArgs = (0, _lodash2.default)({}, this.requestOpts, defaultArgs, args); | ||
return (0, _request3.default)(requestArgs, callback).auth(this.usernamePart, this.passwordPart); | ||
} | ||
@@ -224,0 +239,0 @@ }, { |
{ | ||
"name": "intercom-client", | ||
"version": "2.10.3", | ||
"version": "2.10.4", | ||
"description": "Official Node bindings to the Intercom API", | ||
@@ -23,2 +23,3 @@ "homepage": "https://github.com/intercom/intercom-node", | ||
"htmlencode": "^0.0.4", | ||
"lodash.merge": "^4.6.1", | ||
"request": "^2.83.0" | ||
@@ -25,0 +26,0 @@ }, |
@@ -83,2 +83,18 @@ # intercom-node | ||
## Request Options | ||
This client library also supports passing in [`request` options](https://github.com/request/request#requestoptions-callback): | ||
```node | ||
var client = new Intercom.Client({ token: 'my_token' }); | ||
client.useRequestOpts({ | ||
baseUrl: 'http://local.test-server.com', | ||
// Uses the forever-agent / http(s).Agent({keepAlive:true}) | ||
forever: true | ||
}); | ||
``` | ||
Note that certain request options (such as `json`, and certain `headers` names cannot be overriden). | ||
## Users | ||
@@ -147,3 +163,3 @@ | ||
```node | ||
// Archive user by id (https://developers.intercom.com/v2.0/reference#archive-a-user) | ||
// Archive user by id (https://developers.intercom.com/intercom-api-reference/reference#archive-a-user) | ||
client.users.archive({ id: '1234' }, callback); | ||
@@ -153,3 +169,3 @@ ``` | ||
```node | ||
// Permanently delete a user by id (https://developers.intercom.com/v2.0/reference#delete-users) | ||
// Permanently delete a user by id (https://developers.intercom.com/intercom-api-reference/reference#delete-users) | ||
const intercomUserId = '123' | ||
@@ -462,3 +478,3 @@ client.users.requestPermanentDeletion(intercomUserId, callback); | ||
Listing conversations ([documentation](https://developers.intercom.com/reference#list-conversations)): | ||
Listing conversations ([documentation](https://developers.intercom.com/intercom-api-reference/reference#list-conversations)): | ||
@@ -465,0 +481,0 @@ ```node |
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
59923
22
1077
614
4
2
+ Addedlodash.merge@^4.6.1
+ Addedlodash.merge@4.6.2(transitive)