intercom-client 3.0.1 → 3.1.3
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 +141 -11
- package/dist/admin/admin.types.d.ts +3 -1
- package/dist/admin/admin.types.d.ts.map +1 -1
- package/dist/article.d.ts +1 -4
- package/dist/article.d.ts.map +1 -1
- package/dist/article.js.map +1 -1
- package/dist/client.d.ts +8 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +107 -28
- package/dist/client.js.map +1 -1
- package/dist/common/common.types.d.ts +9 -4
- package/dist/common/common.types.d.ts.map +1 -1
- package/dist/common/common.types.js.map +1 -1
- package/dist/company.js +4 -2
- package/dist/company.js.map +1 -1
- package/dist/contact.d.ts +6 -12
- package/dist/contact.d.ts.map +1 -1
- package/dist/contact.js +3 -2
- package/dist/contact.js.map +1 -1
- package/dist/conversation.d.ts +5 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/count/count.types.d.ts +89 -0
- package/dist/count/count.types.d.ts.map +1 -0
- package/dist/count/count.types.js +17 -0
- package/dist/count/count.types.js.map +1 -0
- package/dist/count.d.ts +18 -0
- package/dist/count.d.ts.map +1 -0
- package/dist/count.js +72 -0
- package/dist/count.js.map +1 -0
- package/dist/errors/badResponse.error.js +16 -2
- package/dist/errors/badResponse.error.js.map +1 -1
- package/dist/helpCenter.d.ts +1 -4
- package/dist/helpCenter.d.ts.map +1 -1
- package/dist/helpCenter.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/note/note.types.d.ts +13 -0
- package/dist/note/note.types.d.ts.map +1 -0
- package/dist/note/note.types.js +3 -0
- package/dist/note/note.types.js.map +1 -0
- package/dist/note.d.ts +24 -0
- package/dist/note.d.ts.map +1 -0
- package/dist/note.js +40 -0
- package/dist/note.js.map +1 -0
- package/dist/package.json +1 -1
- package/dist/scroll.js +68 -8
- package/dist/scroll.js.map +1 -1
- package/dist/visitor/visitor.types.d.ts +20 -0
- package/dist/visitor/visitor.types.d.ts.map +1 -0
- package/dist/visitor/visitor.types.js +3 -0
- package/dist/visitor/visitor.types.js.map +1 -0
- package/dist/visitor.d.ts +50 -0
- package/dist/visitor.d.ts.map +1 -0
- package/dist/visitor.js +60 -0
- package/dist/visitor.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminObject, Timestamp } from '..';
|
|
2
|
+
export declare type NoteObject = {
|
|
3
|
+
type: 'note';
|
|
4
|
+
id: string;
|
|
5
|
+
created_at: Timestamp;
|
|
6
|
+
contact: {
|
|
7
|
+
type: 'contact';
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
author?: Pick<AdminObject, 'type' | 'id' | 'name' | 'email' | 'away_mode_enabled' | 'away_mode_reassign' | 'avatar'>;
|
|
11
|
+
body: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=note.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note.types.d.ts","sourceRoot":"","sources":["../../../lib/note/note.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE5C,oBAAY,UAAU,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,SAAS,CAAC;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,SAAS,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,CAAC,EAAE,IAAI,CACT,WAAW,EACT,MAAM,GACN,IAAI,GACJ,MAAM,GACN,OAAO,GACP,mBAAmB,GACnB,oBAAoB,GACpB,QAAQ,CACb,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note.types.js","sourceRoot":"","sources":["../../../lib/note/note.types.ts"],"names":[],"mappings":""}
|
package/dist/note.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Client, NoteObject } from '.';
|
|
2
|
+
import { OperationById, Paginated } from './common/common.types';
|
|
3
|
+
export default class Note {
|
|
4
|
+
private readonly client;
|
|
5
|
+
readonly baseUrl = "notes";
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
create({ adminId, body, contactId }: CreateNoteData): Promise<NoteObject>;
|
|
8
|
+
find({ id }: FindNoteByIdData): Promise<NoteObject>;
|
|
9
|
+
list({ contactId, page, perPage: per_page }: ListNotesData): Promise<ListNotesResponse>;
|
|
10
|
+
}
|
|
11
|
+
interface CreateNoteData {
|
|
12
|
+
adminId: string;
|
|
13
|
+
body: string;
|
|
14
|
+
contactId: string;
|
|
15
|
+
}
|
|
16
|
+
declare type FindNoteByIdData = OperationById;
|
|
17
|
+
declare type ListNotesData = {
|
|
18
|
+
contactId: string;
|
|
19
|
+
page?: number;
|
|
20
|
+
perPage?: number;
|
|
21
|
+
};
|
|
22
|
+
declare type ListNotesResponse = Paginated<NoteObject>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=note.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../lib/note.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,IAAI;IAGT,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,SAAgB,OAAO,WAAW;gBAEL,MAAM,EAAE,MAAM;IAI3C,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,cAAc;IAWnD,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,gBAAgB;IAK7B,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,aAAa;CAW7D;AAED,UAAU,cAAc;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,aAAK,gBAAgB,GAAG,aAAa,CAAC;AAEtC,aAAK,aAAa,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,aAAK,iBAAiB,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC"}
|
package/dist/note.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Note = /** @class */ (function () {
|
|
4
|
+
function Note(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
this.baseUrl = 'notes';
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
Note.prototype.create = function (_a) {
|
|
10
|
+
var adminId = _a.adminId, body = _a.body, contactId = _a.contactId;
|
|
11
|
+
var data = {
|
|
12
|
+
admin_id: adminId,
|
|
13
|
+
body: body,
|
|
14
|
+
};
|
|
15
|
+
return this.client.post({
|
|
16
|
+
url: "/".concat(this.client.contacts.baseUrl, "/").concat(contactId, "/").concat(this.baseUrl),
|
|
17
|
+
data: data,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Note.prototype.find = function (_a) {
|
|
21
|
+
var id = _a.id;
|
|
22
|
+
return this.client.get({
|
|
23
|
+
url: "/".concat(this.baseUrl, "/").concat(id),
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Note.prototype.list = function (_a) {
|
|
27
|
+
var contactId = _a.contactId, page = _a.page, per_page = _a.perPage;
|
|
28
|
+
var params = {
|
|
29
|
+
page: page,
|
|
30
|
+
per_page: per_page,
|
|
31
|
+
};
|
|
32
|
+
return this.client.get({
|
|
33
|
+
url: "/".concat(this.client.contacts.baseUrl, "/").concat(contactId, "/").concat(this.baseUrl),
|
|
34
|
+
params: params,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return Note;
|
|
38
|
+
}());
|
|
39
|
+
exports.default = Note;
|
|
40
|
+
//# sourceMappingURL=note.js.map
|
package/dist/note.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note.js","sourceRoot":"","sources":["../../lib/note.ts"],"names":[],"mappings":";;AAGA;IAGI,cAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAF3B,YAAO,GAAG,OAAO,CAAC;QAG9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,qBAAM,GAAN,UAAO,EAA4C;YAA1C,OAAO,aAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA;QAC7B,IAAM,IAAI,GAAG;YACT,QAAQ,EAAE,OAAO;YACjB,IAAI,MAAA;SACP,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAa;YAChC,GAAG,EAAE,WAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,cAAI,SAAS,cAAI,IAAI,CAAC,OAAO,CAAE;YACpE,IAAI,MAAA;SACP,CAAC,CAAC;IACP,CAAC;IACD,mBAAI,GAAJ,UAAK,EAAwB;YAAtB,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;IACD,mBAAI,GAAJ,UAAK,EAAqD;YAAnD,SAAS,eAAA,EAAE,IAAI,UAAA,EAAW,QAAQ,aAAA;QACrC,IAAM,MAAM,GAAG;YACX,IAAI,MAAA;YACJ,QAAQ,UAAA;SACX,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAoB;YACtC,GAAG,EAAE,WAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,cAAI,SAAS,cAAI,IAAI,CAAC,OAAO,CAAE;YACpE,MAAM,QAAA;SACT,CAAC,CAAC;IACP,CAAC;IACL,WAAC;AAAD,CAAC,AAlCD,IAkCC"}
|
package/dist/package.json
CHANGED
package/dist/scroll.js
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
2
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
64
|
var Scroll = /** @class */ (function () {
|
|
5
65
|
function Scroll(client, scrollUrlDataType, scrollParam) {
|
|
6
66
|
this.client = client;
|
|
@@ -11,8 +71,8 @@ var Scroll = /** @class */ (function () {
|
|
|
11
71
|
}
|
|
12
72
|
Scroll.prototype.each = function (params) {
|
|
13
73
|
var _a;
|
|
14
|
-
return
|
|
15
|
-
return
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
return __generator(this, function (_b) {
|
|
16
76
|
this.scrollParam = (_a = params.scrollParam) !== null && _a !== void 0 ? _a : undefined;
|
|
17
77
|
return [2 /*return*/, this.eachInternal()];
|
|
18
78
|
});
|
|
@@ -20,9 +80,9 @@ var Scroll = /** @class */ (function () {
|
|
|
20
80
|
};
|
|
21
81
|
Scroll.prototype.eachInternal = function (storedData) {
|
|
22
82
|
if (storedData === void 0) { storedData = []; }
|
|
23
|
-
return
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
24
84
|
var response, dataFromResponse, combinedData;
|
|
25
|
-
return
|
|
85
|
+
return __generator(this, function (_a) {
|
|
26
86
|
switch (_a.label) {
|
|
27
87
|
case 0: return [4 /*yield*/, this.client.get({
|
|
28
88
|
url: this.scrollUrl(),
|
|
@@ -30,7 +90,7 @@ var Scroll = /** @class */ (function () {
|
|
|
30
90
|
case 1:
|
|
31
91
|
response = _a.sent();
|
|
32
92
|
dataFromResponse = response.data;
|
|
33
|
-
combinedData =
|
|
93
|
+
combinedData = __spreadArray(__spreadArray([], __read(dataFromResponse), false), __read(storedData), false);
|
|
34
94
|
if (dataFromResponse.length > 0) {
|
|
35
95
|
this.scrollParam = response.scroll_param;
|
|
36
96
|
return [2 /*return*/, this.eachInternal(combinedData)];
|
|
@@ -42,9 +102,9 @@ var Scroll = /** @class */ (function () {
|
|
|
42
102
|
};
|
|
43
103
|
Scroll.prototype.next = function (_a) {
|
|
44
104
|
var scrollParam = _a.scrollParam;
|
|
45
|
-
return
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
106
|
var response;
|
|
47
|
-
return
|
|
107
|
+
return __generator(this, function (_b) {
|
|
48
108
|
switch (_b.label) {
|
|
49
109
|
case 0:
|
|
50
110
|
this.scrollParam = scrollParam;
|
package/dist/scroll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../lib/scroll.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../lib/scroll.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IACI,gBACqB,MAAc,EACd,iBAAyB,EAClC,WAAoB;QAFX,WAAM,GAAN,MAAM,CAAQ;QACd,sBAAiB,GAAjB,iBAAiB,CAAQ;QAClC,gBAAW,GAAX,WAAW,CAAS;QAE5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAEK,qBAAI,GAAV,UAAW,MAAgB;;;;gBACvB,IAAI,CAAC,WAAW,GAAG,MAAA,MAAM,CAAC,WAAW,mCAAI,SAAS,CAAC;gBAEnD,sBAAO,IAAI,CAAC,YAAY,EAAE,EAAC;;;KAC9B;IAEK,6BAAY,GAAlB,UAAmB,UAA6B;QAA7B,2BAAA,EAAA,eAA6B;;;;;4BAC3B,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAiC;4BACnE,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE;yBACxB,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBACI,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CAAC;wBACjC,YAAY,0CAAO,gBAAgB,kBAAK,UAAU,SAAC,CAAC;wBAE1D,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;4BAC7B,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC;4BACzC,sBAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAC;yBAC1C;wBAED,sBAAO,YAAY,EAAC;;;;KACvB;IAEK,qBAAI,GAAV,UAAW,EAEA;YADP,WAAW,iBAAA;;;;;;wBAEX,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;wBAEd,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAiC;gCACnE,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE;6BACxB,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBAEF,sBAAO,QAAQ,EAAC;;;;KACnB;IAED,0BAAS,GAAT;QACI,IAAM,aAAa,GAAG,WAAI,IAAI,CAAC,iBAAiB,YAAS,CAAC;QAE1D,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAClD,CAAC,CAAC,UAAG,aAAa,2BAAiB,IAAI,CAAC,WAAW,CAAE;YACrD,CAAC,CAAC,aAAa,CAAC;IACxB,CAAC;IACL,aAAC;AAAD,CAAC,AAlDD,IAkDC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JavascriptObject, SegmentObject, TagObject, Timestamp } from '..';
|
|
2
|
+
export declare type VisitorObject = {
|
|
3
|
+
type: 'visitor';
|
|
4
|
+
id: string;
|
|
5
|
+
created_at: Timestamp;
|
|
6
|
+
updated_at: Timestamp;
|
|
7
|
+
user_id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
custom_attributes: JavascriptObject;
|
|
10
|
+
last_request_at: Timestamp;
|
|
11
|
+
avatar: string | {
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
unsubscribed_from_emails: boolean;
|
|
15
|
+
location_data: JavascriptObject;
|
|
16
|
+
social_profiles: JavascriptObject[];
|
|
17
|
+
segments: SegmentObject[];
|
|
18
|
+
tags: TagObject[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=visitor.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor.types.d.ts","sourceRoot":"","sources":["../../../lib/visitor/visitor.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE3E,oBAAY,aAAa,GAAG;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,SAAS,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,gBAAgB,CAAC;IACpC,eAAe,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACjC,wBAAwB,EAAE,OAAO,CAAC;IAClC,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,gBAAgB,EAAE,CAAC;IACpC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,IAAI,EAAE,SAAS,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor.types.js","sourceRoot":"","sources":["../../../lib/visitor/visitor.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Client, ContactObject } from '.';
|
|
2
|
+
import { Role } from './common/common.types';
|
|
3
|
+
import { VisitorObject } from './visitor/visitor.types';
|
|
4
|
+
export default class Visitor {
|
|
5
|
+
private readonly client;
|
|
6
|
+
readonly baseUrl = "visitors";
|
|
7
|
+
constructor(client: Client);
|
|
8
|
+
find({ id, userId }: FindVisitorByIdData): Promise<VisitorObject>;
|
|
9
|
+
update({ id, userId, name, customAttributes }: UpdateVisitorData): Promise<VisitorObject>;
|
|
10
|
+
delete({ id }: DeleteVisitorByIdData): Promise<VisitorObject>;
|
|
11
|
+
mergeToContact({ visitor, user, type }: MergeVisitorToContactData): Promise<ContactObject>;
|
|
12
|
+
}
|
|
13
|
+
export declare type IdentificationForVisitor = {
|
|
14
|
+
id: string;
|
|
15
|
+
userId?: never;
|
|
16
|
+
} | {
|
|
17
|
+
id?: never;
|
|
18
|
+
userId: string;
|
|
19
|
+
};
|
|
20
|
+
declare type FindVisitorByIdData = IdentificationForVisitor;
|
|
21
|
+
declare type UpdateVisitorData = IdentificationForVisitor & {
|
|
22
|
+
name?: string;
|
|
23
|
+
customAttributes?: VisitorObject['custom_attributes'];
|
|
24
|
+
};
|
|
25
|
+
declare type DeleteVisitorByIdData = {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
export declare type MergeVisitorToContactData = {
|
|
29
|
+
visitor: VisitorObjectForMerge;
|
|
30
|
+
user: ContactObjectForMerge;
|
|
31
|
+
type: Role;
|
|
32
|
+
};
|
|
33
|
+
export declare type VisitorObjectForMerge = {
|
|
34
|
+
id: string;
|
|
35
|
+
userId?: never;
|
|
36
|
+
email?: never;
|
|
37
|
+
} | {
|
|
38
|
+
id?: never;
|
|
39
|
+
userId: string;
|
|
40
|
+
email?: never;
|
|
41
|
+
} | {
|
|
42
|
+
id?: never;
|
|
43
|
+
userId?: never;
|
|
44
|
+
email: string;
|
|
45
|
+
};
|
|
46
|
+
export declare type ContactObjectForMerge = IdentificationForVisitor & {
|
|
47
|
+
email?: string;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=visitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../lib/visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,OAAO;IAGZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,SAAgB,OAAO,cAAc;gBAER,MAAM,EAAE,MAAM;IAI3C,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,mBAAmB;IASxC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,iBAAiB;IAahE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,qBAAqB;IAKpC,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,yBAAyB;CAoBpE;AAED,oBAAY,wBAAwB,GAC9B;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,GAC9B;IAAE,EAAE,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC,aAAK,mBAAmB,GAAG,wBAAwB,CAAC;AAEpD,aAAK,iBAAiB,GAAG,wBAAwB,GAAG;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CACzD,CAAC;AAEF,aAAK,qBAAqB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C,oBAAY,yBAAyB,GAAG;IACpC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,oBAAY,qBAAqB,GAC3B;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC7C;IAAE,EAAE,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC7C;IAAE,EAAE,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD,oBAAY,qBAAqB,GAAG,wBAAwB,GAAG;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/dist/visitor.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Visitor = /** @class */ (function () {
|
|
4
|
+
function Visitor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
this.baseUrl = 'visitors';
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
Visitor.prototype.find = function (_a) {
|
|
10
|
+
var id = _a.id, userId = _a.userId;
|
|
11
|
+
var query = userId ? { user_id: userId } : {};
|
|
12
|
+
var url = "/".concat(this.baseUrl).concat(id ? "/".concat(id) : '');
|
|
13
|
+
return this.client.get({
|
|
14
|
+
url: url,
|
|
15
|
+
params: query,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
Visitor.prototype.update = function (_a) {
|
|
19
|
+
var id = _a.id, userId = _a.userId, name = _a.name, customAttributes = _a.customAttributes;
|
|
20
|
+
var data = {
|
|
21
|
+
id: id,
|
|
22
|
+
user_id: userId,
|
|
23
|
+
name: name,
|
|
24
|
+
custom_attributes: customAttributes,
|
|
25
|
+
};
|
|
26
|
+
return this.client.put({
|
|
27
|
+
url: "/".concat(this.baseUrl),
|
|
28
|
+
data: data,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
Visitor.prototype.delete = function (_a) {
|
|
32
|
+
var id = _a.id;
|
|
33
|
+
return this.client.delete({
|
|
34
|
+
url: "/".concat(this.baseUrl, "/").concat(id),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
Visitor.prototype.mergeToContact = function (_a) {
|
|
38
|
+
var visitor = _a.visitor, user = _a.user, type = _a.type;
|
|
39
|
+
var data = {
|
|
40
|
+
visitor: {
|
|
41
|
+
id: visitor.id,
|
|
42
|
+
user_id: visitor.userId,
|
|
43
|
+
email: visitor.email,
|
|
44
|
+
},
|
|
45
|
+
user: {
|
|
46
|
+
id: user.id,
|
|
47
|
+
user_id: user.userId,
|
|
48
|
+
email: user.email,
|
|
49
|
+
},
|
|
50
|
+
type: type,
|
|
51
|
+
};
|
|
52
|
+
return this.client.post({
|
|
53
|
+
url: "/".concat(this.baseUrl, "/convert"),
|
|
54
|
+
data: data,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return Visitor;
|
|
58
|
+
}());
|
|
59
|
+
exports.default = Visitor;
|
|
60
|
+
//# sourceMappingURL=visitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../lib/visitor.ts"],"names":[],"mappings":";;AAIA;IAGI,iBAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAF3B,YAAO,GAAG,UAAU,CAAC;QAGjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,sBAAI,GAAJ,UAAK,EAAmC;YAAjC,EAAE,QAAA,EAAE,MAAM,YAAA;QACb,IAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,IAAM,GAAG,GAAG,WAAI,IAAI,CAAC,OAAO,SAAG,EAAE,CAAC,CAAC,CAAC,WAAI,EAAE,CAAE,CAAC,CAAC,CAAC,EAAE,CAAE,CAAC;QAEpD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAgB;YAClC,GAAG,KAAA;YACH,MAAM,EAAE,KAAK;SAChB,CAAC,CAAC;IACP,CAAC;IACD,wBAAM,GAAN,UAAO,EAAyD;YAAvD,EAAE,QAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,gBAAgB,sBAAA;QACvC,IAAM,IAAI,GAAG;YACT,EAAE,IAAA;YACF,OAAO,EAAE,MAAM;YACf,IAAI,MAAA;YACJ,iBAAiB,EAAE,gBAAgB;SACtC,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAgB;YAClC,GAAG,EAAE,WAAI,IAAI,CAAC,OAAO,CAAE;YACvB,IAAI,MAAA;SACP,CAAC,CAAC;IACP,CAAC;IACD,wBAAM,GAAN,UAAO,EAA6B;YAA3B,EAAE,QAAA;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAgB;YACrC,GAAG,EAAE,WAAI,IAAI,CAAC,OAAO,cAAI,EAAE,CAAE;SAChC,CAAC,CAAC;IACP,CAAC;IACD,gCAAc,GAAd,UAAe,EAAkD;YAAhD,OAAO,aAAA,EAAE,IAAI,UAAA,EAAE,IAAI,UAAA;QAChC,IAAM,IAAI,GAAG;YACT,OAAO,EAAE;gBACL,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,OAAO,EAAE,OAAO,CAAC,MAAM;gBACvB,KAAK,EAAE,OAAO,CAAC,KAAK;aACvB;YACD,IAAI,EAAE;gBACF,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,MAAM;gBACpB,KAAK,EAAE,IAAI,CAAC,KAAK;aACpB;YACD,IAAI,MAAA;SACP,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAgB;YACnC,GAAG,EAAE,WAAI,IAAI,CAAC,OAAO,aAAU;YAC/B,IAAI,MAAA;SACP,CAAC,CAAC;IACP,CAAC;IACL,cAAC;AAAD,CAAC,AAtDD,IAsDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intercom-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Official Node bindings to the Intercom API",
|
|
5
5
|
"homepage": "https://github.com/intercom/intercom-node",
|
|
6
6
|
"bugs:": "https://github.com/intercom/intercom-node/issues",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@typescript-eslint/parser": "^5.7.0",
|
|
33
33
|
"eslint": "^8.2.0",
|
|
34
34
|
"eslint-config-prettier": "^8.3.0",
|
|
35
|
+
"eslint-plugin-no-only-tests": "^2.6.0",
|
|
35
36
|
"merge2": "^1.4.1",
|
|
36
37
|
"mocha": "^9.2.0",
|
|
37
38
|
"nock": "^13.0.11",
|
|
@@ -48,7 +49,8 @@
|
|
|
48
49
|
"compile_ts": "tsc",
|
|
49
50
|
"move_compiled_to_dist": "mv dist/lib/* dist && rmdir dist/lib",
|
|
50
51
|
"prepublish": "yarn clean && yarn static && yarn compile_ts && yarn move_compiled_to_dist",
|
|
51
|
-
"test": "mocha -r ts-node/register test/*.ts",
|
|
52
|
+
"test:unit": "mocha -r ts-node/register test/unit/*.test.ts --reporter=nyan",
|
|
53
|
+
"test:integration": "mocha -r ts-node/register test/integration/**/*.test.ts --timeout=30000",
|
|
52
54
|
"coverage": "nyc yarn test"
|
|
53
55
|
},
|
|
54
56
|
"engines": {
|