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/README.md +696 -390
- package/package.json +65 -48
- package/dist/admin.js +0 -38
- package/dist/bulk.js +0 -46
- package/dist/client.js +0 -261
- package/dist/company.js +0 -72
- package/dist/contact.js +0 -76
- package/dist/conversation.js +0 -43
- package/dist/counts.js +0 -63
- package/dist/event.js +0 -44
- package/dist/get_user.js +0 -13
- package/dist/index.js +0 -60
- package/dist/message.js +0 -28
- package/dist/note.js +0 -38
- package/dist/scroll.js +0 -74
- package/dist/segment.js +0 -33
- package/dist/snippet.js +0 -114
- package/dist/tag.js +0 -54
- package/dist/user-data.js +0 -100
- package/dist/user.js +0 -110
- package/dist/visitor.js +0 -47
package/dist/counts.js
DELETED
|
@@ -1,63 +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 Counts = function () {
|
|
12
|
-
function Counts(client) {
|
|
13
|
-
_classCallCheck(this, Counts);
|
|
14
|
-
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_createClass(Counts, [{
|
|
19
|
-
key: 'appCounts',
|
|
20
|
-
value: function appCounts(f) {
|
|
21
|
-
return this.client.get('/counts', {}, f);
|
|
22
|
-
}
|
|
23
|
-
}, {
|
|
24
|
-
key: 'conversationCounts',
|
|
25
|
-
value: function conversationCounts(f) {
|
|
26
|
-
return this.client.get('/counts', { type: 'conversation' }, f);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: 'conversationAdminCounts',
|
|
30
|
-
value: function conversationAdminCounts(f) {
|
|
31
|
-
return this.client.get('/counts', { type: 'conversation', count: 'admin' }, f);
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: 'userTagCounts',
|
|
35
|
-
value: function userTagCounts(f) {
|
|
36
|
-
return this.client.get('/counts', { type: 'user', count: 'tag' }, f);
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
key: 'userSegmentCounts',
|
|
40
|
-
value: function userSegmentCounts(f) {
|
|
41
|
-
return this.client.get('/counts', { type: 'user', count: 'segment' }, f);
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: 'companyTagCounts',
|
|
45
|
-
value: function companyTagCounts(f) {
|
|
46
|
-
return this.client.get('/counts', { type: 'company', count: 'tag' }, f);
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: 'companySegmentCounts',
|
|
50
|
-
value: function companySegmentCounts(f) {
|
|
51
|
-
return this.client.get('/counts', { type: 'company', count: 'segment' }, f);
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: 'companyUserCounts',
|
|
55
|
-
value: function companyUserCounts(f) {
|
|
56
|
-
return this.client.get('/counts', { type: 'company', count: 'user' }, f);
|
|
57
|
-
}
|
|
58
|
-
}]);
|
|
59
|
-
|
|
60
|
-
return Counts;
|
|
61
|
-
}();
|
|
62
|
-
|
|
63
|
-
exports.default = Counts;
|
package/dist/event.js
DELETED
|
@@ -1,44 +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 _bulk = require('./bulk');
|
|
10
|
-
|
|
11
|
-
var _bulk2 = _interopRequireDefault(_bulk);
|
|
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 Event = function () {
|
|
18
|
-
function Event(client) {
|
|
19
|
-
_classCallCheck(this, Event);
|
|
20
|
-
|
|
21
|
-
this.client = client;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_createClass(Event, [{
|
|
25
|
-
key: 'create',
|
|
26
|
-
value: function create(data, f) {
|
|
27
|
-
return this.client.post('/events', data, f);
|
|
28
|
-
}
|
|
29
|
-
}, {
|
|
30
|
-
key: 'listBy',
|
|
31
|
-
value: function listBy(params, f) {
|
|
32
|
-
return this.client.get('/events', params, f);
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
key: 'bulk',
|
|
36
|
-
value: function bulk(params, f) {
|
|
37
|
-
return new _bulk2.default(this.client, 'event').bulk(params, f);
|
|
38
|
-
}
|
|
39
|
-
}]);
|
|
40
|
-
|
|
41
|
-
return Event;
|
|
42
|
-
}();
|
|
43
|
-
|
|
44
|
-
exports.default = Event;
|
package/dist/get_user.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Intercom = require('intercom-client');
|
|
4
|
-
//var Intercom = require('/Users/cathalhoran/intercom-node/lib');
|
|
5
|
-
|
|
6
|
-
var client = new Intercom.Client({ token: process.env['AT'] });
|
|
7
|
-
var usr_id = process.argv[2];
|
|
8
|
-
client.users.find({ user_id: usr_id }, function (err, rsp) {
|
|
9
|
-
if (err) {
|
|
10
|
-
console.log(err);
|
|
11
|
-
}
|
|
12
|
-
console.log(rsp.body);
|
|
13
|
-
});
|
package/dist/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.IdentityVerification = exports.UserData = exports.Snippet = exports.User = exports.Client = undefined;
|
|
7
|
-
|
|
8
|
-
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; }; }();
|
|
9
|
-
|
|
10
|
-
var _client = require('./client');
|
|
11
|
-
|
|
12
|
-
var _client2 = _interopRequireDefault(_client);
|
|
13
|
-
|
|
14
|
-
var _user = require('./user');
|
|
15
|
-
|
|
16
|
-
var _user2 = _interopRequireDefault(_user);
|
|
17
|
-
|
|
18
|
-
var _snippet = require('./snippet');
|
|
19
|
-
|
|
20
|
-
var _snippet2 = _interopRequireDefault(_snippet);
|
|
21
|
-
|
|
22
|
-
var _userData = require('./user-data');
|
|
23
|
-
|
|
24
|
-
var _userData2 = _interopRequireDefault(_userData);
|
|
25
|
-
|
|
26
|
-
var _crypto = require('crypto');
|
|
27
|
-
|
|
28
|
-
var _crypto2 = _interopRequireDefault(_crypto);
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
|
-
|
|
34
|
-
exports.Client = _client2.default;
|
|
35
|
-
exports.User = _user2.default;
|
|
36
|
-
exports.Snippet = _snippet2.default;
|
|
37
|
-
exports.UserData = _userData2.default;
|
|
38
|
-
|
|
39
|
-
var IdentityVerification = exports.IdentityVerification = function () {
|
|
40
|
-
function IdentityVerification() {
|
|
41
|
-
_classCallCheck(this, IdentityVerification);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
_createClass(IdentityVerification, null, [{
|
|
45
|
-
key: 'userHash',
|
|
46
|
-
value: function userHash(params) {
|
|
47
|
-
var secretKey = params.secretKey;
|
|
48
|
-
var identifier = params.identifier;
|
|
49
|
-
if (!secretKey) {
|
|
50
|
-
throw new Error('secretKey must be provided');
|
|
51
|
-
}
|
|
52
|
-
if (!identifier) {
|
|
53
|
-
throw new Error('identifier must be provided');
|
|
54
|
-
}
|
|
55
|
-
return _crypto2.default.createHmac('sha256', secretKey).update(identifier).digest('hex');
|
|
56
|
-
}
|
|
57
|
-
}]);
|
|
58
|
-
|
|
59
|
-
return IdentityVerification;
|
|
60
|
-
}();
|
package/dist/message.js
DELETED
|
@@ -1,28 +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 Message = function () {
|
|
12
|
-
function Message(client) {
|
|
13
|
-
_classCallCheck(this, Message);
|
|
14
|
-
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_createClass(Message, [{
|
|
19
|
-
key: 'create',
|
|
20
|
-
value: function create(data, f) {
|
|
21
|
-
return this.client.post('/messages', data, f);
|
|
22
|
-
}
|
|
23
|
-
}]);
|
|
24
|
-
|
|
25
|
-
return Message;
|
|
26
|
-
}();
|
|
27
|
-
|
|
28
|
-
exports.default = Message;
|
package/dist/note.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 Note = function () {
|
|
12
|
-
function Note(client) {
|
|
13
|
-
_classCallCheck(this, Note);
|
|
14
|
-
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_createClass(Note, [{
|
|
19
|
-
key: 'create',
|
|
20
|
-
value: function create(params, f) {
|
|
21
|
-
return this.client.post('/notes', params, f);
|
|
22
|
-
}
|
|
23
|
-
}, {
|
|
24
|
-
key: 'list',
|
|
25
|
-
value: function list(params, f) {
|
|
26
|
-
return this.client.get('/notes', params, f);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: 'find',
|
|
30
|
-
value: function find(params, f) {
|
|
31
|
-
return this.client.get('/notes/' + params.id, {}, f);
|
|
32
|
-
}
|
|
33
|
-
}]);
|
|
34
|
-
|
|
35
|
-
return Note;
|
|
36
|
-
}();
|
|
37
|
-
|
|
38
|
-
exports.default = Note;
|
package/dist/scroll.js
DELETED
|
@@ -1,74 +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 _bluebird = require('bluebird');
|
|
10
|
-
|
|
11
|
-
var _bluebird2 = _interopRequireDefault(_bluebird);
|
|
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 Scroll = function () {
|
|
18
|
-
function Scroll(client, dataType) {
|
|
19
|
-
_classCallCheck(this, Scroll);
|
|
20
|
-
|
|
21
|
-
this.client = client;
|
|
22
|
-
this.dataType = dataType;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
_createClass(Scroll, [{
|
|
26
|
-
key: 'each',
|
|
27
|
-
value: function each(params, f) {
|
|
28
|
-
var self = this;
|
|
29
|
-
this.scroll_param = undefined;
|
|
30
|
-
|
|
31
|
-
return new _bluebird2.default(function (resolve, reject) {
|
|
32
|
-
self.eachInternal(params, f, { resolve: resolve, reject: reject });
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: 'eachInternal',
|
|
37
|
-
value: function eachInternal(params, f, promise) {
|
|
38
|
-
var self = this;
|
|
39
|
-
this.client.get(this.scrollUrl(), params).then(function (response) {
|
|
40
|
-
var result = f(response);
|
|
41
|
-
if (response.body[self.dataType + 's'].length > 0) {
|
|
42
|
-
self.scroll_param = response.body.scroll_param;
|
|
43
|
-
if (result && 'then' in result && typeof result.then === 'function') {
|
|
44
|
-
result.then(function () {
|
|
45
|
-
self.eachInternal(params, f, promise);
|
|
46
|
-
}, function (error) {
|
|
47
|
-
promise.reject(error);
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
self.eachInternal(params, f, promise);
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
promise.resolve();
|
|
54
|
-
}
|
|
55
|
-
}).catch(function (error) {
|
|
56
|
-
promise.reject(error);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: 'scrollUrl',
|
|
61
|
-
value: function scrollUrl() {
|
|
62
|
-
var dataType = this.dataType;
|
|
63
|
-
if (typeof this.scroll_param !== 'undefined') {
|
|
64
|
-
return '/' + dataType + 's/scroll?scroll_param=' + this.scroll_param;
|
|
65
|
-
} else {
|
|
66
|
-
return '/' + dataType + 's/scroll';
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}]);
|
|
70
|
-
|
|
71
|
-
return Scroll;
|
|
72
|
-
}();
|
|
73
|
-
|
|
74
|
-
exports.default = Scroll;
|
package/dist/segment.js
DELETED
|
@@ -1,33 +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 Segment = function () {
|
|
12
|
-
function Segment(client) {
|
|
13
|
-
_classCallCheck(this, Segment);
|
|
14
|
-
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_createClass(Segment, [{
|
|
19
|
-
key: 'list',
|
|
20
|
-
value: function list(f) {
|
|
21
|
-
return this.client.get('/segments', {}, f);
|
|
22
|
-
}
|
|
23
|
-
}, {
|
|
24
|
-
key: 'find',
|
|
25
|
-
value: function find(params, f) {
|
|
26
|
-
return this.client.get('/segments/' + params.id, {}, f);
|
|
27
|
-
}
|
|
28
|
-
}]);
|
|
29
|
-
|
|
30
|
-
return Segment;
|
|
31
|
-
}();
|
|
32
|
-
|
|
33
|
-
exports.default = Segment;
|
package/dist/snippet.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
8
|
-
|
|
9
|
-
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; }; }();
|
|
10
|
-
|
|
11
|
-
var _index = require('./index');
|
|
12
|
-
|
|
13
|
-
var _htmlencode = require('htmlencode');
|
|
14
|
-
|
|
15
|
-
var _htmlencode2 = _interopRequireDefault(_htmlencode);
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
-
|
|
21
|
-
var Snippet = function () {
|
|
22
|
-
function Snippet(settings) {
|
|
23
|
-
_classCallCheck(this, Snippet);
|
|
24
|
-
|
|
25
|
-
this.loggedOut = !settings.user_id && !settings.email;
|
|
26
|
-
|
|
27
|
-
if (!settings.app_id) {
|
|
28
|
-
throw new Error('You must provide an app_id in your Intercom settings');
|
|
29
|
-
}
|
|
30
|
-
if (!this.loggedOut && !settings.verificationSecret) {
|
|
31
|
-
throw new Error('You must provide your verification secret in your Intercom settings');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.settings = settings;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_createClass(Snippet, [{
|
|
38
|
-
key: 'create',
|
|
39
|
-
value: function create() {
|
|
40
|
-
var verificationSecret = this.getVerificationSecret();
|
|
41
|
-
var identifier = this.getIdentifier();
|
|
42
|
-
this.setUserHash(verificationSecret, identifier);
|
|
43
|
-
return this.generateSnippetHTML();
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: 'getVerificationSecret',
|
|
47
|
-
value: function getVerificationSecret() {
|
|
48
|
-
var verificationSecret = this.settings.verificationSecret;
|
|
49
|
-
|
|
50
|
-
delete this.settings.verificationSecret;
|
|
51
|
-
return verificationSecret;
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: 'getIdentifier',
|
|
55
|
-
value: function getIdentifier() {
|
|
56
|
-
if (this.settings.user_id) {
|
|
57
|
-
return this.settings.user_id.toString();
|
|
58
|
-
} else {
|
|
59
|
-
return this.settings.email;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: 'setUserHash',
|
|
64
|
-
value: function setUserHash(verificationSecret, identifier) {
|
|
65
|
-
if (this.loggedOut) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var userHash = _index.IdentityVerification.userHash({
|
|
70
|
-
secretKey: verificationSecret,
|
|
71
|
-
identifier: identifier
|
|
72
|
-
});
|
|
73
|
-
this.settings.user_hash = userHash;
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: 'generateSnippetHTML',
|
|
77
|
-
value: function generateSnippetHTML() {
|
|
78
|
-
return '\n<script>\n window.intercomSettings = {\n ' + this.settingsToString(this.settings) + '\n };\n</script>\n<script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic(\'reattach_activator\');ic(\'update\',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement(\'script\');s.type=\'text/javascript\';s.async=true;s.src=\'https://widget.intercom.io/widget/' + this.settings.app_id + '\';var x=d.getElementsByTagName(\'script\')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent(\'onload\',l);}else{w.addEventListener(\'load\',l,false);}}})()</script>\n ';
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: 'settingsToString',
|
|
82
|
-
value: function settingsToString(settings) {
|
|
83
|
-
var _this = this;
|
|
84
|
-
|
|
85
|
-
var intercomSettings = [];
|
|
86
|
-
Object.keys(settings).map(function (key) {
|
|
87
|
-
if (_typeof(settings[key]) === 'object' && settings[key] !== null) {
|
|
88
|
-
intercomSettings.push(key + ': { ' + _this.settingsToString(settings[key]) + ' }');
|
|
89
|
-
} else {
|
|
90
|
-
var escapedKey = _this.escapeString(key);
|
|
91
|
-
var value = _this.escapeString(settings[key]);
|
|
92
|
-
if (typeof settings[key] === 'string') {
|
|
93
|
-
intercomSettings.push(escapedKey + ': "' + value + '"');
|
|
94
|
-
} else {
|
|
95
|
-
intercomSettings.push(escapedKey + ': ' + value);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return intercomSettings.join(', ');
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: 'escapeString',
|
|
103
|
-
value: function escapeString(string) {
|
|
104
|
-
if (typeof string === 'string') {
|
|
105
|
-
string = _htmlencode2.default.htmlEncode(string).replace(/\"/gi, '\\"');
|
|
106
|
-
}
|
|
107
|
-
return string;
|
|
108
|
-
}
|
|
109
|
-
}]);
|
|
110
|
-
|
|
111
|
-
return Snippet;
|
|
112
|
-
}();
|
|
113
|
-
|
|
114
|
-
exports.default = Snippet;
|
package/dist/tag.js
DELETED
|
@@ -1,54 +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 Tag = function () {
|
|
12
|
-
function Tag(client) {
|
|
13
|
-
_classCallCheck(this, Tag);
|
|
14
|
-
|
|
15
|
-
this.client = client;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_createClass(Tag, [{
|
|
19
|
-
key: 'create',
|
|
20
|
-
value: function create(data, f) {
|
|
21
|
-
return this.client.post('/tags', data, f);
|
|
22
|
-
}
|
|
23
|
-
}, {
|
|
24
|
-
key: 'tag',
|
|
25
|
-
value: function tag(data, f) {
|
|
26
|
-
return this.client.post('/tags', data, f);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: 'untag',
|
|
30
|
-
value: function untag(data, f) {
|
|
31
|
-
(data.users || []).forEach(function (user) {
|
|
32
|
-
return user.untag = true;
|
|
33
|
-
});
|
|
34
|
-
(data.companies || []).forEach(function (company) {
|
|
35
|
-
return company.untag = true;
|
|
36
|
-
});
|
|
37
|
-
return this.client.post('/tags', data, f);
|
|
38
|
-
}
|
|
39
|
-
}, {
|
|
40
|
-
key: 'delete',
|
|
41
|
-
value: function _delete(params, f) {
|
|
42
|
-
return this.client.delete('/tags/' + params.id, {}, f);
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: 'list',
|
|
46
|
-
value: function list(f) {
|
|
47
|
-
return this.client.get('/tags', {}, f);
|
|
48
|
-
}
|
|
49
|
-
}]);
|
|
50
|
-
|
|
51
|
-
return Tag;
|
|
52
|
-
}();
|
|
53
|
-
|
|
54
|
-
exports.default = Tag;
|
package/dist/user-data.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
8
|
-
|
|
9
|
-
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; }; }();
|
|
10
|
-
|
|
11
|
-
var _index = require('./index');
|
|
12
|
-
|
|
13
|
-
var _htmlencode = require('htmlencode');
|
|
14
|
-
|
|
15
|
-
var _htmlencode2 = _interopRequireDefault(_htmlencode);
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
-
|
|
21
|
-
var UserData = function () {
|
|
22
|
-
function UserData(settings) {
|
|
23
|
-
_classCallCheck(this, UserData);
|
|
24
|
-
|
|
25
|
-
this.loggedOut = !settings.user_id && !settings.email;
|
|
26
|
-
|
|
27
|
-
if (!settings.app_id) {
|
|
28
|
-
throw new Error('You must provide an app_id in your Intercom settings');
|
|
29
|
-
}
|
|
30
|
-
if (!this.loggedOut && !settings.verificationSecret) {
|
|
31
|
-
throw new Error('You must provide your verification secret in your Intercom settings');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.settings = settings;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_createClass(UserData, [{
|
|
38
|
-
key: 'json',
|
|
39
|
-
value: function json() {
|
|
40
|
-
this.setUserHash();
|
|
41
|
-
return this.escapedSettings(this.settings);
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: 'getVerificationSecret',
|
|
45
|
-
value: function getVerificationSecret() {
|
|
46
|
-
var verificationSecret = this.settings.verificationSecret;
|
|
47
|
-
|
|
48
|
-
delete this.settings.verificationSecret;
|
|
49
|
-
return verificationSecret;
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: 'setUserHash',
|
|
53
|
-
value: function setUserHash() {
|
|
54
|
-
if (this.loggedOut || this.settings.user_hash !== undefined) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var verificationSecret = this.settings.verificationSecret;
|
|
59
|
-
|
|
60
|
-
delete this.settings.verificationSecret;
|
|
61
|
-
var identifier = this.settings.user_id ? this.settings.user_id.toString() : this.settings.email;
|
|
62
|
-
|
|
63
|
-
var userHash = _index.IdentityVerification.userHash({
|
|
64
|
-
secretKey: verificationSecret,
|
|
65
|
-
identifier: identifier
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
this.settings.user_hash = userHash;
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: 'escapedSettings',
|
|
72
|
-
value: function escapedSettings(settings) {
|
|
73
|
-
var _this = this;
|
|
74
|
-
|
|
75
|
-
var intercomSettings = {};
|
|
76
|
-
Object.keys(settings).map(function (key) {
|
|
77
|
-
if (_typeof(settings[key]) === 'object' && settings[key] !== null) {
|
|
78
|
-
intercomSettings[key] = _this.escapedSettings(settings[key]);
|
|
79
|
-
} else {
|
|
80
|
-
var escapedKey = _this.escapeString(key);
|
|
81
|
-
var value = _this.escapeString(settings[key]);
|
|
82
|
-
intercomSettings[escapedKey] = value;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return intercomSettings;
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: 'escapeString',
|
|
89
|
-
value: function escapeString(string) {
|
|
90
|
-
if (typeof string === 'string') {
|
|
91
|
-
string = _htmlencode2.default.htmlEncode(string).replace(/\"/gi, '\\"');
|
|
92
|
-
}
|
|
93
|
-
return string;
|
|
94
|
-
}
|
|
95
|
-
}]);
|
|
96
|
-
|
|
97
|
-
return UserData;
|
|
98
|
-
}();
|
|
99
|
-
|
|
100
|
-
exports.default = UserData;
|