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/dist/user-data.js DELETED
@@ -1,103 +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 UserData = /*#__PURE__*/function () {
23
- function UserData(settings) {
24
- _classCallCheck(this, UserData);
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(UserData, [{
40
- key: "json",
41
- value: function json() {
42
- this.setUserHash();
43
- return this.escapedSettings(this.settings);
44
- }
45
- }, {
46
- key: "getVerificationSecret",
47
- value: function getVerificationSecret() {
48
- var verificationSecret = this.settings.verificationSecret;
49
- delete this.settings.verificationSecret;
50
- return verificationSecret;
51
- }
52
- }, {
53
- key: "setUserHash",
54
- value: function setUserHash() {
55
- if (this.loggedOut || this.settings.user_hash !== undefined) {
56
- return;
57
- }
58
-
59
- var verificationSecret = this.settings.verificationSecret;
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
-
82
- var value = _this.escapeString(settings[key]);
83
-
84
- intercomSettings[escapedKey] = value;
85
- }
86
- });
87
- return intercomSettings;
88
- }
89
- }, {
90
- key: "escapeString",
91
- value: function escapeString(string) {
92
- if (typeof string === 'string') {
93
- string = _htmlencode["default"].htmlEncode(string).replace(/\&quot;/gi, '\\"');
94
- }
95
-
96
- return string;
97
- }
98
- }]);
99
-
100
- return UserData;
101
- }();
102
-
103
- exports["default"] = UserData;
package/dist/user.js DELETED
@@ -1,118 +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 = /*#__PURE__*/function () {
23
- function User(client) {
24
- _classCallCheck(this, User);
25
-
26
- this.client = client;
27
- this.scroll = new _scroll["default"](this.client, 'user'); // Keep this API around but mark it deprecated
28
-
29
- this["delete"] = (0, _util.deprecate)(this.archive.bind(this), 'intercom-client - user.delete: Use user.archive instead');
30
- }
31
-
32
- _createClass(User, [{
33
- key: "create",
34
- value: function create(data, f) {
35
- return this.client.post('/users', data, f);
36
- }
37
- }, {
38
- key: "update",
39
- value: function update(data, f) {
40
- return this.create(data, f);
41
- }
42
- }, {
43
- key: "list",
44
- value: function list(f) {
45
- return this.client.get('/users', {}, f);
46
- }
47
- }, {
48
- key: "listBy",
49
- value: function listBy(params, f) {
50
- return this.client.get('/users', params, f);
51
- }
52
- }, {
53
- key: "find",
54
- value: function find(params, f) {
55
- if (params.id) {
56
- return this.client.get("/users/".concat(params.id), {}, f);
57
- } else if (params.user_id) {
58
- return this.client.get('/users', {
59
- user_id: params.user_id
60
- }, f);
61
- } else if (params.email) {
62
- return this.client.get('/users', {
63
- email: params.email
64
- }, f);
65
- }
66
- }
67
- }, {
68
- key: "archive",
69
- value: function archive(params, f) {
70
- if (params.id) {
71
- return this.client["delete"]("/users/".concat(params.id), {}, f);
72
- } else if (params.user_id) {
73
- return this.client["delete"]('/users', {
74
- user_id: params.user_id
75
- }, f);
76
- } else if (params.email) {
77
- return this.client["delete"]('/users', {
78
- email: params.email
79
- }, f);
80
- }
81
- }
82
- }, {
83
- key: "bulk",
84
- value: function bulk(params, f) {
85
- return new _bulk["default"](this.client, 'user').bulk(params, f);
86
- }
87
- }, {
88
- key: "requestPermanentDeletion",
89
- value: function requestPermanentDeletion(intercom_user_id, f) {
90
- return this.client.post('/user_delete_requests', {
91
- intercom_user_id: intercom_user_id
92
- }, f);
93
- }
94
- }, {
95
- key: "requestPermanentDeletionByParams",
96
- value: function requestPermanentDeletionByParams(params, f) {
97
- var _this = this;
98
-
99
- if (params.id) {
100
- return this.requestPermanentDeletion(params.id, f);
101
- }
102
-
103
- return this.find(params).then(function (res) {
104
- return _this.requestPermanentDeletion(res.body.id, f);
105
- })["catch"](function (err) {
106
- if (f) {
107
- return f(err);
108
- }
109
-
110
- throw err;
111
- });
112
- }
113
- }]);
114
-
115
- return User;
116
- }();
117
-
118
- exports["default"] = User;
package/dist/visitor.js DELETED
@@ -1,52 +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 = /*#__PURE__*/function () {
15
- function Visitor(client) {
16
- _classCallCheck(this, Visitor);
17
-
18
- this.client = client;
19
- }
20
-
21
- _createClass(Visitor, [{
22
- key: "update",
23
- value: function update(params, f) {
24
- return this.client.post('/visitors', params, f);
25
- }
26
- }, {
27
- key: "find",
28
- value: function find(params, f) {
29
- if (params.id) {
30
- return this.client.get("/visitors/".concat(params.id), {}, f);
31
- } else if (params.user_id) {
32
- return this.client.get('/visitors', {
33
- user_id: params.user_id
34
- }, f);
35
- }
36
- }
37
- }, {
38
- key: "delete",
39
- value: function _delete(params, f) {
40
- return this.client["delete"]("/visitors/".concat(params.id), {}, f);
41
- }
42
- }, {
43
- key: "convert",
44
- value: function convert(params, f) {
45
- return this.client.post('/visitors/convert', params, f);
46
- }
47
- }]);
48
-
49
- return Visitor;
50
- }();
51
-
52
- exports["default"] = Visitor;