crisp-api 10.0.2 → 10.0.4
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/CHANGELOG.md +6 -2
- package/dist/crisp.d.ts +41 -29
- package/dist/crisp.js +43 -34
- package/dist/resources/BaseResource.d.ts +6 -0
- package/dist/resources/BaseResource.js +6 -0
- package/dist/resources/BucketURL.d.ts +9 -0
- package/dist/resources/BucketURL.js +6 -0
- package/dist/resources/MediaAnimation.d.ts +6 -0
- package/dist/resources/MediaAnimation.js +9 -1
- package/dist/resources/PluginConnect.d.ts +9 -0
- package/dist/resources/PluginConnect.js +6 -0
- package/dist/resources/PluginSubscription.d.ts +9 -0
- package/dist/resources/PluginSubscription.js +9 -1
- package/dist/resources/WebsiteAnalytics.d.ts +6 -0
- package/dist/resources/WebsiteAnalytics.js +9 -1
- package/dist/resources/WebsiteAvailability.d.ts +9 -0
- package/dist/resources/WebsiteAvailability.js +12 -2
- package/dist/resources/WebsiteBase.d.ts +9 -0
- package/dist/resources/WebsiteBase.js +6 -0
- package/dist/resources/WebsiteBatch.d.ts +9 -0
- package/dist/resources/WebsiteBatch.js +6 -0
- package/dist/resources/WebsiteCampaign.d.ts +9 -0
- package/dist/resources/WebsiteCampaign.js +8 -1
- package/dist/resources/WebsiteConversation.d.ts +9 -0
- package/dist/resources/WebsiteConversation.js +15 -3
- package/dist/resources/WebsiteHelpdesk.d.ts +15 -2
- package/dist/resources/WebsiteHelpdesk.js +6 -0
- package/dist/resources/WebsiteOperator.d.ts +9 -0
- package/dist/resources/WebsiteOperator.js +6 -0
- package/dist/resources/WebsitePeople.d.ts +9 -0
- package/dist/resources/WebsitePeople.js +6 -0
- package/dist/resources/WebsiteSettings.d.ts +9 -0
- package/dist/resources/WebsiteSettings.js +6 -0
- package/dist/resources/WebsiteVerify.d.ts +9 -0
- package/dist/resources/WebsiteVerify.js +6 -0
- package/dist/resources/WebsiteVisitors.d.ts +9 -0
- package/dist/resources/WebsiteVisitors.js +12 -2
- package/dist/resources/index.d.ts +3 -0
- package/dist/resources/index.js +3 -1
- package/dist/services/bucket.d.ts +6 -0
- package/dist/services/bucket.js +3 -0
- package/dist/services/media.d.ts +6 -0
- package/dist/services/media.js +3 -0
- package/dist/services/plugin.d.ts +6 -0
- package/dist/services/plugin.js +3 -0
- package/dist/services/website.d.ts +6 -0
- package/dist/services/website.js +3 -0
- package/lib/crisp.ts +123 -74
- package/lib/resources/BaseResource.ts +8 -0
- package/lib/resources/BucketURL.ts +12 -3
- package/lib/resources/MediaAnimation.ts +11 -1
- package/lib/resources/PluginConnect.ts +12 -5
- package/lib/resources/PluginSubscription.ts +36 -8
- package/lib/resources/WebsiteAnalytics.ts +11 -1
- package/lib/resources/WebsiteAvailability.ts +24 -4
- package/lib/resources/WebsiteBase.ts +14 -3
- package/lib/resources/WebsiteBatch.ts +24 -4
- package/lib/resources/WebsiteCampaign.ts +49 -16
- package/lib/resources/WebsiteConversation.ts +136 -45
- package/lib/resources/WebsiteHelpdesk.ts +81 -34
- package/lib/resources/WebsiteOperator.ts +28 -6
- package/lib/resources/WebsitePeople.ts +60 -19
- package/lib/resources/WebsiteSettings.ts +17 -2
- package/lib/resources/WebsiteVerify.ts +17 -3
- package/lib/resources/WebsiteVisitors.ts +32 -9
- package/lib/resources/index.ts +4 -1
- package/lib/services/bucket.ts +8 -0
- package/lib/services/media.ts +8 -0
- package/lib/services/plugin.ts +8 -0
- package/lib/services/website.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
## v10.0.3
|
|
5
|
+
|
|
6
|
+
# Return missing type on website.listHelpdeskLocales
|
|
7
|
+
|
|
4
8
|
## v10.0.1
|
|
5
9
|
|
|
6
|
-
* Routes supporting pagination can be used without page argument (page 1 by default)
|
|
10
|
+
* Routes supporting pagination can be used without a page argument (page is set to `1` by default).
|
|
7
11
|
|
|
8
12
|
## v10.0.0
|
|
9
13
|
|
|
10
|
-
*
|
|
14
|
+
* Added TypeScript support (retro-compatible).
|
|
11
15
|
|
|
12
16
|
## v9.13.0
|
|
13
17
|
|
package/dist/crisp.d.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { Socket } from "socket.io-client";
|
|
2
2
|
import { Emitter } from "mitt";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { BucketServiceInterface } from "./services/bucket";
|
|
4
|
+
import { MediaServiceInterface } from "./services/media";
|
|
5
|
+
import { PluginServiceInterface } from "./services/plugin";
|
|
6
6
|
import { WebsiteServiceInterface } from "./services/website";
|
|
7
|
-
|
|
7
|
+
/**************************************************************************
|
|
8
|
+
* TYPES
|
|
9
|
+
***************************************************************************/
|
|
8
10
|
export type RTM_MODES = "websockets" | "webhooks";
|
|
11
|
+
export type CrispTier = "user" | "plugin";
|
|
12
|
+
/**************************************************************************
|
|
13
|
+
* INTERFACES
|
|
14
|
+
***************************************************************************/
|
|
9
15
|
interface CrispAuth {
|
|
10
16
|
tier: CrispTier;
|
|
11
17
|
identifier: string | null;
|
|
12
18
|
key: string | null;
|
|
13
19
|
token: string | null;
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
/**************************************************************************
|
|
22
|
+
* CLASSES
|
|
23
|
+
***************************************************************************/
|
|
16
24
|
/**
|
|
17
|
-
*
|
|
25
|
+
*
|
|
18
26
|
*/
|
|
19
27
|
export declare class Crisp {
|
|
20
|
-
bucket:
|
|
21
|
-
media:
|
|
22
|
-
plugin:
|
|
28
|
+
bucket: BucketServiceInterface;
|
|
29
|
+
media: MediaServiceInterface;
|
|
30
|
+
plugin: PluginServiceInterface;
|
|
23
31
|
website: WebsiteServiceInterface;
|
|
24
32
|
/**
|
|
25
33
|
* @deprecated Use import { RTM_MODES } instead
|
|
@@ -29,22 +37,22 @@ export declare class Crisp {
|
|
|
29
37
|
WebHooks: RTM_MODES;
|
|
30
38
|
};
|
|
31
39
|
auth: CrispAuth;
|
|
32
|
-
_rest: {
|
|
40
|
+
protected _rest: {
|
|
33
41
|
host: string;
|
|
34
42
|
basePath: string;
|
|
35
43
|
};
|
|
36
|
-
_rtm: {
|
|
44
|
+
protected _rtm: {
|
|
37
45
|
host: string;
|
|
38
46
|
mode: RTM_MODES;
|
|
39
47
|
};
|
|
40
|
-
_useragent: string;
|
|
41
|
-
_emitter: Emitter<Record<import("mitt").EventType, unknown>>;
|
|
42
|
-
_socket: Socket | null;
|
|
43
|
-
_loopback: Emitter<Record<string, unknown>> | null;
|
|
44
|
-
_lastEventRebind: any;
|
|
45
|
-
_brokerScheduler: typeof setTimeout | null;
|
|
46
|
-
_brokerBindHooks: ((modeInstance: any, emitter: any) => void)[];
|
|
47
|
-
_boundEvents: {};
|
|
48
|
+
protected _useragent: string;
|
|
49
|
+
protected _emitter: Emitter<Record<import("mitt").EventType, unknown>>;
|
|
50
|
+
protected _socket: Socket | null;
|
|
51
|
+
protected _loopback: Emitter<Record<string, unknown>> | null;
|
|
52
|
+
protected _lastEventRebind: any;
|
|
53
|
+
protected _brokerScheduler: typeof setTimeout | null;
|
|
54
|
+
protected _brokerBindHooks: ((modeInstance: any, emitter: any) => void)[];
|
|
55
|
+
protected _boundEvents: {};
|
|
48
56
|
/**
|
|
49
57
|
* Constructor
|
|
50
58
|
*/
|
|
@@ -126,42 +134,46 @@ export declare class Crisp {
|
|
|
126
134
|
/**
|
|
127
135
|
* Binds services to the main object
|
|
128
136
|
*/
|
|
129
|
-
_prepareServices(): void;
|
|
137
|
+
protected _prepareServices(): void;
|
|
130
138
|
/**
|
|
131
139
|
* Binds resources to the service object
|
|
132
140
|
*/
|
|
133
|
-
private
|
|
141
|
+
private __prepareResources;
|
|
134
142
|
/**
|
|
135
143
|
* Binds broker to the main object
|
|
136
144
|
*/
|
|
137
|
-
private
|
|
145
|
+
private __prepareBroker;
|
|
138
146
|
/**
|
|
139
147
|
* Connects loopback (used for Web Hooks)
|
|
140
148
|
*/
|
|
141
|
-
private
|
|
149
|
+
private __connectLoopback;
|
|
142
150
|
/**
|
|
143
151
|
* Connects socket, using preferred RTM API host (used for WebSockets)
|
|
144
152
|
*/
|
|
145
|
-
private
|
|
153
|
+
private __connectSocket;
|
|
146
154
|
/**
|
|
147
155
|
* Authenticates client (used for WebSockets)
|
|
148
156
|
*/
|
|
149
|
-
private
|
|
157
|
+
private __emitAuthenticateSocket;
|
|
150
158
|
/**
|
|
151
159
|
* Unstacks pending broker bind hooks
|
|
152
160
|
*/
|
|
153
|
-
private
|
|
161
|
+
private __unstackBrokerBindHooks;
|
|
154
162
|
/**
|
|
155
163
|
* Performs a request to REST API
|
|
156
164
|
*/
|
|
157
|
-
private
|
|
165
|
+
private __request;
|
|
158
166
|
/**
|
|
159
167
|
* Reads reason for error response
|
|
160
168
|
*/
|
|
161
|
-
private
|
|
169
|
+
private __readErrorResponseReason;
|
|
162
170
|
/**
|
|
163
171
|
* Verifies an event string and checks that signatures match
|
|
164
172
|
*/
|
|
165
|
-
private
|
|
173
|
+
private __verifySignature;
|
|
166
174
|
}
|
|
175
|
+
/**************************************************************************
|
|
176
|
+
* EXPORTS
|
|
177
|
+
***************************************************************************/
|
|
178
|
+
export * from "./resources";
|
|
167
179
|
export default Crisp;
|
package/dist/crisp.js
CHANGED
|
@@ -28,24 +28,24 @@ exports.Crisp = void 0;
|
|
|
28
28
|
* IMPORTS
|
|
29
29
|
***************************************************************************/
|
|
30
30
|
// NPM
|
|
31
|
-
const got_1 = __importDefault(require("got"));
|
|
32
|
-
const socket_io_client_1 = require("socket.io-client");
|
|
33
31
|
const url_1 = require("url");
|
|
34
32
|
const crypto_1 = __importDefault(require("crypto"));
|
|
33
|
+
const got_1 = __importDefault(require("got"));
|
|
34
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
35
35
|
const mitt_1 = __importDefault(require("mitt"));
|
|
36
36
|
// PROJECT: SERVICES
|
|
37
37
|
const bucket_1 = __importDefault(require("./services/bucket"));
|
|
38
38
|
const media_1 = __importDefault(require("./services/media"));
|
|
39
39
|
const plugin_1 = __importDefault(require("./services/plugin"));
|
|
40
40
|
const website_1 = __importDefault(require("./services/website"));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/**************************************************************************
|
|
42
|
+
* CONSTANTS
|
|
43
|
+
***************************************************************************/
|
|
44
44
|
const AVAILABLE_RTM_MODES = [
|
|
45
45
|
"websockets",
|
|
46
46
|
"webhooks"
|
|
47
47
|
];
|
|
48
|
-
const VERSION = "10.0.
|
|
48
|
+
const VERSION = "10.0.4";
|
|
49
49
|
// Base configuration
|
|
50
50
|
const DEFAULT_REQUEST_TIMEOUT = 10000;
|
|
51
51
|
const DEFAULT_SOCKET_TIMEOUT = 10000;
|
|
@@ -163,8 +163,11 @@ const services = {
|
|
|
163
163
|
Plugin: plugin_1.default,
|
|
164
164
|
Website: website_1.default
|
|
165
165
|
};
|
|
166
|
+
/**************************************************************************
|
|
167
|
+
* CLASSES
|
|
168
|
+
***************************************************************************/
|
|
166
169
|
/**
|
|
167
|
-
*
|
|
170
|
+
*
|
|
168
171
|
*/
|
|
169
172
|
class Crisp {
|
|
170
173
|
/**
|
|
@@ -263,7 +266,7 @@ class Crisp {
|
|
|
263
266
|
*/
|
|
264
267
|
head(resource, query) {
|
|
265
268
|
return new Promise((resolve, reject) => {
|
|
266
|
-
this.
|
|
269
|
+
this.__request(resource, "head", (query || {}), null, resolve, reject);
|
|
267
270
|
});
|
|
268
271
|
}
|
|
269
272
|
/**
|
|
@@ -271,7 +274,7 @@ class Crisp {
|
|
|
271
274
|
*/
|
|
272
275
|
get(resource, query) {
|
|
273
276
|
return new Promise((resolve, reject) => {
|
|
274
|
-
this.
|
|
277
|
+
this.__request(resource, "get", (query || {}), null, resolve, reject);
|
|
275
278
|
});
|
|
276
279
|
}
|
|
277
280
|
/**
|
|
@@ -279,7 +282,7 @@ class Crisp {
|
|
|
279
282
|
*/
|
|
280
283
|
post(resource, query, body) {
|
|
281
284
|
return new Promise((resolve, reject) => {
|
|
282
|
-
this.
|
|
285
|
+
this.__request(resource, "post", (query || {}), (body || {}), resolve, reject);
|
|
283
286
|
});
|
|
284
287
|
}
|
|
285
288
|
/**
|
|
@@ -287,7 +290,7 @@ class Crisp {
|
|
|
287
290
|
*/
|
|
288
291
|
patch(resource, query, body) {
|
|
289
292
|
return new Promise((resolve, reject) => {
|
|
290
|
-
this.
|
|
293
|
+
this.__request(resource, "patch", (query || {}), (body || {}), resolve, reject);
|
|
291
294
|
});
|
|
292
295
|
}
|
|
293
296
|
/**
|
|
@@ -295,7 +298,7 @@ class Crisp {
|
|
|
295
298
|
*/
|
|
296
299
|
put(resource, query, body) {
|
|
297
300
|
return new Promise((resolve, reject) => {
|
|
298
|
-
this.
|
|
301
|
+
this.__request(resource, "put", (query || {}), (body || {}), resolve, reject);
|
|
299
302
|
});
|
|
300
303
|
}
|
|
301
304
|
/**
|
|
@@ -303,7 +306,7 @@ class Crisp {
|
|
|
303
306
|
*/
|
|
304
307
|
delete(resource, query, body) {
|
|
305
308
|
return new Promise((resolve, reject) => {
|
|
306
|
-
this.
|
|
309
|
+
this.__request(resource, "delete", (query || {}), (body || null), resolve, reject);
|
|
307
310
|
});
|
|
308
311
|
}
|
|
309
312
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
@@ -340,7 +343,7 @@ class Crisp {
|
|
|
340
343
|
// Mark event as bound
|
|
341
344
|
this._boundEvents[event] = true;
|
|
342
345
|
// Broker not connected? Connect now.
|
|
343
|
-
return this.
|
|
346
|
+
return this.__prepareBroker((instance, emitter) => {
|
|
344
347
|
// Listen for event? (once instance is bound)
|
|
345
348
|
switch (rtmMode) {
|
|
346
349
|
case "websockets": {
|
|
@@ -393,7 +396,7 @@ class Crisp {
|
|
|
393
396
|
*/
|
|
394
397
|
verifyHook(secret, body, timestamp, signature) {
|
|
395
398
|
if (this._loopback) {
|
|
396
|
-
return this.
|
|
399
|
+
return this.__verifySignature(secret, body, timestamp, signature);
|
|
397
400
|
}
|
|
398
401
|
// Default: not verified (loopback not /yet?/ bound)
|
|
399
402
|
return false;
|
|
@@ -403,7 +406,7 @@ class Crisp {
|
|
|
403
406
|
* Widgets)
|
|
404
407
|
*/
|
|
405
408
|
verifyWidget(secret, body, timestamp, signature) {
|
|
406
|
-
return this.
|
|
409
|
+
return this.__verifySignature(secret, body, timestamp, signature);
|
|
407
410
|
}
|
|
408
411
|
/**
|
|
409
412
|
* Rebinds socket events (used for WebSockets)
|
|
@@ -456,19 +459,20 @@ class Crisp {
|
|
|
456
459
|
"defined");
|
|
457
460
|
}
|
|
458
461
|
// Prepare all resources (for service)
|
|
459
|
-
this.
|
|
462
|
+
this.__prepareResources(serviceMap, serviceInstance.__resources);
|
|
460
463
|
}
|
|
461
464
|
}
|
|
462
465
|
/**
|
|
463
466
|
* Binds resources to the service object
|
|
464
467
|
*/
|
|
465
468
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
466
|
-
|
|
469
|
+
__prepareResources(serviceMap, resources) {
|
|
467
470
|
for (let i = 0; i < resources.length; i++) {
|
|
468
471
|
const resourceConstructor = resources[i];
|
|
469
472
|
const resourceInstance = new resourceConstructor(this);
|
|
470
473
|
// Bind each method of the resource instance to the service map
|
|
471
|
-
|
|
474
|
+
const methodNames = Object.getOwnPropertyNames(Object.getPrototypeOf(resourceInstance));
|
|
475
|
+
for (const methodName of methodNames) {
|
|
472
476
|
if (methodName !== "constructor") {
|
|
473
477
|
serviceMap[methodName] = resourceInstance[methodName].bind(resourceInstance);
|
|
474
478
|
}
|
|
@@ -478,8 +482,9 @@ class Crisp {
|
|
|
478
482
|
/**
|
|
479
483
|
* Binds broker to the main object
|
|
480
484
|
*/
|
|
485
|
+
__prepareBroker(
|
|
481
486
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, no-unused-vars
|
|
482
|
-
|
|
487
|
+
fnBindHook) {
|
|
483
488
|
return new Promise((resolve, reject) => {
|
|
484
489
|
const rtmMode = this._rtm.mode;
|
|
485
490
|
const rtmHostOverride = this._rtm.host;
|
|
@@ -500,14 +505,14 @@ class Crisp {
|
|
|
500
505
|
case "websockets": {
|
|
501
506
|
// Connect to socket now
|
|
502
507
|
// Notice: will unstack broker bind hooks once ready
|
|
503
|
-
this.
|
|
508
|
+
this.__connectSocket(rtmHostOverride)
|
|
504
509
|
.then(resolve)
|
|
505
510
|
.catch(reject);
|
|
506
511
|
break;
|
|
507
512
|
}
|
|
508
513
|
case "webhooks": {
|
|
509
514
|
// Connect to loopback now
|
|
510
|
-
this.
|
|
515
|
+
this.__connectLoopback()
|
|
511
516
|
.then(resolve)
|
|
512
517
|
.catch(reject);
|
|
513
518
|
break;
|
|
@@ -529,20 +534,20 @@ class Crisp {
|
|
|
529
534
|
/**
|
|
530
535
|
* Connects loopback (used for Web Hooks)
|
|
531
536
|
*/
|
|
532
|
-
|
|
537
|
+
__connectLoopback() {
|
|
533
538
|
return Promise.resolve()
|
|
534
539
|
.then(() => {
|
|
535
540
|
// Assign emitter to loopback
|
|
536
541
|
this._loopback = this._emitter;
|
|
537
542
|
// Unstack broker bind hooks immediately
|
|
538
|
-
this.
|
|
543
|
+
this.__unstackBrokerBindHooks(this._loopback);
|
|
539
544
|
return Promise.resolve();
|
|
540
545
|
});
|
|
541
546
|
}
|
|
542
547
|
/**
|
|
543
548
|
* Connects socket, using preferred RTM API host (used for WebSockets)
|
|
544
549
|
*/
|
|
545
|
-
|
|
550
|
+
__connectSocket(rtmHostOverride) {
|
|
546
551
|
return Promise.resolve()
|
|
547
552
|
.then(() => {
|
|
548
553
|
// Any override RTM API host?
|
|
@@ -592,24 +597,24 @@ class Crisp {
|
|
|
592
597
|
reconnectionDelayMax: DEFAULT_SOCKET_RECONNECT_DELAY_MAX,
|
|
593
598
|
randomizationFactor: DEFAULT_SOCKET_RECONNECT_FACTOR
|
|
594
599
|
});
|
|
595
|
-
this.
|
|
600
|
+
this.__emitAuthenticateSocket();
|
|
596
601
|
// Setup base socket event listeners
|
|
597
602
|
(_b = this._socket) === null || _b === void 0 ? void 0 : _b.io.on("reconnect", () => {
|
|
598
|
-
this.
|
|
603
|
+
this.__emitAuthenticateSocket();
|
|
599
604
|
});
|
|
600
605
|
(_c = this._socket) === null || _c === void 0 ? void 0 : _c.on("unauthorized", () => {
|
|
601
606
|
throw new Error("[Crisp] connectSocket: cannot listen for events as " +
|
|
602
607
|
"authentication is invalid");
|
|
603
608
|
});
|
|
604
609
|
// Setup user socket event listeners
|
|
605
|
-
this.
|
|
610
|
+
this.__unstackBrokerBindHooks(this._socket);
|
|
606
611
|
return Promise.resolve();
|
|
607
612
|
});
|
|
608
613
|
}
|
|
609
614
|
/**
|
|
610
615
|
* Authenticates client (used for WebSockets)
|
|
611
616
|
*/
|
|
612
|
-
|
|
617
|
+
__emitAuthenticateSocket() {
|
|
613
618
|
const auth = this.auth;
|
|
614
619
|
const boundEvents = Object.keys(this._boundEvents);
|
|
615
620
|
if (!this._socket) {
|
|
@@ -635,7 +640,7 @@ class Crisp {
|
|
|
635
640
|
* Unstacks pending broker bind hooks
|
|
636
641
|
*/
|
|
637
642
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
638
|
-
|
|
643
|
+
__unstackBrokerBindHooks(modeInstance) {
|
|
639
644
|
var _a;
|
|
640
645
|
// Setup user socket event listeners
|
|
641
646
|
while (this._brokerBindHooks.length > 0) {
|
|
@@ -645,7 +650,7 @@ class Crisp {
|
|
|
645
650
|
/**
|
|
646
651
|
* Performs a request to REST API
|
|
647
652
|
*/
|
|
648
|
-
|
|
653
|
+
__request(resource, method, query, body,
|
|
649
654
|
// eslint-disable-next-line no-unused-vars
|
|
650
655
|
resolve,
|
|
651
656
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -695,7 +700,7 @@ class Crisp {
|
|
|
695
700
|
}
|
|
696
701
|
// Response error?
|
|
697
702
|
if (response.statusCode >= 400) {
|
|
698
|
-
let reasonMessage = this.
|
|
703
|
+
let reasonMessage = this.__readErrorResponseReason(method, response.statusCode, response);
|
|
699
704
|
const dataMessage = (((_b = (_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || "");
|
|
700
705
|
return reject({
|
|
701
706
|
reason: "error",
|
|
@@ -714,7 +719,7 @@ class Crisp {
|
|
|
714
719
|
/**
|
|
715
720
|
* Reads reason for error response
|
|
716
721
|
*/
|
|
717
|
-
|
|
722
|
+
__readErrorResponseReason(method, statusCode, response) {
|
|
718
723
|
var _a;
|
|
719
724
|
// HEAD method? As HEAD requests do not expect any response body, then we \
|
|
720
725
|
// cannot map a reason from the response.
|
|
@@ -736,7 +741,7 @@ class Crisp {
|
|
|
736
741
|
/**
|
|
737
742
|
* Verifies an event string and checks that signatures match
|
|
738
743
|
*/
|
|
739
|
-
|
|
744
|
+
__verifySignature(secret, body, timestamp, signature) {
|
|
740
745
|
// Ensure all provided data is valid
|
|
741
746
|
if (!secret || !signature || !body || typeof body !== "object" ||
|
|
742
747
|
!timestamp || isNaN(timestamp) === true) {
|
|
@@ -761,4 +766,8 @@ Crisp.RTM_MODES = {
|
|
|
761
766
|
WebHooks: "webhooks"
|
|
762
767
|
};
|
|
763
768
|
;
|
|
769
|
+
/**************************************************************************
|
|
770
|
+
* EXPORTS
|
|
771
|
+
***************************************************************************/
|
|
772
|
+
__exportStar(require("./resources"), exports);
|
|
764
773
|
exports.default = Crisp;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* IMPORTS
|
|
3
3
|
***************************************************************************/
|
|
4
4
|
import Crisp from "../crisp";
|
|
5
|
+
/**************************************************************************
|
|
6
|
+
* CLASSES
|
|
7
|
+
***************************************************************************/
|
|
5
8
|
/**
|
|
6
9
|
* Crisp Base Resource
|
|
7
10
|
*/
|
|
@@ -12,4 +15,7 @@ declare class BaseResource {
|
|
|
12
15
|
*/
|
|
13
16
|
constructor(crisp: Crisp);
|
|
14
17
|
}
|
|
18
|
+
/**************************************************************************
|
|
19
|
+
* EXPORTS
|
|
20
|
+
***************************************************************************/
|
|
15
21
|
export default BaseResource;
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* Author: Baptiste Jamin <baptiste@crisp.chat>
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
/**************************************************************************
|
|
10
|
+
* CLASSES
|
|
11
|
+
***************************************************************************/
|
|
9
12
|
/**
|
|
10
13
|
* Crisp Base Resource
|
|
11
14
|
*/
|
|
@@ -17,4 +20,7 @@ class BaseResource {
|
|
|
17
20
|
this.crisp = crisp;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
23
|
+
/**************************************************************************
|
|
24
|
+
* EXPORTS
|
|
25
|
+
***************************************************************************/
|
|
20
26
|
exports.default = BaseResource;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* IMPORTS
|
|
3
3
|
***************************************************************************/
|
|
4
4
|
import BaseResource from "./BaseResource";
|
|
5
|
+
/**************************************************************************
|
|
6
|
+
* TYPES
|
|
7
|
+
***************************************************************************/
|
|
5
8
|
export type BucketURLRequestFile = {
|
|
6
9
|
name?: string;
|
|
7
10
|
type?: string;
|
|
@@ -16,6 +19,9 @@ export type BucketURLRequest = {
|
|
|
16
19
|
file?: BucketURLRequestFile;
|
|
17
20
|
resource?: BucketURLRequestResource;
|
|
18
21
|
};
|
|
22
|
+
/**************************************************************************
|
|
23
|
+
* CLASSES
|
|
24
|
+
***************************************************************************/
|
|
19
25
|
/**
|
|
20
26
|
* Crisp BucketURL Resource
|
|
21
27
|
*/
|
|
@@ -25,4 +31,7 @@ declare class BucketURL extends BaseResource {
|
|
|
25
31
|
*/
|
|
26
32
|
generateBucketURL(data: BucketURLRequest): Promise<any>;
|
|
27
33
|
}
|
|
34
|
+
/**************************************************************************
|
|
35
|
+
* EXPORTS
|
|
36
|
+
***************************************************************************/
|
|
28
37
|
export default BucketURL;
|
|
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
***************************************************************************/
|
|
15
15
|
// PROJECT: RESOURCES
|
|
16
16
|
const BaseResource_1 = __importDefault(require("./BaseResource"));
|
|
17
|
+
/**************************************************************************
|
|
18
|
+
* CLASSES
|
|
19
|
+
***************************************************************************/
|
|
17
20
|
/**
|
|
18
21
|
* Crisp BucketURL Resource
|
|
19
22
|
*/
|
|
@@ -26,4 +29,7 @@ class BucketURL extends BaseResource_1.default {
|
|
|
26
29
|
}
|
|
27
30
|
;
|
|
28
31
|
}
|
|
32
|
+
/**************************************************************************
|
|
33
|
+
* EXPORTS
|
|
34
|
+
***************************************************************************/
|
|
29
35
|
exports.default = BucketURL;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* IMPORTS
|
|
3
3
|
***************************************************************************/
|
|
4
4
|
import BaseResource from "./BaseResource";
|
|
5
|
+
/**************************************************************************
|
|
6
|
+
* CLASSES
|
|
7
|
+
***************************************************************************/
|
|
5
8
|
/**
|
|
6
9
|
* Crisp MediaAnimation Resource
|
|
7
10
|
*/
|
|
@@ -11,4 +14,7 @@ declare class MediaAnimation extends BaseResource {
|
|
|
11
14
|
*/
|
|
12
15
|
listAnimationMedias(pageNumber: number, listID: string, searchQuery: object): Promise<any>;
|
|
13
16
|
}
|
|
17
|
+
/**************************************************************************
|
|
18
|
+
* EXPORTS
|
|
19
|
+
***************************************************************************/
|
|
14
20
|
export default MediaAnimation;
|
|
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
***************************************************************************/
|
|
15
15
|
// PROJECT: RESOURCES
|
|
16
16
|
const BaseResource_1 = __importDefault(require("./BaseResource"));
|
|
17
|
+
/**************************************************************************
|
|
18
|
+
* CLASSES
|
|
19
|
+
***************************************************************************/
|
|
17
20
|
/**
|
|
18
21
|
* Crisp MediaAnimation Resource
|
|
19
22
|
*/
|
|
@@ -22,11 +25,16 @@ class MediaAnimation extends BaseResource_1.default {
|
|
|
22
25
|
* List Animation Medias
|
|
23
26
|
*/
|
|
24
27
|
listAnimationMedias(pageNumber, listID, searchQuery) {
|
|
25
|
-
return this.crisp.get(this.crisp.prepareRestUrl([
|
|
28
|
+
return this.crisp.get(this.crisp.prepareRestUrl([
|
|
29
|
+
"media", "animation", "list", String(pageNumber)
|
|
30
|
+
]), {
|
|
26
31
|
list_id: listID,
|
|
27
32
|
search_query: searchQuery
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
35
|
;
|
|
31
36
|
}
|
|
37
|
+
/**************************************************************************
|
|
38
|
+
* EXPORTS
|
|
39
|
+
***************************************************************************/
|
|
32
40
|
exports.default = MediaAnimation;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* IMPORTS
|
|
3
3
|
***************************************************************************/
|
|
4
4
|
import BaseResource from "./BaseResource";
|
|
5
|
+
/**************************************************************************
|
|
6
|
+
* TYPES
|
|
7
|
+
***************************************************************************/
|
|
5
8
|
export type PluginConnectAccount = {
|
|
6
9
|
plugin_id?: string;
|
|
7
10
|
};
|
|
@@ -22,6 +25,9 @@ export type PluginConnectEndpoints = {
|
|
|
22
25
|
export type PluginConnectEndpointsSocket = {
|
|
23
26
|
app?: string;
|
|
24
27
|
};
|
|
28
|
+
/**************************************************************************
|
|
29
|
+
* CLASSES
|
|
30
|
+
***************************************************************************/
|
|
25
31
|
/**
|
|
26
32
|
* Crisp PluginConnect Resource
|
|
27
33
|
*/
|
|
@@ -47,4 +53,7 @@ declare class PluginConnect extends BaseResource {
|
|
|
47
53
|
*/
|
|
48
54
|
getConnectEndpoints(): Promise<PluginConnectEndpoints>;
|
|
49
55
|
}
|
|
56
|
+
/**************************************************************************
|
|
57
|
+
* EXPORTS
|
|
58
|
+
***************************************************************************/
|
|
50
59
|
export default PluginConnect;
|
|
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
***************************************************************************/
|
|
15
15
|
// PROJECT: RESOURCES
|
|
16
16
|
const BaseResource_1 = __importDefault(require("./BaseResource"));
|
|
17
|
+
/**************************************************************************
|
|
18
|
+
* CLASSES
|
|
19
|
+
***************************************************************************/
|
|
17
20
|
/**
|
|
18
21
|
* Crisp PluginConnect Resource
|
|
19
22
|
*/
|
|
@@ -70,4 +73,7 @@ class PluginConnect extends BaseResource_1.default {
|
|
|
70
73
|
}
|
|
71
74
|
;
|
|
72
75
|
}
|
|
76
|
+
/**************************************************************************
|
|
77
|
+
* EXPORTS
|
|
78
|
+
***************************************************************************/
|
|
73
79
|
exports.default = PluginConnect;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* IMPORTS
|
|
3
3
|
***************************************************************************/
|
|
4
4
|
import BaseResource from "./BaseResource";
|
|
5
|
+
/**************************************************************************
|
|
6
|
+
* TYPES
|
|
7
|
+
***************************************************************************/
|
|
5
8
|
type PluginSubscription = {
|
|
6
9
|
id?: string;
|
|
7
10
|
urn?: string;
|
|
@@ -47,6 +50,9 @@ type PluginSubscriptionEventDispatch = {
|
|
|
47
50
|
name?: string;
|
|
48
51
|
data?: object;
|
|
49
52
|
};
|
|
53
|
+
/**************************************************************************
|
|
54
|
+
* CLASSES
|
|
55
|
+
***************************************************************************/
|
|
50
56
|
/**
|
|
51
57
|
* Crisp PluginSubscription Resource
|
|
52
58
|
*/
|
|
@@ -100,4 +106,7 @@ declare class PluginSubscriptionService extends BaseResource {
|
|
|
100
106
|
*/
|
|
101
107
|
dispatchPluginEvent(websiteID: string, pluginID: string, payload: PluginSubscriptionEventDispatch): Promise<any>;
|
|
102
108
|
}
|
|
109
|
+
/**************************************************************************
|
|
110
|
+
* EXPORTS
|
|
111
|
+
***************************************************************************/
|
|
103
112
|
export default PluginSubscriptionService;
|
|
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
***************************************************************************/
|
|
15
15
|
// PROJECT: RESOURCES
|
|
16
16
|
const BaseResource_1 = __importDefault(require("./BaseResource"));
|
|
17
|
+
/**************************************************************************
|
|
18
|
+
* CLASSES
|
|
19
|
+
***************************************************************************/
|
|
17
20
|
/**
|
|
18
21
|
* Crisp PluginSubscription Resource
|
|
19
22
|
*/
|
|
@@ -52,7 +55,9 @@ class PluginSubscriptionService extends BaseResource_1.default {
|
|
|
52
55
|
* Unsubscribe Plugin From Website
|
|
53
56
|
*/
|
|
54
57
|
unsubscribePluginFromWebsite(websiteID, pluginID) {
|
|
55
|
-
return this.crisp.delete(this.crisp.prepareRestUrl([
|
|
58
|
+
return this.crisp.delete(this.crisp.prepareRestUrl([
|
|
59
|
+
"plugins", "subscription", websiteID, pluginID
|
|
60
|
+
]));
|
|
56
61
|
}
|
|
57
62
|
;
|
|
58
63
|
/**
|
|
@@ -119,4 +124,7 @@ class PluginSubscriptionService extends BaseResource_1.default {
|
|
|
119
124
|
}
|
|
120
125
|
;
|
|
121
126
|
}
|
|
127
|
+
/**************************************************************************
|
|
128
|
+
* EXPORTS
|
|
129
|
+
***************************************************************************/
|
|
122
130
|
exports.default = PluginSubscriptionService;
|