intercom-client 2.11.2 → 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 +681 -404
- package/package.json +65 -49
- package/dist/admin.js +0 -46
- package/dist/bulk.js +0 -53
- package/dist/client.js +0 -245
- package/dist/company.js +0 -83
- package/dist/contact.js +0 -81
- package/dist/conversation.js +0 -48
- package/dist/counts.js +0 -86
- package/dist/customer.js +0 -31
- package/dist/event.js +0 -45
- package/dist/index.js +0 -76
- package/dist/message.js +0 -31
- package/dist/note.js +0 -41
- package/dist/scroll.js +0 -80
- package/dist/segment.js +0 -36
- package/dist/snippet.js +0 -119
- package/dist/tag.js +0 -57
- package/dist/user-data.js +0 -103
- package/dist/user.js +0 -118
- package/dist/visitor.js +0 -52
package/dist/counts.js
DELETED
|
@@ -1,86 +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 = /*#__PURE__*/function () {
|
|
15
|
-
function Counts(client) {
|
|
16
|
-
_classCallCheck(this, Counts);
|
|
17
|
-
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Counts, [{
|
|
22
|
-
key: "appCounts",
|
|
23
|
-
value: function appCounts(f) {
|
|
24
|
-
return this.client.get('/counts', {}, f);
|
|
25
|
-
}
|
|
26
|
-
}, {
|
|
27
|
-
key: "conversationCounts",
|
|
28
|
-
value: function conversationCounts(f) {
|
|
29
|
-
return this.client.get('/counts', {
|
|
30
|
-
type: 'conversation'
|
|
31
|
-
}, f);
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "conversationAdminCounts",
|
|
35
|
-
value: function conversationAdminCounts(f) {
|
|
36
|
-
return this.client.get('/counts', {
|
|
37
|
-
type: 'conversation',
|
|
38
|
-
count: 'admin'
|
|
39
|
-
}, f);
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "userTagCounts",
|
|
43
|
-
value: function userTagCounts(f) {
|
|
44
|
-
return this.client.get('/counts', {
|
|
45
|
-
type: 'user',
|
|
46
|
-
count: 'tag'
|
|
47
|
-
}, f);
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "userSegmentCounts",
|
|
51
|
-
value: function userSegmentCounts(f) {
|
|
52
|
-
return this.client.get('/counts', {
|
|
53
|
-
type: 'user',
|
|
54
|
-
count: 'segment'
|
|
55
|
-
}, f);
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "companyTagCounts",
|
|
59
|
-
value: function companyTagCounts(f) {
|
|
60
|
-
return this.client.get('/counts', {
|
|
61
|
-
type: 'company',
|
|
62
|
-
count: 'tag'
|
|
63
|
-
}, f);
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "companySegmentCounts",
|
|
67
|
-
value: function companySegmentCounts(f) {
|
|
68
|
-
return this.client.get('/counts', {
|
|
69
|
-
type: 'company',
|
|
70
|
-
count: 'segment'
|
|
71
|
-
}, f);
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "companyUserCounts",
|
|
75
|
-
value: function companyUserCounts(f) {
|
|
76
|
-
return this.client.get('/counts', {
|
|
77
|
-
type: 'company',
|
|
78
|
-
count: 'user'
|
|
79
|
-
}, f);
|
|
80
|
-
}
|
|
81
|
-
}]);
|
|
82
|
-
|
|
83
|
-
return Counts;
|
|
84
|
-
}();
|
|
85
|
-
|
|
86
|
-
exports["default"] = Counts;
|
package/dist/customer.js
DELETED
|
@@ -1,31 +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 = /*#__PURE__*/function () {
|
|
15
|
-
function Customer(client) {
|
|
16
|
-
_classCallCheck(this, Customer);
|
|
17
|
-
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Customer, [{
|
|
22
|
-
key: "search",
|
|
23
|
-
value: function search(params, f) {
|
|
24
|
-
return this.client.post('/customers/search', params, f);
|
|
25
|
-
}
|
|
26
|
-
}]);
|
|
27
|
-
|
|
28
|
-
return Customer;
|
|
29
|
-
}();
|
|
30
|
-
|
|
31
|
-
exports["default"] = Customer;
|
package/dist/event.js
DELETED
|
@@ -1,45 +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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
|
|
14
|
-
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); } }
|
|
15
|
-
|
|
16
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
17
|
-
|
|
18
|
-
var Event = /*#__PURE__*/function () {
|
|
19
|
-
function Event(client) {
|
|
20
|
-
_classCallCheck(this, Event);
|
|
21
|
-
|
|
22
|
-
this.client = client;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
_createClass(Event, [{
|
|
26
|
-
key: "create",
|
|
27
|
-
value: function create(data, f) {
|
|
28
|
-
return this.client.post('/events', data, f);
|
|
29
|
-
}
|
|
30
|
-
}, {
|
|
31
|
-
key: "listBy",
|
|
32
|
-
value: function listBy(params, f) {
|
|
33
|
-
return this.client.get('/events', params, f);
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "bulk",
|
|
37
|
-
value: function bulk(params, f) {
|
|
38
|
-
return new _bulk["default"](this.client, 'event').bulk(params, f);
|
|
39
|
-
}
|
|
40
|
-
}]);
|
|
41
|
-
|
|
42
|
-
return Event;
|
|
43
|
-
}();
|
|
44
|
-
|
|
45
|
-
exports["default"] = Event;
|
package/dist/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Client", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _client["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "User", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _user["default"];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "Snippet", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _snippet["default"];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "UserData", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _userData["default"];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
exports.IdentityVerification = void 0;
|
|
31
|
-
|
|
32
|
-
var _client = _interopRequireDefault(require("./client"));
|
|
33
|
-
|
|
34
|
-
var _user = _interopRequireDefault(require("./user"));
|
|
35
|
-
|
|
36
|
-
var _snippet = _interopRequireDefault(require("./snippet"));
|
|
37
|
-
|
|
38
|
-
var _userData = _interopRequireDefault(require("./user-data"));
|
|
39
|
-
|
|
40
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
41
|
-
|
|
42
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
43
|
-
|
|
44
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
45
|
-
|
|
46
|
-
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); } }
|
|
47
|
-
|
|
48
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
49
|
-
|
|
50
|
-
var IdentityVerification = /*#__PURE__*/function () {
|
|
51
|
-
function IdentityVerification() {
|
|
52
|
-
_classCallCheck(this, IdentityVerification);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_createClass(IdentityVerification, null, [{
|
|
56
|
-
key: "userHash",
|
|
57
|
-
value: function userHash(params) {
|
|
58
|
-
var secretKey = params.secretKey;
|
|
59
|
-
var identifier = params.identifier;
|
|
60
|
-
|
|
61
|
-
if (!secretKey) {
|
|
62
|
-
throw new Error('secretKey must be provided');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!identifier) {
|
|
66
|
-
throw new Error('identifier must be provided');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return _crypto["default"].createHmac('sha256', secretKey).update(identifier).digest('hex');
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
|
|
73
|
-
return IdentityVerification;
|
|
74
|
-
}();
|
|
75
|
-
|
|
76
|
-
exports.IdentityVerification = IdentityVerification;
|
package/dist/message.js
DELETED
|
@@ -1,31 +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 Message = /*#__PURE__*/function () {
|
|
15
|
-
function Message(client) {
|
|
16
|
-
_classCallCheck(this, Message);
|
|
17
|
-
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Message, [{
|
|
22
|
-
key: "create",
|
|
23
|
-
value: function create(data, f) {
|
|
24
|
-
return this.client.post('/messages', data, f);
|
|
25
|
-
}
|
|
26
|
-
}]);
|
|
27
|
-
|
|
28
|
-
return Message;
|
|
29
|
-
}();
|
|
30
|
-
|
|
31
|
-
exports["default"] = Message;
|
package/dist/note.js
DELETED
|
@@ -1,41 +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 = /*#__PURE__*/function () {
|
|
15
|
-
function Note(client) {
|
|
16
|
-
_classCallCheck(this, Note);
|
|
17
|
-
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Note, [{
|
|
22
|
-
key: "create",
|
|
23
|
-
value: function create(params, f) {
|
|
24
|
-
return this.client.post('/notes', params, f);
|
|
25
|
-
}
|
|
26
|
-
}, {
|
|
27
|
-
key: "list",
|
|
28
|
-
value: function list(params, f) {
|
|
29
|
-
return this.client.get('/notes', params, f);
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
key: "find",
|
|
33
|
-
value: function find(params, f) {
|
|
34
|
-
return this.client.get("/notes/".concat(params.id), {}, f);
|
|
35
|
-
}
|
|
36
|
-
}]);
|
|
37
|
-
|
|
38
|
-
return Note;
|
|
39
|
-
}();
|
|
40
|
-
|
|
41
|
-
exports["default"] = Note;
|
package/dist/scroll.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
|
|
14
|
-
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); } }
|
|
15
|
-
|
|
16
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
17
|
-
|
|
18
|
-
var Scroll = /*#__PURE__*/function () {
|
|
19
|
-
function Scroll(client, dataType) {
|
|
20
|
-
_classCallCheck(this, Scroll);
|
|
21
|
-
|
|
22
|
-
this.client = client;
|
|
23
|
-
this.dataType = dataType;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
_createClass(Scroll, [{
|
|
27
|
-
key: "each",
|
|
28
|
-
value: function each(params, f) {
|
|
29
|
-
var self = this;
|
|
30
|
-
this.scroll_param = undefined;
|
|
31
|
-
return new _bluebird["default"](function (resolve, reject) {
|
|
32
|
-
self.eachInternal(params, f, {
|
|
33
|
-
resolve: resolve,
|
|
34
|
-
reject: reject
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
key: "eachInternal",
|
|
40
|
-
value: function eachInternal(params, f, promise) {
|
|
41
|
-
var self = this;
|
|
42
|
-
this.client.get(this.scrollUrl(), params).then(function (response) {
|
|
43
|
-
var result = f(response);
|
|
44
|
-
|
|
45
|
-
if (response.body["".concat(self.dataType, "s")].length > 0) {
|
|
46
|
-
self.scroll_param = response.body.scroll_param;
|
|
47
|
-
|
|
48
|
-
if (result && 'then' in result && typeof result.then === 'function') {
|
|
49
|
-
result.then(function () {
|
|
50
|
-
self.eachInternal(params, f, promise);
|
|
51
|
-
}, function (error) {
|
|
52
|
-
promise.reject(error);
|
|
53
|
-
});
|
|
54
|
-
} else {
|
|
55
|
-
self.eachInternal(params, f, promise);
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
promise.resolve();
|
|
59
|
-
}
|
|
60
|
-
})["catch"](function (error) {
|
|
61
|
-
promise.reject(error);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "scrollUrl",
|
|
66
|
-
value: function scrollUrl() {
|
|
67
|
-
var dataType = this.dataType;
|
|
68
|
-
|
|
69
|
-
if (typeof this.scroll_param !== 'undefined') {
|
|
70
|
-
return "/".concat(dataType, "s/scroll?scroll_param=").concat(this.scroll_param);
|
|
71
|
-
} else {
|
|
72
|
-
return "/".concat(dataType, "s/scroll");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}]);
|
|
76
|
-
|
|
77
|
-
return Scroll;
|
|
78
|
-
}();
|
|
79
|
-
|
|
80
|
-
exports["default"] = Scroll;
|
package/dist/segment.js
DELETED
|
@@ -1,36 +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 Segment = /*#__PURE__*/function () {
|
|
15
|
-
function Segment(client) {
|
|
16
|
-
_classCallCheck(this, Segment);
|
|
17
|
-
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Segment, [{
|
|
22
|
-
key: "list",
|
|
23
|
-
value: function list(f) {
|
|
24
|
-
return this.client.get('/segments', {}, f);
|
|
25
|
-
}
|
|
26
|
-
}, {
|
|
27
|
-
key: "find",
|
|
28
|
-
value: function find(params, f) {
|
|
29
|
-
return this.client.get("/segments/".concat(params.id), {}, f);
|
|
30
|
-
}
|
|
31
|
-
}]);
|
|
32
|
-
|
|
33
|
-
return Segment;
|
|
34
|
-
}();
|
|
35
|
-
|
|
36
|
-
exports["default"] = Segment;
|
package/dist/snippet.js
DELETED
|
@@ -1,119 +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) { "@babel/helpers - typeof"; 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 = /*#__PURE__*/function () {
|
|
23
|
-
function Snippet(settings) {
|
|
24
|
-
_classCallCheck(this, Snippet);
|
|
25
|
-
|
|
26
|
-
this.loggedOut = !settings.user_id && !settings.email;
|
|
27
|
-
|
|
28
|
-
if (!settings.app_id) {
|
|
29
|
-
throw new Error('You must provide an app_id in your Intercom settings');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!this.loggedOut && !settings.verificationSecret) {
|
|
33
|
-
throw new Error('You must provide your verification secret in your Intercom settings');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
this.settings = settings;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
_createClass(Snippet, [{
|
|
40
|
-
key: "create",
|
|
41
|
-
value: function create() {
|
|
42
|
-
var verificationSecret = this.getVerificationSecret();
|
|
43
|
-
var identifier = this.getIdentifier();
|
|
44
|
-
this.setUserHash(verificationSecret, identifier);
|
|
45
|
-
return this.generateSnippetHTML();
|
|
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: "getIdentifier",
|
|
56
|
-
value: function getIdentifier() {
|
|
57
|
-
if (this.settings.user_id) {
|
|
58
|
-
return this.settings.user_id.toString();
|
|
59
|
-
} else {
|
|
60
|
-
return this.settings.email;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "setUserHash",
|
|
65
|
-
value: function setUserHash(verificationSecret, identifier) {
|
|
66
|
-
if (this.loggedOut) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var userHash = _index.IdentityVerification.userHash({
|
|
71
|
-
secretKey: verificationSecret,
|
|
72
|
-
identifier: identifier
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
this.settings.user_hash = userHash;
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: "generateSnippetHTML",
|
|
79
|
-
value: function generateSnippetHTML() {
|
|
80
|
-
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 ");
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "settingsToString",
|
|
84
|
-
value: function settingsToString(settings) {
|
|
85
|
-
var _this = this;
|
|
86
|
-
|
|
87
|
-
var intercomSettings = [];
|
|
88
|
-
Object.keys(settings).map(function (key) {
|
|
89
|
-
if (_typeof(settings[key]) === 'object' && settings[key] !== null) {
|
|
90
|
-
intercomSettings.push("".concat(key, ": { ").concat(_this.settingsToString(settings[key]), " }"));
|
|
91
|
-
} else {
|
|
92
|
-
var escapedKey = _this.escapeString(key);
|
|
93
|
-
|
|
94
|
-
var value = _this.escapeString(settings[key]);
|
|
95
|
-
|
|
96
|
-
if (typeof settings[key] === 'string') {
|
|
97
|
-
intercomSettings.push("".concat(escapedKey, ": \"").concat(value, "\""));
|
|
98
|
-
} else {
|
|
99
|
-
intercomSettings.push("".concat(escapedKey, ": ").concat(value));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return intercomSettings.join(', ');
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "escapeString",
|
|
107
|
-
value: function escapeString(string) {
|
|
108
|
-
if (typeof string === 'string') {
|
|
109
|
-
string = _htmlencode["default"].htmlEncode(string).replace(/\"/gi, '\\"');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return string;
|
|
113
|
-
}
|
|
114
|
-
}]);
|
|
115
|
-
|
|
116
|
-
return Snippet;
|
|
117
|
-
}();
|
|
118
|
-
|
|
119
|
-
exports["default"] = Snippet;
|
package/dist/tag.js
DELETED
|
@@ -1,57 +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 Tag = /*#__PURE__*/function () {
|
|
15
|
-
function Tag(client) {
|
|
16
|
-
_classCallCheck(this, Tag);
|
|
17
|
-
|
|
18
|
-
this.client = client;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Tag, [{
|
|
22
|
-
key: "create",
|
|
23
|
-
value: function create(data, f) {
|
|
24
|
-
return this.client.post('/tags', data, f);
|
|
25
|
-
}
|
|
26
|
-
}, {
|
|
27
|
-
key: "tag",
|
|
28
|
-
value: function tag(data, f) {
|
|
29
|
-
return this.client.post('/tags', data, f);
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
key: "untag",
|
|
33
|
-
value: function untag(data, f) {
|
|
34
|
-
(data.users || []).forEach(function (user) {
|
|
35
|
-
user.untag = true;
|
|
36
|
-
});
|
|
37
|
-
(data.companies || []).forEach(function (company) {
|
|
38
|
-
company.untag = true;
|
|
39
|
-
});
|
|
40
|
-
return this.client.post('/tags', data, f);
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "delete",
|
|
44
|
-
value: function _delete(params, f) {
|
|
45
|
-
return this.client["delete"]("/tags/".concat(params.id), {}, f);
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "list",
|
|
49
|
-
value: function list(f) {
|
|
50
|
-
return this.client.get('/tags', {}, f);
|
|
51
|
-
}
|
|
52
|
-
}]);
|
|
53
|
-
|
|
54
|
-
return Tag;
|
|
55
|
-
}();
|
|
56
|
-
|
|
57
|
-
exports["default"] = Tag;
|