intercom-client 2.11.2 → 3.0.1

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.
Files changed (139) hide show
  1. package/README.md +863 -404
  2. package/dist/admin/admin.types.d.ts +13 -0
  3. package/dist/admin/admin.types.d.ts.map +1 -0
  4. package/dist/admin/admin.types.js +3 -0
  5. package/dist/admin/admin.types.js.map +1 -0
  6. package/dist/admin.d.ts +48 -0
  7. package/dist/admin.d.ts.map +1 -0
  8. package/dist/admin.js +40 -44
  9. package/dist/admin.js.map +1 -0
  10. package/dist/article/article.types.d.ts +87 -0
  11. package/dist/article/article.types.d.ts.map +1 -0
  12. package/dist/article/article.types.js +45 -0
  13. package/dist/article/article.types.js.map +1 -0
  14. package/dist/article.d.ts +37 -0
  15. package/dist/article.d.ts.map +1 -0
  16. package/dist/article.js +69 -0
  17. package/dist/article.js.map +1 -0
  18. package/dist/client.d.ts +71 -0
  19. package/dist/client.d.ts.map +1 -0
  20. package/dist/client.js +235 -237
  21. package/dist/client.js.map +1 -0
  22. package/dist/common/common.types.d.ts +64 -0
  23. package/dist/common/common.types.d.ts.map +1 -0
  24. package/dist/common/common.types.js +29 -0
  25. package/dist/common/common.types.js.map +1 -0
  26. package/dist/company/company.types.d.ts +37 -0
  27. package/dist/company/company.types.d.ts.map +1 -0
  28. package/dist/company/company.types.js +3 -0
  29. package/dist/company/company.types.js.map +1 -0
  30. package/dist/company.d.ts +63 -0
  31. package/dist/company.d.ts.map +1 -0
  32. package/dist/company.js +110 -81
  33. package/dist/company.js.map +1 -0
  34. package/dist/contact/contact.types.d.ts +80 -0
  35. package/dist/contact/contact.types.d.ts.map +1 -0
  36. package/dist/contact/contact.types.js +3 -0
  37. package/dist/contact/contact.types.js.map +1 -0
  38. package/dist/contact.d.ts +126 -0
  39. package/dist/contact.d.ts.map +1 -0
  40. package/dist/contact.js +155 -79
  41. package/dist/contact.js.map +1 -0
  42. package/dist/conversation/conversation.types.d.ts +144 -0
  43. package/dist/conversation/conversation.types.d.ts.map +1 -0
  44. package/dist/conversation/conversation.types.js +50 -0
  45. package/dist/conversation/conversation.types.js.map +1 -0
  46. package/dist/conversation.d.ts +176 -0
  47. package/dist/conversation.d.ts.map +1 -0
  48. package/dist/conversation.js +287 -46
  49. package/dist/conversation.js.map +1 -0
  50. package/dist/dataAttribute/dataAttribute.types.d.ts +32 -0
  51. package/dist/dataAttribute/dataAttribute.types.d.ts.map +1 -0
  52. package/dist/dataAttribute/dataAttribute.types.js +18 -0
  53. package/dist/dataAttribute/dataAttribute.types.js.map +1 -0
  54. package/dist/dataAttribute.d.ts +33 -0
  55. package/dist/dataAttribute.d.ts.map +1 -0
  56. package/dist/dataAttribute.js +49 -0
  57. package/dist/dataAttribute.js.map +1 -0
  58. package/dist/errors/badResponse.error.d.ts +9 -0
  59. package/dist/errors/badResponse.error.d.ts.map +1 -0
  60. package/dist/errors/badResponse.error.js +21 -0
  61. package/dist/errors/badResponse.error.js.map +1 -0
  62. package/dist/event/event.types.d.ts +29 -0
  63. package/dist/event/event.types.d.ts.map +1 -0
  64. package/dist/event/event.types.js +3 -0
  65. package/dist/event/event.types.js.map +1 -0
  66. package/dist/event.d.ts +41 -0
  67. package/dist/event.d.ts.map +1 -0
  68. package/dist/event.js +42 -43
  69. package/dist/event.js.map +1 -0
  70. package/dist/helpCenter/helpCenter.types.d.ts +23 -0
  71. package/dist/helpCenter/helpCenter.types.d.ts.map +1 -0
  72. package/dist/helpCenter/helpCenter.types.js +3 -0
  73. package/dist/helpCenter/helpCenter.types.js.map +1 -0
  74. package/dist/helpCenter.d.ts +61 -0
  75. package/dist/helpCenter.d.ts.map +1 -0
  76. package/dist/helpCenter.js +121 -0
  77. package/dist/helpCenter.js.map +1 -0
  78. package/dist/index.d.ts +25 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +57 -74
  81. package/dist/index.js.map +1 -0
  82. package/dist/message/message.types.d.ts +17 -0
  83. package/dist/message/message.types.d.ts.map +1 -0
  84. package/dist/message/message.types.js +11 -0
  85. package/dist/message/message.types.js.map +1 -0
  86. package/dist/message.d.ts +30 -0
  87. package/dist/message.d.ts.map +1 -0
  88. package/dist/message.js +32 -29
  89. package/dist/message.js.map +1 -0
  90. package/dist/package.json +59 -0
  91. package/dist/scroll.d.ts +24 -0
  92. package/dist/scroll.d.ts.map +1 -0
  93. package/dist/scroll.js +67 -77
  94. package/dist/scroll.js.map +1 -0
  95. package/dist/segment/segment.types.d.ts +11 -0
  96. package/dist/segment/segment.types.d.ts.map +1 -0
  97. package/dist/segment/segment.types.js +3 -0
  98. package/dist/segment/segment.types.js.map +1 -0
  99. package/dist/segment.d.ts +22 -0
  100. package/dist/segment.d.ts.map +1 -0
  101. package/dist/segment.js +26 -34
  102. package/dist/segment.js.map +1 -0
  103. package/dist/subscription/subscription.types.d.ts +19 -0
  104. package/dist/subscription/subscription.types.d.ts.map +1 -0
  105. package/dist/subscription/subscription.types.js +10 -0
  106. package/dist/subscription/subscription.types.js.map +1 -0
  107. package/dist/tag/tag.types.d.ts +6 -0
  108. package/dist/tag/tag.types.d.ts.map +1 -0
  109. package/dist/tag/tag.types.js +3 -0
  110. package/dist/tag/tag.types.js.map +1 -0
  111. package/dist/tag.d.ts +52 -0
  112. package/dist/tag.d.ts.map +1 -0
  113. package/dist/tag.js +93 -55
  114. package/dist/tag.js.map +1 -0
  115. package/dist/team/team.types.d.ts +7 -0
  116. package/dist/team/team.types.d.ts.map +1 -0
  117. package/dist/team/team.types.js +3 -0
  118. package/dist/team/team.types.js.map +1 -0
  119. package/dist/team.d.ts +18 -0
  120. package/dist/team.d.ts.map +1 -0
  121. package/dist/team.js +23 -0
  122. package/dist/team.js.map +1 -0
  123. package/dist/util/time.d.ts +3 -0
  124. package/dist/util/time.d.ts.map +1 -0
  125. package/dist/util/time.js +6 -0
  126. package/dist/util/time.js.map +1 -0
  127. package/dist/util/url.d.ts +3 -0
  128. package/dist/util/url.d.ts.map +1 -0
  129. package/dist/util/url.js +9 -0
  130. package/dist/util/url.js.map +1 -0
  131. package/package.json +57 -49
  132. package/dist/bulk.js +0 -53
  133. package/dist/counts.js +0 -86
  134. package/dist/customer.js +0 -31
  135. package/dist/note.js +0 -41
  136. package/dist/snippet.js +0 -119
  137. package/dist/user-data.js +0 -103
  138. package/dist/user.js +0 -118
  139. package/dist/visitor.js +0 -52
