intercom-client 2.11.0 → 3.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 +873 -396
- package/dist/admin/admin.types.d.ts +13 -0
- package/dist/admin/admin.types.d.ts.map +1 -0
- package/dist/admin/admin.types.js +3 -0
- package/dist/admin/admin.types.js.map +1 -0
- package/dist/admin.d.ts +48 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +40 -41
- package/dist/admin.js.map +1 -0
- package/dist/client.d.ts +67 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +230 -239
- package/dist/client.js.map +1 -0
- package/dist/common/common.types.d.ts +91 -0
- package/dist/common/common.types.d.ts.map +1 -0
- package/dist/common/common.types.js +29 -0
- package/dist/common/common.types.js.map +1 -0
- package/dist/company/company.types.d.ts +37 -0
- package/dist/company/company.types.d.ts.map +1 -0
- package/dist/company/company.types.js +3 -0
- package/dist/company/company.types.js.map +1 -0
- package/dist/company.d.ts +67 -0
- package/dist/company.d.ts.map +1 -0
- package/dist/company.js +110 -83
- package/dist/company.js.map +1 -0
- package/dist/contact/contact.types.d.ts +80 -0
- package/dist/contact/contact.types.d.ts.map +1 -0
- package/dist/contact/contact.types.js +3 -0
- package/dist/contact/contact.types.js.map +1 -0
- package/dist/contact.d.ts +130 -0
- package/dist/contact.d.ts.map +1 -0
- package/dist/contact.js +155 -81
- package/dist/contact.js.map +1 -0
- package/dist/conversation/conversation.types.d.ts +144 -0
- package/dist/conversation/conversation.types.d.ts.map +1 -0
- package/dist/conversation/conversation.types.js +50 -0
- package/dist/conversation/conversation.types.js.map +1 -0
- package/dist/conversation.d.ts +176 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +287 -48
- package/dist/conversation.js.map +1 -0
- package/dist/dataAttribute/dataAttribute.types.d.ts +32 -0
- package/dist/dataAttribute/dataAttribute.types.d.ts.map +1 -0
- package/dist/dataAttribute/dataAttribute.types.js +18 -0
- package/dist/dataAttribute/dataAttribute.types.js.map +1 -0
- package/dist/dataAttribute.d.ts +33 -0
- package/dist/dataAttribute.d.ts.map +1 -0
- package/dist/dataAttribute.js +49 -0
- package/dist/dataAttribute.js.map +1 -0
- package/dist/errors/badResponse.error.d.ts +9 -0
- package/dist/errors/badResponse.error.d.ts.map +1 -0
- package/dist/errors/badResponse.error.js +21 -0
- package/dist/errors/badResponse.error.js.map +1 -0
- package/dist/event/event.types.d.ts +29 -0
- package/dist/event/event.types.d.ts.map +1 -0
- package/dist/event/event.types.js +3 -0
- package/dist/event/event.types.js.map +1 -0
- package/dist/event.d.ts +41 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +42 -45
- package/dist/event.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -76
- package/dist/index.js.map +1 -0
- package/dist/message/message.types.d.ts +17 -0
- package/dist/message/message.types.d.ts.map +1 -0
- package/dist/message/message.types.js +11 -0
- package/dist/message/message.types.js.map +1 -0
- package/dist/message.d.ts +30 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +32 -31
- package/dist/message.js.map +1 -0
- package/dist/scroll.d.ts +24 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +67 -79
- package/dist/scroll.js.map +1 -0
- package/dist/segment/segment.types.d.ts +11 -0
- package/dist/segment/segment.types.d.ts.map +1 -0
- package/dist/segment/segment.types.js +3 -0
- package/dist/segment/segment.types.js.map +1 -0
- package/dist/segment.d.ts +22 -0
- package/dist/segment.d.ts.map +1 -0
- package/dist/segment.js +26 -36
- package/dist/segment.js.map +1 -0
- package/dist/subscription/subscription.types.d.ts +19 -0
- package/dist/subscription/subscription.types.d.ts.map +1 -0
- package/dist/subscription/subscription.types.js +10 -0
- package/dist/subscription/subscription.types.js.map +1 -0
- package/dist/tag/tag.types.d.ts +6 -0
- package/dist/tag/tag.types.d.ts.map +1 -0
- package/dist/tag/tag.types.js +3 -0
- package/dist/tag/tag.types.js.map +1 -0
- package/dist/tag.d.ts +52 -0
- package/dist/tag.d.ts.map +1 -0
- package/dist/tag.js +93 -57
- package/dist/tag.js.map +1 -0
- package/dist/team/team.types.d.ts +7 -0
- package/dist/team/team.types.d.ts.map +1 -0
- package/dist/team/team.types.js +3 -0
- package/dist/team/team.types.js.map +1 -0
- package/dist/team.d.ts +18 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/team.js +23 -0
- package/dist/team.js.map +1 -0
- package/dist/util/time.d.ts +3 -0
- package/dist/util/time.d.ts.map +1 -0
- package/dist/util/time.js +6 -0
- package/dist/util/time.js.map +1 -0
- package/dist/util/url.d.ts +3 -0
- package/dist/util/url.d.ts.map +1 -0
- package/dist/util/url.js +9 -0
- package/dist/util/url.js.map +1 -0
- package/package.json +57 -48
- package/dist/bulk.js +0 -55
- package/dist/counts.js +0 -88
- package/dist/customer.js +0 -33
- package/dist/note.js +0 -43
- package/dist/snippet.js +0 -121
- package/dist/user-data.js +0 -105
- package/dist/user.js +0 -120
- package/dist/visitor.js +0 -54
package/dist/counts.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
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); } }
|
|
11
|
-
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
-
|
|
14
|
-
var Counts =
|
|
15
|
-
/*#__PURE__*/
|
|
16
|
-
function () {
|
|
17
|
-
function Counts(client) {
|
|
18
|
-
_classCallCheck(this, Counts);
|
|
19
|
-
|
|
20
|
-
this.client = client;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_createClass(Counts, [{
|
|
24
|
-
key: "appCounts",
|
|
25
|
-
value: function appCounts(f) {
|
|
26
|
-
return this.client.get('/counts', {}, f);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "conversationCounts",
|
|
30
|
-
value: function conversationCounts(f) {
|
|
31
|
-
return this.client.get('/counts', {
|
|
32
|
-
type: 'conversation'
|
|
33
|
-
}, f);
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "conversationAdminCounts",
|
|
37
|
-
value: function conversationAdminCounts(f) {
|
|
38
|
-
return this.client.get('/counts', {
|
|
39
|
-
type: 'conversation',
|
|
40
|
-
count: 'admin'
|
|
41
|
-
}, f);
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: "userTagCounts",
|
|
45
|
-
value: function userTagCounts(f) {
|
|
46
|
-
return this.client.get('/counts', {
|
|
47
|
-
type: 'user',
|
|
48
|
-
count: 'tag'
|
|
49
|
-
}, f);
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: "userSegmentCounts",
|
|
53
|
-
value: function userSegmentCounts(f) {
|
|
54
|
-
return this.client.get('/counts', {
|
|
55
|
-
type: 'user',
|
|
56
|
-
count: 'segment'
|
|
57
|
-
}, f);
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "companyTagCounts",
|
|
61
|
-
value: function companyTagCounts(f) {
|
|
62
|
-
return this.client.get('/counts', {
|
|
63
|
-
type: 'company',
|
|
64
|
-
count: 'tag'
|
|
65
|
-
}, f);
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "companySegmentCounts",
|
|
69
|
-
value: function companySegmentCounts(f) {
|
|
70
|
-
return this.client.get('/counts', {
|
|
71
|
-
type: 'company',
|
|
72
|
-
count: 'segment'
|
|
73
|
-
}, f);
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: "companyUserCounts",
|
|
77
|
-
value: function companyUserCounts(f) {
|
|
78
|
-
return this.client.get('/counts', {
|
|
79
|
-
type: 'company',
|
|
80
|
-
count: 'user'
|
|
81
|
-
}, f);
|
|
82
|
-
}
|
|
83
|
-
}]);
|
|
84
|
-
|
|
85
|
-
return Counts;
|
|
86
|
-
}();
|
|
87
|
-
|
|
88
|
-
exports["default"] = Counts;
|
package/dist/customer.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
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); } }
|
|
11
|
-
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
-
|
|
14
|
-
var Customer =
|
|
15
|
-
/*#__PURE__*/
|
|
16
|
-
function () {
|
|
17
|
-
function Customer(client) {
|
|
18
|
-
_classCallCheck(this, Customer);
|
|
19
|
-
|
|
20
|
-
this.client = client;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_createClass(Customer, [{
|
|
24
|
-
key: "search",
|
|
25
|
-
value: function search(params, f) {
|
|
26
|
-
return this.client.post('/customers/search', params, f);
|
|
27
|
-
}
|
|
28
|
-
}]);
|
|
29
|
-
|
|
30
|
-
return Customer;
|
|
31
|
-
}();
|
|
32
|
-
|
|
33
|
-
exports["default"] = Customer;
|
package/dist/note.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
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); } }
|
|
11
|
-
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
-
|
|
14
|
-
var Note =
|
|
15
|
-
/*#__PURE__*/
|
|
16
|
-
function () {
|
|
17
|
-
function Note(client) {
|
|
18
|
-
_classCallCheck(this, Note);
|
|
19
|
-
|
|
20
|
-
this.client = client;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_createClass(Note, [{
|
|
24
|
-
key: "create",
|
|
25
|
-
value: function create(params, f) {
|
|
26
|
-
return this.client.post('/notes', params, f);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "list",
|
|
30
|
-
value: function list(params, f) {
|
|
31
|
-
return this.client.get('/notes', params, f);
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "find",
|
|
35
|
-
value: function find(params, f) {
|
|
36
|
-
return this.client.get("/notes/".concat(params.id), {}, f);
|
|
37
|
-
}
|
|
38
|
-
}]);
|
|
39
|
-
|
|
40
|
-
return Note;
|
|
41
|
-
}();
|
|
42
|
-
|
|
43
|
-
exports["default"] = Note;
|
package/dist/snippet.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _index = require("./index");
|
|
9
|
-
|
|
10
|
-
var _htmlencode = _interopRequireDefault(require("htmlencode"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
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); } }
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
-
|
|
22
|
-
var Snippet =
|
|
23
|
-
/*#__PURE__*/
|
|
24
|
-
function () {
|
|
25
|
-
function Snippet(settings) {
|
|
26
|
-
_classCallCheck(this, Snippet);
|
|
27
|
-
|
|
28
|
-
this.loggedOut = !settings.user_id && !settings.email;
|
|
29
|
-
|
|
30
|
-
if (!settings.app_id) {
|
|
31
|
-
throw new Error('You must provide an app_id in your Intercom settings');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!this.loggedOut && !settings.verificationSecret) {
|
|
35
|
-
throw new Error('You must provide your verification secret in your Intercom settings');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this.settings = settings;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_createClass(Snippet, [{
|
|
42
|
-
key: "create",
|
|
43
|
-
value: function create() {
|
|
44
|
-
var verificationSecret = this.getVerificationSecret();
|
|
45
|
-
var identifier = this.getIdentifier();
|
|
46
|
-
this.setUserHash(verificationSecret, identifier);
|
|
47
|
-
return this.generateSnippetHTML();
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "getVerificationSecret",
|
|
51
|
-
value: function getVerificationSecret() {
|
|
52
|
-
var verificationSecret = this.settings.verificationSecret;
|
|
53
|
-
delete this.settings.verificationSecret;
|
|
54
|
-
return verificationSecret;
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "getIdentifier",
|
|
58
|
-
value: function getIdentifier() {
|
|
59
|
-
if (this.settings.user_id) {
|
|
60
|
-
return this.settings.user_id.toString();
|
|
61
|
-
} else {
|
|
62
|
-
return this.settings.email;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "setUserHash",
|
|
67
|
-
value: function setUserHash(verificationSecret, identifier) {
|
|
68
|
-
if (this.loggedOut) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var userHash = _index.IdentityVerification.userHash({
|
|
73
|
-
secretKey: verificationSecret,
|
|
74
|
-
identifier: identifier
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
this.settings.user_hash = userHash;
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "generateSnippetHTML",
|
|
81
|
-
value: function generateSnippetHTML() {
|
|
82
|
-
return "\n<script>\n window.intercomSettings = {\n ".concat(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/").concat(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 ");
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "settingsToString",
|
|
86
|
-
value: function settingsToString(settings) {
|
|
87
|
-
var _this = this;
|
|
88
|
-
|
|
89
|
-
var intercomSettings = [];
|
|
90
|
-
Object.keys(settings).map(function (key) {
|
|
91
|
-
if (_typeof(settings[key]) === 'object' && settings[key] !== null) {
|
|
92
|
-
intercomSettings.push("".concat(key, ": { ").concat(_this.settingsToString(settings[key]), " }"));
|
|
93
|
-
} else {
|
|
94
|
-
var escapedKey = _this.escapeString(key);
|
|
95
|
-
|
|
96
|
-
var value = _this.escapeString(settings[key]);
|
|
97
|
-
|
|
98
|
-
if (typeof settings[key] === 'string') {
|
|
99
|
-
intercomSettings.push("".concat(escapedKey, ": \"").concat(value, "\""));
|
|
100
|
-
} else {
|
|
101
|
-
intercomSettings.push("".concat(escapedKey, ": ").concat(value));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return intercomSettings.join(', ');
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "escapeString",
|
|
109
|
-
value: function escapeString(string) {
|
|
110
|
-
if (typeof string === 'string') {
|
|
111
|
-
string = _htmlencode["default"].htmlEncode(string).replace(/\"/gi, '\\"');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return string;
|
|
115
|
-
}
|
|
116
|
-
}]);
|
|
117
|
-
|
|
118
|
-
return Snippet;
|
|
119
|
-
}();
|
|
120
|
-
|
|
121
|
-
exports["default"] = Snippet;
|
package/dist/user-data.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _index = require("./index");
|
|
9
|
-
|
|
10
|
-
var _htmlencode = _interopRequireDefault(require("htmlencode"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
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); } }
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
-
|
|
22
|
-
var UserData =
|
|
23
|
-
/*#__PURE__*/
|
|
24
|
-
function () {
|
|
25
|
-
function UserData(settings) {
|
|
26
|
-
_classCallCheck(this, UserData);
|
|
27
|
-
|
|
28
|
-
this.loggedOut = !settings.user_id && !settings.email;
|
|
29
|
-
|
|
30
|
-
if (!settings.app_id) {
|
|
31
|
-
throw new Error('You must provide an app_id in your Intercom settings');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!this.loggedOut && !settings.verificationSecret) {
|
|
35
|
-
throw new Error('You must provide your verification secret in your Intercom settings');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this.settings = settings;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_createClass(UserData, [{
|
|
42
|
-
key: "json",
|
|
43
|
-
value: function json() {
|
|
44
|
-
this.setUserHash();
|
|
45
|
-
return this.escapedSettings(this.settings);
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "getVerificationSecret",
|
|
49
|
-
value: function getVerificationSecret() {
|
|
50
|
-
var verificationSecret = this.settings.verificationSecret;
|
|
51
|
-
delete this.settings.verificationSecret;
|
|
52
|
-
return verificationSecret;
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "setUserHash",
|
|
56
|
-
value: function setUserHash() {
|
|
57
|
-
if (this.loggedOut || this.settings.user_hash !== undefined) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var verificationSecret = this.settings.verificationSecret;
|
|
62
|
-
delete this.settings.verificationSecret;
|
|
63
|
-
var identifier = this.settings.user_id ? this.settings.user_id.toString() : this.settings.email;
|
|
64
|
-
|
|
65
|
-
var userHash = _index.IdentityVerification.userHash({
|
|
66
|
-
secretKey: verificationSecret,
|
|
67
|
-
identifier: identifier
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
this.settings.user_hash = userHash;
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: "escapedSettings",
|
|
74
|
-
value: function escapedSettings(settings) {
|
|
75
|
-
var _this = this;
|
|
76
|
-
|
|
77
|
-
var intercomSettings = {};
|
|
78
|
-
Object.keys(settings).map(function (key) {
|
|
79
|
-
if (_typeof(settings[key]) === 'object' && settings[key] !== null) {
|
|
80
|
-
intercomSettings[key] = _this.escapedSettings(settings[key]);
|
|
81
|
-
} else {
|
|
82
|
-
var escapedKey = _this.escapeString(key);
|
|
83
|
-
|
|
84
|
-
var value = _this.escapeString(settings[key]);
|
|
85
|
-
|
|
86
|
-
intercomSettings[escapedKey] = value;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return intercomSettings;
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "escapeString",
|
|
93
|
-
value: function escapeString(string) {
|
|
94
|
-
if (typeof string === 'string') {
|
|
95
|
-
string = _htmlencode["default"].htmlEncode(string).replace(/\"/gi, '\\"');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return string;
|
|
99
|
-
}
|
|
100
|
-
}]);
|
|
101
|
-
|
|
102
|
-
return UserData;
|
|
103
|
-
}();
|
|
104
|
-
|
|
105
|
-
exports["default"] = UserData;
|
package/dist/user.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _bulk = _interopRequireDefault(require("./bulk"));
|
|
9
|
-
|
|
10
|
-
var _scroll = _interopRequireDefault(require("./scroll"));
|
|
11
|
-
|
|
12
|
-
var _util = require("util");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
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); } }
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
-
|
|
22
|
-
var User =
|
|
23
|
-
/*#__PURE__*/
|
|
24
|
-
function () {
|
|
25
|
-
function User(client) {
|
|
26
|
-
_classCallCheck(this, User);
|
|
27
|
-
|
|
28
|
-
this.client = client;
|
|
29
|
-
this.scroll = new _scroll["default"](this.client, 'user'); // Keep this API around but mark it deprecated
|
|
30
|
-
|
|
31
|
-
this["delete"] = (0, _util.deprecate)(this.archive.bind(this), 'intercom-client - user.delete: Use user.archive instead');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_createClass(User, [{
|
|
35
|
-
key: "create",
|
|
36
|
-
value: function create(data, f) {
|
|
37
|
-
return this.client.post('/users', data, f);
|
|
38
|
-
}
|
|
39
|
-
}, {
|
|
40
|
-
key: "update",
|
|
41
|
-
value: function update(data, f) {
|
|
42
|
-
return this.create(data, f);
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: "list",
|
|
46
|
-
value: function list(f) {
|
|
47
|
-
return this.client.get('/users', {}, f);
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "listBy",
|
|
51
|
-
value: function listBy(params, f) {
|
|
52
|
-
return this.client.get('/users', params, f);
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "find",
|
|
56
|
-
value: function find(params, f) {
|
|
57
|
-
if (params.id) {
|
|
58
|
-
return this.client.get("/users/".concat(params.id), {}, f);
|
|
59
|
-
} else if (params.user_id) {
|
|
60
|
-
return this.client.get('/users', {
|
|
61
|
-
user_id: params.user_id
|
|
62
|
-
}, f);
|
|
63
|
-
} else if (params.email) {
|
|
64
|
-
return this.client.get('/users', {
|
|
65
|
-
email: params.email
|
|
66
|
-
}, f);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "archive",
|
|
71
|
-
value: function archive(params, f) {
|
|
72
|
-
if (params.id) {
|
|
73
|
-
return this.client["delete"]("/users/".concat(params.id), {}, f);
|
|
74
|
-
} else if (params.user_id) {
|
|
75
|
-
return this.client["delete"]('/users', {
|
|
76
|
-
user_id: params.user_id
|
|
77
|
-
}, f);
|
|
78
|
-
} else if (params.email) {
|
|
79
|
-
return this.client["delete"]('/users', {
|
|
80
|
-
email: params.email
|
|
81
|
-
}, f);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "bulk",
|
|
86
|
-
value: function bulk(params, f) {
|
|
87
|
-
return new _bulk["default"](this.client, 'user').bulk(params, f);
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
key: "requestPermanentDeletion",
|
|
91
|
-
value: function requestPermanentDeletion(intercom_user_id, f) {
|
|
92
|
-
return this.client.post('/user_delete_requests', {
|
|
93
|
-
intercom_user_id: intercom_user_id
|
|
94
|
-
}, f);
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "requestPermanentDeletionByParams",
|
|
98
|
-
value: function requestPermanentDeletionByParams(params, f) {
|
|
99
|
-
var _this = this;
|
|
100
|
-
|
|
101
|
-
if (params.id) {
|
|
102
|
-
return this.requestPermanentDeletion(params.id, f);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return this.find(params).then(function (res) {
|
|
106
|
-
return _this.requestPermanentDeletion(res.body.id, f);
|
|
107
|
-
})["catch"](function (err) {
|
|
108
|
-
if (f) {
|
|
109
|
-
return f(err);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
throw err;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}]);
|
|
116
|
-
|
|
117
|
-
return User;
|
|
118
|
-
}();
|
|
119
|
-
|
|
120
|
-
exports["default"] = User;
|
package/dist/visitor.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
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); } }
|
|
11
|
-
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
-
|
|
14
|
-
var Visitor =
|
|
15
|
-
/*#__PURE__*/
|
|
16
|
-
function () {
|
|
17
|
-
function Visitor(client) {
|
|
18
|
-
_classCallCheck(this, Visitor);
|
|
19
|
-
|
|
20
|
-
this.client = client;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_createClass(Visitor, [{
|
|
24
|
-
key: "update",
|
|
25
|
-
value: function update(params, f) {
|
|
26
|
-
return this.client.post('/visitors', params, f);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "find",
|
|
30
|
-
value: function find(params, f) {
|
|
31
|
-
if (params.id) {
|
|
32
|
-
return this.client.get("/visitors/".concat(params.id), {}, f);
|
|
33
|
-
} else if (params.user_id) {
|
|
34
|
-
return this.client.get('/visitors', {
|
|
35
|
-
user_id: params.user_id
|
|
36
|
-
}, f);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, {
|
|
40
|
-
key: "delete",
|
|
41
|
-
value: function _delete(params, f) {
|
|
42
|
-
return this.client["delete"]("/visitors/".concat(params.id), {}, f);
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: "convert",
|
|
46
|
-
value: function convert(params, f) {
|
|
47
|
-
return this.client.post('/visitors/convert', params, f);
|
|
48
|
-
}
|
|
49
|
-
}]);
|
|
50
|
-
|
|
51
|
-
return Visitor;
|
|
52
|
-
}();
|
|
53
|
-
|
|
54
|
-
exports["default"] = Visitor;
|