intercom-client 2.10.5 → 3.0.0-0

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/package.json CHANGED
@@ -1,50 +1,67 @@
1
1
  {
2
- "name": "intercom-client",
3
- "version": "2.10.5",
4
- "description": "Official Node bindings to the Intercom API",
5
- "homepage": "https://github.com/intercom/intercom-node",
6
- "bugs:": "https://github.com/intercom/intercom-node/issues",
7
- "repository": "intercom/intercom-node",
8
- "author": {
9
- "name": "Bob Long",
10
- "email": "bob@intercom.io"
11
- },
12
- "files": [
13
- "dist"
14
- ],
15
- "main": "dist/index.js",
16
- "keywords": [
17
- "intercom",
18
- "api"
19
- ],
20
- "dependencies": {
21
- "bluebird": "^3.3.4",
22
- "htmlencode": "^0.0.4",
23
- "lodash": "^4.17.11",
24
- "request": "^2.83.0"
25
- },
26
- "devDependencies": {
27
- "babel-core": "^6.7.4",
28
- "babel-eslint": "^5.0.0",
29
- "babel-preset-es2015": "^6.6.0",
30
- "babel-preset-stage-1": "^6.5.0",
31
- "gulp": "^3.9.1",
32
- "gulp-babel": "^6.1.2",
33
- "gulp-eslint": "^0.15.0",
34
- "gulp-exclude-gitignore": "^1.0.0",
35
- "gulp-istanbul": "^0.10.3",
36
- "gulp-mocha": "^2.0.0",
37
- "gulp-nsp": "^2.4.2",
38
- "gulp-plumber": "^1.1.0",
39
- "nock": "7.5.0",
40
- "sinon": "^6.1.4"
41
- },
42
- "scripts": {
43
- "prepublish": "gulp prepublish",
44
- "test": "gulp"
45
- },
46
- "engines": {
47
- "node": ">= v0.10.0"
48
- },
49
- "license": "Apache-2.0"
2
+ "name": "intercom-client",
3
+ "version": "3.0.0-0",
4
+ "description": "Official Node bindings to the Intercom API",
5
+ "homepage": "https://github.com/intercom/intercom-node",
6
+ "bugs:": "https://github.com/intercom/intercom-node/issues",
7
+ "repository": "intercom/intercom-node",
8
+ "author": {
9
+ "name": "Bob Long",
10
+ "email": "bob@intercom.io"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "main": "dist/index.js",
16
+ "keywords": [
17
+ "intercom",
18
+ "api"
19
+ ],
20
+ "dependencies": {
21
+ "axios": "^0.24.0",
22
+ "htmlencode": "^0.0.4",
23
+ "lodash": "^4.17.21"
24
+ },
25
+ "devDependencies": {
26
+ "@babel/core": "^7.13.16",
27
+ "@babel/eslint-parser": "^7.16.0",
28
+ "@babel/plugin-transform-runtime": "^7.16.4",
29
+ "@babel/polyfill": "^7.12.1",
30
+ "@babel/preset-env": "^7.13.15",
31
+ "@babel/preset-typescript": "^7.16.0",
32
+ "@babel/register": "^7.13.16",
33
+ "@types/lodash": "^4.14.176",
34
+ "@types/mocha": "^9.0.0",
35
+ "@types/node": "^16.11.6",
36
+ "@types/sinon": "^10.0.6",
37
+ "@typescript-eslint/eslint-plugin": "^5.7.0",
38
+ "@typescript-eslint/parser": "^5.7.0",
39
+ "eslint": "^8.2.0",
40
+ "eslint-config-prettier": "^8.3.0",
41
+ "gulp": "^4.0.2",
42
+ "gulp-babel": "^8.0.0",
43
+ "gulp-cli": "^2.2.0",
44
+ "gulp-eslint": "^6.0.0",
45
+ "gulp-exclude-gitignore": "^1.0.0",
46
+ "gulp-istanbul": "^1.1.3",
47
+ "gulp-mocha": "^6.0.0",
48
+ "gulp-plumber": "^1.2.1",
49
+ "gulp-sourcemaps": "^3.0.0",
50
+ "gulp-typescript": "^6.0.0-alpha.1",
51
+ "merge2": "^1.4.1",
52
+ "nock": "^13.0.11",
53
+ "prettier": "^2.5.1",
54
+ "sinon": "^7.3.2",
55
+ "tslib": "^2.3.1",
56
+ "typescript": "^4.5.3"
57
+ },
58
+ "scripts": {
59
+ "prepublish": "gulp prepublish",
60
+ "test": "gulp"
61
+ },
62
+ "engines": {
63
+ "node": ">= v0.10.0"
64
+ },
65
+ "license": "Apache-2.0",
66
+ "packageManager": "yarn@3.1.0"
50
67
  }
package/dist/admin.js DELETED
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- var Admin = function () {
12
- function Admin(client) {
13
- _classCallCheck(this, Admin);
14
-
15
- this.client = client;
16
- }
17
-
18
- _createClass(Admin, [{
19
- key: 'list',
20
- value: function list(f) {
21
- return this.client.get('/admins', {}, f);
22
- }
23
- }, {
24
- key: 'find',
25
- value: function find(id, f) {
26
- return this.client.get('/admins/' + id, {}, f);
27
- }
28
- }, {
29
- key: 'me',
30
- value: function me(f) {
31
- return this.client.get('/me', {}, f);
32
- }
33
- }]);
34
-
35
- return Admin;
36
- }();
37
-
38
- exports.default = Admin;
package/dist/bulk.js DELETED
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- var Bulk = function () {
12
- function Bulk(client, dataType) {
13
- _classCallCheck(this, Bulk);
14
-
15
- this.client = client;
16
- this.dataType = dataType;
17
- }
18
-
19
- _createClass(Bulk, [{
20
- key: 'bulk',
21
- value: function bulk(bulkOperations, f) {
22
- var dataType = this.dataType;
23
- var bulkParams = { items: [] };
24
- var url = '/bulk/' + dataType + 's';
25
- bulkOperations.forEach(function (params) {
26
- for (var k in params) {
27
- var data = params[k];
28
- var method = k === 'create' ? 'post' : k;
29
- if (method !== 'post' && method !== 'delete') {
30
- throw new Error('Unknown bulk type: ' + method);
31
- }
32
- bulkParams.items.push({
33
- method: method,
34
- data_type: dataType,
35
- data: data
36
- });
37
- }
38
- });
39
- return this.client.post(url, bulkParams, f);
40
- }
41
- }]);
42
-
43
- return Bulk;
44
- }();
45
-
46
- exports.default = Bulk;
package/dist/client.js DELETED
@@ -1,261 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _util = require('util');
10
-
11
- var _request2 = require('request');
12
-
13
- var _request3 = _interopRequireDefault(_request2);
14
-
15
- var _bluebird = require('bluebird');
16
-
17
- var _bluebird2 = _interopRequireDefault(_bluebird);
18
-
19
- var _merge = require('lodash/merge');
20
-
21
- var _merge2 = _interopRequireDefault(_merge);
22
-
23
- var _user = require('./user');
24
-
25
- var _user2 = _interopRequireDefault(_user);
26
-
27
- var _event = require('./event');
28
-
29
- var _event2 = _interopRequireDefault(_event);
30
-
31
- var _company = require('./company');
32
-
33
- var _company2 = _interopRequireDefault(_company);
34
-
35
- var _contact = require('./contact');
36
-
37
- var _contact2 = _interopRequireDefault(_contact);
38
-
39
- var _visitor = require('./visitor');
40
-
41
- var _visitor2 = _interopRequireDefault(_visitor);
42
-
43
- var _counts = require('./counts');
44
-
45
- var _counts2 = _interopRequireDefault(_counts);
46
-
47
- var _admin = require('./admin');
48
-
49
- var _admin2 = _interopRequireDefault(_admin);
50
-
51
- var _tag = require('./tag');
52
-
53
- var _tag2 = _interopRequireDefault(_tag);
54
-
55
- var _segment = require('./segment');
56
-
57
- var _segment2 = _interopRequireDefault(_segment);
58
-
59
- var _message = require('./message');
60
-
61
- var _message2 = _interopRequireDefault(_message);
62
-
63
- var _conversation = require('./conversation');
64
-
65
- var _conversation2 = _interopRequireDefault(_conversation);
66
-
67
- var _note = require('./note');
68
-
69
- var _note2 = _interopRequireDefault(_note);
70
-
71
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
72
-
73
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
74
-
75
- var Client = function () {
76
- function Client() {
77
- var _this = this;
78
-
79
- _classCallCheck(this, Client);
80
-
81
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
82
- args[_key] = arguments[_key];
83
- }
84
-
85
- if (args.length === 2) {
86
- this.usernamePart = args[0];
87
- this.passwordPart = args[1];
88
- } else if (args.length === 1) {
89
- if (args[0].token) {
90
- this.usernamePart = args[0].token;
91
- this.passwordPart = '';
92
- } else {
93
- this.usernamePart = args[0].appId;
94
- this.passwordPart = args[0].appApiKey;
95
- }
96
- }
97
- if (!this.usernamePart || this.passwordPart === undefined) {
98
- throw new Error('Could not construct a client with those parameters');
99
- }
100
- this.users = new _user2.default(this);
101
- this.events = new _event2.default(this);
102
- this.companies = new _company2.default(this);
103
- this.contacts = new _contact2.default(this);
104
- this.leads = new _contact2.default(this);
105
- this.visitors = new _visitor2.default(this);
106
- this.counts = new _counts2.default(this);
107
- this.admins = new _admin2.default(this);
108
- this.tags = new _tag2.default(this);
109
- this.segments = new _segment2.default(this);
110
- this.messages = new _message2.default(this);
111
- this.conversations = new _conversation2.default(this);
112
- this.notes = new _note2.default(this);
113
- this.promises = false;
114
- this.requestOpts = {
115
- baseUrl: 'https://api.intercom.io'
116
- };
117
-
118
- this.useBaseUrl = (0, _util.deprecate)(function (baseUrl) {
119
- return _this.useRequestOpts({ baseUrl: baseUrl });
120
- }, 'intercom-client - client.useBaseUrl(url): Use client.useRequestOpts({ baseUrl: url }) instead');
121
- }
122
-
123
- _createClass(Client, [{
124
- key: 'usePromises',
125
- value: function usePromises() {
126
- this.promises = true;
127
- return this;
128
- }
129
- }, {
130
- key: 'useRequestOpts',
131
- value: function useRequestOpts(opts) {
132
- this.requestOpts = Object.assign(this.requestOpts, opts);
133
- return this;
134
- }
135
- }, {
136
- key: 'promiseProxy',
137
- value: function promiseProxy(f, args) {
138
- var _this2 = this;
139
-
140
- if (this.promises || !f) {
141
- var callbackHandler = this.callback;
142
- return new _bluebird2.default(function (resolve, reject) {
143
- var resolver = function resolver(err, data) {
144
- if (err) {
145
- reject(err);
146
- } else {
147
- resolve(data);
148
- }
149
- };
150
- _this2.request(args, function (err, r) {
151
- callbackHandler(resolver, err, r);
152
- });
153
- });
154
- } else {
155
- this.request(args, function (err, r) {
156
- return _this2.callback(f, err, r);
157
- });
158
- }
159
- }
160
- }, {
161
- key: 'ping',
162
- value: function ping(f) {
163
- this.request({
164
- uri: '/admins'
165
- }, function (_, response) {
166
- return f(response.statusCode);
167
- });
168
- }
169
- }, {
170
- key: 'put',
171
- value: function put(endpoint, data, f) {
172
- return this.promiseProxy(f, {
173
- method: 'put',
174
- uri: endpoint,
175
- body: data
176
- });
177
- }
178
- }, {
179
- key: 'post',
180
- value: function post(endpoint, data, f) {
181
- return this.promiseProxy(f, {
182
- method: 'post',
183
- uri: endpoint,
184
- body: data
185
- });
186
- }
187
- }, {
188
- key: 'get',
189
- value: function get(endpoint, data, f) {
190
- return this.promiseProxy(f, {
191
- method: 'get',
192
- uri: endpoint,
193
- qs: data
194
- });
195
- }
196
- }, {
197
- key: 'nextPage',
198
- value: function nextPage(paginationObject, f) {
199
- return this.promiseProxy(f, {
200
- method: 'get',
201
- uri: paginationObject.next,
202
- baseUrl: null
203
- });
204
- }
205
- }, {
206
- key: 'delete',
207
- value: function _delete(endpoint, data, f) {
208
- return this.promiseProxy(f, {
209
- method: 'delete',
210
- uri: endpoint,
211
- qs: data
212
- });
213
- }
214
- }, {
215
- key: 'request',
216
- value: function request(args, callback) {
217
- var defaultArgs = {
218
- json: true,
219
- headers: {
220
- Accept: 'application/json',
221
- 'User-Agent': 'intercom-node-client/2.0.0'
222
- }
223
- };
224
- // Don't just use Object.assign(requestArgs, args) here because we need to handle special cases like .headers
225
- // Per request args should take prededence over the default, and both of these over the user specified args via .useRequestOpts
226
- var requestArgs = (0, _merge2.default)({}, this.requestOpts, defaultArgs, args);
227
- return (0, _request3.default)(requestArgs, callback).auth(this.usernamePart, this.passwordPart);
228
- }
229
- }, {
230
- key: 'callback',
231
- value: function callback(f, err, res) {
232
- if (!f) {
233
- return;
234
- }
235
- if (f.length >= 2) {
236
- if (res && res.body && res.body.type === 'error.list') {
237
- var message = null;
238
- if (Array.isArray(res.body.errors) && res.body.errors[0] && 'message' in res.body.errors[0]) {
239
- // Try to use the first errors message
240
- message = res.body.errors[0].message;
241
- }
242
- err = new Error(message || 'Response error');
243
- err.statusCode = res.statusCode;
244
- err.body = res.body;
245
- err.headers = res.headers;
246
- }
247
- if (err) {
248
- f(err, null);
249
- } else {
250
- f(null, res);
251
- }
252
- } else {
253
- f(res || null);
254
- }
255
- }
256
- }]);
257
-
258
- return Client;
259
- }();
260
-
261
- exports.default = Client;
package/dist/company.js DELETED
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _scroll = require('./scroll');
10
-
11
- var _scroll2 = _interopRequireDefault(_scroll);
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
-
17
- var Company = function () {
18
- function Company(client) {
19
- _classCallCheck(this, Company);
20
-
21
- this.client = client;
22
- this.scroll = new _scroll2.default(this.client, 'companie');
23
- }
24
-
25
- _createClass(Company, [{
26
- key: 'create',
27
- value: function create(data, f) {
28
- return this.client.post('/companies', data, f);
29
- }
30
- }, {
31
- key: 'update',
32
- value: function update(data, f) {
33
- return this.create(data, f);
34
- }
35
- }, {
36
- key: 'list',
37
- value: function list(f) {
38
- return this.client.get('/companies', {}, f);
39
- }
40
- }, {
41
- key: 'listBy',
42
- value: function listBy(params, f) {
43
- return this.client.get('/companies', params, f);
44
- }
45
- }, {
46
- key: 'find',
47
- value: function find(params, f) {
48
- if (params.id) {
49
- return this.client.get('/companies/' + params.id, {}, f);
50
- } else if (params.company_id) {
51
- return this.client.get('/companies', { company_id: params.company_id }, f);
52
- } else if (params.name) {
53
- return this.client.get('/companies', { name: params.name }, f);
54
- }
55
- }
56
- }, {
57
- key: 'listUsers',
58
- value: function listUsers(params, f) {
59
- if (params.id) {
60
- return this.client.get('/companies/' + params.id + '/users', {}, f);
61
- } else if (params.company_id) {
62
- return this.client.get('/companies', { company_id: params.company_id, type: 'user' }, f);
63
- } else if (params.name) {
64
- return this.client.get('/companies', { name: params.name, type: 'user' }, f);
65
- }
66
- }
67
- }]);
68
-
69
- return Company;
70
- }();
71
-
72
- exports.default = Company;
package/dist/contact.js DELETED
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- var _scroll = require('./scroll');
10
-
11
- var _scroll2 = _interopRequireDefault(_scroll);
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
-
17
- var Contact = function () {
18
- function Contact(client) {
19
- _classCallCheck(this, Contact);
20
-
21
- this.client = client;
22
- this.scroll = new _scroll2.default(this.client, 'contact');
23
- }
24
-
25
- _createClass(Contact, [{
26
- key: 'create',
27
- value: function create() {
28
- var parameters_or_function = arguments[0];
29
- var params = {};
30
- var callback = parameters_or_function;
31
- if (typeof parameters_or_function !== 'function') {
32
- params = parameters_or_function;
33
- callback = arguments[1];
34
- }
35
- return this.client.post('/contacts', params, callback);
36
- }
37
- }, {
38
- key: 'update',
39
- value: function update(params, f) {
40
- return this.client.post('/contacts', params, f);
41
- }
42
- }, {
43
- key: 'list',
44
- value: function list(f) {
45
- return this.client.get('/contacts', {}, f);
46
- }
47
- }, {
48
- key: 'listBy',
49
- value: function listBy(params, f) {
50
- return this.client.get('/contacts', params, f);
51
- }
52
- }, {
53
- key: 'find',
54
- value: function find(params, f) {
55
- if (params.id) {
56
- return this.client.get('/contacts/' + params.id, {}, f);
57
- } else if (params.user_id) {
58
- return this.client.get('/contacts', { user_id: params.user_id }, f);
59
- }
60
- }
61
- }, {
62
- key: 'delete',
63
- value: function _delete(params, f) {
64
- return this.client.delete('/contacts/' + params.id, {}, f);
65
- }
66
- }, {
67
- key: 'convert',
68
- value: function convert(params, f) {
69
- return this.client.post('/contacts/convert', params, f);
70
- }
71
- }]);
72
-
73
- return Contact;
74
- }();
75
-
76
- exports.default = Contact;
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
-
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
-
11
- var Conversation = function () {
12
- function Conversation(client) {
13
- _classCallCheck(this, Conversation);
14
-
15
- this.client = client;
16
- }
17
-
18
- _createClass(Conversation, [{
19
- key: 'list',
20
- value: function list(data, f) {
21
- return this.client.get('/conversations', data, f);
22
- }
23
- }, {
24
- key: 'find',
25
- value: function find(params, f) {
26
- return this.client.get('/conversations/' + params.id, params, f);
27
- }
28
- }, {
29
- key: 'reply',
30
- value: function reply(params, f) {
31
- return this.client.post('/conversations/' + params.id + '/reply', params, f);
32
- }
33
- }, {
34
- key: 'markAsRead',
35
- value: function markAsRead(params, f) {
36
- return this.client.put('/conversations/' + params.id, { read: true }, f);
37
- }
38
- }]);
39
-
40
- return Conversation;
41
- }();
42
-
43
- exports.default = Conversation;