@@ -0,0 +1,7 @@
1
+ export interface TeamObject {
2
+ type: 'team';
3
+ id: string;
4
+ name: string;
5
+ admin_ids: string[];
6
+ }
7
+ //# sourceMappingURL=team.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.types.d.ts","sourceRoot":"","sources":["../../../lib/team/team.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACvB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=team.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.types.js","sourceRoot":"","sources":["../../../lib/team/team.types.ts"],"names":[],"mappings":""}
package/dist/team.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { Client } from '.';
2
+ import { TeamObject } from './team/team.types';
3
+ export default class Team {
4
+ private readonly client;
5
+ private readonly baseUrl;
6
+ constructor(client: Client);
7
+ find({ id }: FindTeamData): Promise<TeamObject>;
8
+ list(): Promise<ListTeamsResponse>;
9
+ }
10
+ interface FindTeamData {
11
+ id: string;
12
+ }
13
+ interface ListTeamsResponse {
14
+ type: 'team.list';
15
+ teams: TeamObject[];
16
+ }
17
+ export {};
18
+ //# sourceMappingURL=team.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.d.ts","sourceRoot":"","sources":["../../lib/team.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,IAAI;IAGT,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;gBAEN,MAAM,EAAE,MAAM;IAI3C,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY;IAMzB,IAAI;CAKP;AAED,UAAU,YAAY;IAClB,EAAE,EAAE,MAAM,CAAC;CACd;AAED,UAAU,iBAAiB;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,UAAU,EAAE,CAAC;CACvB"}
package/dist/team.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Team = /** @class */ (function () {
4
+ function Team(client) {
5
+ this.client = client;
6
+ this.baseUrl = 'teams';
7
+ this.client = client;
8
+ }
9
+ Team.prototype.find = function (_a) {
10
+ var id = _a.id;
11
+ return this.client.get({
12
+ url: "/".concat(this.baseUrl, "/").concat(id),
13
+ });
14
+ };
15
+ Team.prototype.list = function () {
16
+ return this.client.get({
17
+ url: "/".concat(this.baseUrl),
18
+ });
19
+ };
20
+ return Team;
21
+ }());
22
+ exports.default = Team;
23
+ //# sourceMappingURL=team.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.js","sourceRoot":"","sources":["../../lib/team.ts"],"names":[],"mappings":";;AAGA;IAGI,cAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAF1B,YAAO,GAAG,OAAO,CAAC;QAG/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,mBAAI,GAAJ,UAAK,EAAoB;YAAlB,EAAE,QAAA;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAa;YAC/B,GAAG,EAAE,WAAI,IAAI,CAAC,OAAO,cAAI,EAAE,CAAE;SAChC,CAAC,CAAC;IACP,CAAC;IAED,mBAAI,GAAJ;QACI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAoB;YACtC,GAAG,EAAE,WAAI,IAAI,CAAC,OAAO,CAAE;SAC1B,CAAC,CAAC;IACP,CAAC;IACL,WAAC;AAAD,CAAC,AAlBD,IAkBC"}
@@ -0,0 +1,3 @@
1
+ import { Timestamp } from "../common/common.types";
2
+ export declare const dateToUnixTimestamp: (date: Date) => Timestamp;
3
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../lib/util/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,eAAO,MAAM,mBAAmB,SAAU,IAAI,KAAG,SAA8C,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateToUnixTimestamp = void 0;
4
+ var dateToUnixTimestamp = function (date) { return Math.floor(date.getTime() / 1000); };
5
+ exports.dateToUnixTimestamp = dateToUnixTimestamp;
6
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../../../lib/util/time.ts"],"names":[],"mappings":";;;AAEO,IAAM,mBAAmB,GAAG,UAAC,IAAU,IAAgB,OAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,EAAjC,CAAiC,CAAC;AAAnF,QAAA,mBAAmB,uBAAgE"}
@@ -0,0 +1,3 @@
1
+ import { URLSearchParams } from 'url';
2
+ export declare const encodeParamsForURL: (params: Record<string, string | ReadonlyArray<string>>) => URLSearchParams;
3
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../lib/util/url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAGtC,eAAO,MAAM,kBAAkB,WACnB,OAAO,MAAM,EAAE,MAAM,GAAG,cAAc,MAAM,CAAC,CAAC,KACvD,eAAmE,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeParamsForURL = void 0;
4
+ var url_1 = require("url");
5
+ var lodash_1 = require("lodash");
6
+ var encodeParamsForURL = function (params) { return new url_1.URLSearchParams(purifyFromEmptiness(params)); };
7
+ exports.encodeParamsForURL = encodeParamsForURL;
8
+ var purifyFromEmptiness = function (object) { return (0, lodash_1.omitBy)(object, lodash_1.isEmpty); };
9
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../../lib/util/url.ts"],"names":[],"mappings":";;;AAAA,2BAAsC;AACtC,iCAAyC;AAElC,IAAM,kBAAkB,GAAG,UAC9B,MAAsD,IACpC,OAAA,IAAI,qBAAe,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,EAAhD,CAAgD,CAAC;AAF1D,QAAA,kBAAkB,sBAEwC;AAEvE,IAAM,mBAAmB,GAAG,UACxB,MAAsD,IACL,OAAA,IAAA,eAAM,EAAC,MAAM,EAAE,gBAAO,CAAC,EAAvB,CAAuB,CAAC"}
package/package.json CHANGED
@@ -1,51 +1,59 @@
1
1
  {
2
- "name": "intercom-client",
3
- "version": "2.11.2",
4
- "description": "Official Node bindings to the Intercom API",
5
- "homepage": "https://github.com/intercom/intercom-node",
6
- "bugs:": "https://github.com/intercom/intercom-node/issues",
7
- "repository": "intercom/intercom-node",
8
- "author": {
9
- "name": "Bob Long",
10
- "email": "bob@intercom.io"
11
- },
12
- "files": [
13
- "dist"
14
- ],
15
- "main": "dist/index.js",
16
- "keywords": [
17
- "intercom",
18
- "api"
19
- ],
20
- "dependencies": {
21
- "bluebird": "^3.7.2",
22
- "htmlencode": "^0.0.4",
23
- "lodash": "^4.17.19",
24
- "request": "^2.88.0"
25
- },
26
- "devDependencies": {
27
- "@babel/core": "^7.13.16",
28
- "@babel/preset-env": "^7.13.15",
29
- "@babel/register": "^7.13.16",
30
- "babel-eslint": "^10.0.2",
31
- "eslint": "^6.8.0",
32
- "gulp": "^4.0.2",
33
- "gulp-babel": "^8.0.0",
34
- "gulp-cli": "^2.2.0",
35
- "gulp-eslint": "4.0.2",
36
- "gulp-exclude-gitignore": "^1.0.0",
37
- "gulp-istanbul": "^1.1.3",
38
- "gulp-mocha": "^6.0.0",
39
- "gulp-plumber": "^1.2.1",
40
- "nock": "^13.0.11",
41
- "sinon": "^7.3.2"
42
- },
43
- "scripts": {
44
- "prepublish": "gulp prepublish",
45
- "test": "gulp"
46
- },
47
- "engines": {
48
- "node": ">= v0.10.0"
49
- },
50
- "license": "Apache-2.0"
2
+ "name": "intercom-client",
3
+ "version": "3.0.1",
4
+ "description": "Official Node bindings to the Intercom API",
5
+ "homepage": "https://github.com/intercom/intercom-node",
6
+ "bugs:": "https://github.com/intercom/intercom-node/issues",
7
+ "repository": "intercom/intercom-node",
8
+ "author": {
9
+ "name": "Bob Long",
10
+ "email": "bob@intercom.io"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "main": "dist/index.js",
16
+ "keywords": [
17
+ "intercom",
18
+ "api"
19
+ ],
20
+ "dependencies": {
21
+ "axios": "^0.24.0",
22
+ "htmlencode": "^0.0.4",
23
+ "lodash": "^4.17.21"
24
+ },
25
+ "devDependencies": {
26
+ "@istanbuljs/nyc-config-typescript": "^1.0.2",
27
+ "@types/lodash": "^4.14.176",
28
+ "@types/mocha": "^9.1.0",
29
+ "@types/node": "^16.11.6",
30
+ "@types/sinon": "^10.0.6",
31
+ "@typescript-eslint/eslint-plugin": "^5.7.0",
32
+ "@typescript-eslint/parser": "^5.7.0",
33
+ "eslint": "^8.2.0",
34
+ "eslint-config-prettier": "^8.3.0",
35
+ "merge2": "^1.4.1",
36
+ "mocha": "^9.2.0",
37
+ "nock": "^13.0.11",
38
+ "nyc": "^15.1.0",
39
+ "prettier": "^2.5.1",
40
+ "sinon": "^7.3.2",
41
+ "ts-node": "^10.4.0",
42
+ "tslib": "^2.3.1",
43
+ "typescript": "^4.5.3"
44
+ },
45
+ "scripts": {
46
+ "clean": "rm -r -f dist",
47
+ "static": "eslint .",
48
+ "compile_ts": "tsc",
49
+ "move_compiled_to_dist": "mv dist/lib/* dist && rmdir dist/lib",
50
+ "prepublish": "yarn clean && yarn static && yarn compile_ts && yarn move_compiled_to_dist",
51
+ "test": "mocha -r ts-node/register test/*.ts",
52
+ "coverage": "nyc yarn test"
53
+ },
54
+ "engines": {
55
+ "node": ">= v8.0.0"
56
+ },
57
+ "license": "Apache-2.0",
58
+ "packageManager": "yarn@3.1.1"
51
59
  }
package/dist/bulk.js DELETED
@@ -1,53 +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 Bulk = /*#__PURE__*/function () {
15
- function Bulk(client, dataType) {
16
- _classCallCheck(this, Bulk);
17
-
18
- this.client = client;
19
- this.dataType = dataType;
20
- }
21
-
22
- _createClass(Bulk, [{
23
- key: "bulk",
24
- value: function bulk(bulkOperations, f) {
25
- var dataType = this.dataType;
26
- var bulkParams = {
27
- items: []
28
- };
29
- var url = "/bulk/".concat(dataType, "s");
30
- bulkOperations.forEach(function (params) {
31
- for (var k in params) {
32
- var data = params[k];
33
- var method = k === 'create' ? 'post' : k;
34
-
35
- if (method !== 'post' && method !== 'delete') {
36
- throw new Error("Unknown bulk type: ".concat(method));
37
- }
38
-
39
- bulkParams.items.push({
40
- method: method,
41
- data_type: dataType,
42
- data: data
43
- });
44
- }
45
- });
46
- return this.client.post(url, bulkParams, f);
47
- }
48
- }]);
49
-
50
- return Bulk;
51
- }();
52
-
53
- exports["default"] = Bulk;
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/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/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(/\&quot;/gi, '\\"');
110
- }
111
-
112
- return string;
113
- }
114
- }]);
115
-
116
- return Snippet;
117
- }();
118
-
119
- exports["default"] = Snippet;