crisp-api 10.10.6 → 10.11.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/CHANGELOG.md +6 -1
- package/EXAMPLES.md +74 -0
- package/README.md +101 -0
- package/dist/crisp.js +16 -23
- package/dist/events/Events.d.ts +2 -2
- package/dist/resources/PluginConnect.js +3 -3
- package/dist/resources/WebsiteBase.d.ts +0 -10
- package/dist/resources/WebsiteBase.js +0 -10
- package/dist/resources/WebsiteBatch.d.ts +0 -18
- package/dist/resources/WebsiteBatch.js +0 -18
- package/dist/resources/WebsiteCampaign.d.ts +0 -1
- package/dist/resources/WebsiteCampaign.js +0 -1
- package/dist/resources/WebsiteConversation.js +17 -20
- package/dist/resources/WebsiteHelpdesk.d.ts +2 -2
- package/dist/resources/WebsiteHelpdesk.js +8 -15
- package/dist/resources/WebsiteInbox.d.ts +2 -0
- package/dist/resources/WebsitePeople.js +1 -6
- package/dist/resources/WebsiteSettings.d.ts +6 -0
- package/dist/resources/WebsiteTeams.d.ts +54 -0
- package/dist/resources/WebsiteTeams.js +73 -0
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.js +1 -0
- package/dist/services/website.d.ts +2 -1
- package/dist/services/website.js +2 -0
- package/eslint.config.mjs +13 -184
- package/lib/crisp.ts +17 -22
- package/lib/events/Events.ts +2 -2
- package/lib/resources/PluginConnect.ts +3 -3
- package/lib/resources/WebsiteBase.ts +0 -10
- package/lib/resources/WebsiteBatch.ts +0 -18
- package/lib/resources/WebsiteCampaign.ts +0 -1
- package/lib/resources/WebsiteConversation.ts +17 -20
- package/lib/resources/WebsiteHelpdesk.ts +8 -15
- package/lib/resources/WebsiteInbox.ts +2 -0
- package/lib/resources/WebsitePeople.ts +1 -6
- package/lib/resources/WebsiteSettings.ts +6 -0
- package/lib/resources/WebsiteTeams.ts +109 -0
- package/lib/resources/index.ts +1 -0
- package/lib/services/bucket.ts +1 -0
- package/lib/services/media.ts +1 -0
- package/lib/services/plan.ts +1 -0
- package/lib/services/website.ts +3 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
## v10.11.0
|
|
5
|
+
|
|
6
|
+
### Changes
|
|
7
|
+
|
|
8
|
+
* Added now-public `WebsiteTeams` service to the `CrispClient.website` prefix.
|
|
9
|
+
|
|
4
10
|
## v10.10.6
|
|
5
11
|
|
|
6
12
|
### Changes
|
|
@@ -8,7 +14,6 @@ Changelog
|
|
|
8
14
|
* Added missing `url` field on `PeopleProfileCardPersonProfile` type.
|
|
9
15
|
* Adding missing fields on RTM events
|
|
10
16
|
|
|
11
|
-
|
|
12
17
|
## v10.10.5
|
|
13
18
|
|
|
14
19
|
### Changes
|
package/EXAMPLES.md
CHANGED
|
@@ -1689,6 +1689,7 @@ var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
|
1689
1689
|
var settings = {
|
|
1690
1690
|
"name": "Crisp",
|
|
1691
1691
|
"domain": "crisp.chat",
|
|
1692
|
+
"domain_alternates": [],
|
|
1692
1693
|
"logo": "https://storage.crisp.chat/users/avatar/website/8c842203-7ed8-4e29-a608-7cf78a7d2fcc/b6c2948d-b061-405e-91a9-2fdf855d1cc0.png",
|
|
1693
1694
|
"audit": {
|
|
1694
1695
|
"log": true
|
|
@@ -1705,6 +1706,7 @@ var settings = {
|
|
|
1705
1706
|
"emails": {
|
|
1706
1707
|
"rating": true,
|
|
1707
1708
|
"transcript": true,
|
|
1709
|
+
"trackers": true,
|
|
1708
1710
|
"junk_filter": true
|
|
1709
1711
|
},
|
|
1710
1712
|
"chatbox": {
|
|
@@ -1729,6 +1731,7 @@ var settings = {
|
|
|
1729
1731
|
"visitor_compose": false,
|
|
1730
1732
|
"file_transfer": true,
|
|
1731
1733
|
"audio_record": true,
|
|
1734
|
+
"guard_level": "default",
|
|
1732
1735
|
"mode_initial": "chat",
|
|
1733
1736
|
"home": true,
|
|
1734
1737
|
"overlay_search": true,
|
|
@@ -2203,6 +2206,77 @@ CrispClient.website.deleteInbox(websiteID, inboxID);
|
|
|
2203
2206
|
|
|
2204
2207
|
=========================
|
|
2205
2208
|
|
|
2209
|
+
https://docs.crisp.chat/references/rest-api/v1/#list-teams
|
|
2210
|
+
|
|
2211
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
2212
|
+
var pageNumber = 1;
|
|
2213
|
+
|
|
2214
|
+
CrispClient.website.listTeams(websiteID, pageNumber);
|
|
2215
|
+
|
|
2216
|
+
=========================
|
|
2217
|
+
|
|
2218
|
+
https://docs.crisp.chat/references/rest-api/v1/#create-a-new-team
|
|
2219
|
+
|
|
2220
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
2221
|
+
|
|
2222
|
+
var team = {
|
|
2223
|
+
"name": "Sales",
|
|
2224
|
+
"emoji": "💰",
|
|
2225
|
+
|
|
2226
|
+
"operators": [
|
|
2227
|
+
"a4c32c68-be91-4e29-8a05-976e93abbe3f"
|
|
2228
|
+
]
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
CrispClient.website.createNewTeam(websiteID, team);
|
|
2232
|
+
|
|
2233
|
+
=========================
|
|
2234
|
+
|
|
2235
|
+
https://docs.crisp.chat/references/rest-api/v1/#check-if-team-exists
|
|
2236
|
+
|
|
2237
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
2238
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
2239
|
+
|
|
2240
|
+
CrispClient.website.checkTeamExists(websiteID, teamID);
|
|
2241
|
+
|
|
2242
|
+
=========================
|
|
2243
|
+
|
|
2244
|
+
https://docs.crisp.chat/references/rest-api/v1/#get-a-team
|
|
2245
|
+
|
|
2246
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
2247
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
2248
|
+
|
|
2249
|
+
CrispClient.website.getTeam(websiteID, teamID);
|
|
2250
|
+
|
|
2251
|
+
=========================
|
|
2252
|
+
|
|
2253
|
+
https://docs.crisp.chat/references/rest-api/v1/#save-a-team
|
|
2254
|
+
|
|
2255
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
2256
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
2257
|
+
|
|
2258
|
+
var team = {
|
|
2259
|
+
"name": "Sales",
|
|
2260
|
+
"emoji": "💰",
|
|
2261
|
+
|
|
2262
|
+
"operators": [
|
|
2263
|
+
"a4c32c68-be91-4e29-8a05-976e93abbe3f"
|
|
2264
|
+
]
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2267
|
+
CrispClient.website.saveTeam(websiteID, teamID, team);
|
|
2268
|
+
|
|
2269
|
+
=========================
|
|
2270
|
+
|
|
2271
|
+
https://docs.crisp.chat/references/rest-api/v1/#remove-a-team
|
|
2272
|
+
|
|
2273
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
2274
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
2275
|
+
|
|
2276
|
+
CrispClient.website.deleteTeam(websiteID, teamID);
|
|
2277
|
+
|
|
2278
|
+
=========================
|
|
2279
|
+
|
|
2206
2280
|
https://docs.crisp.chat/references/rest-api/v1/#get-verify-settings
|
|
2207
2281
|
|
|
2208
2282
|
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
package/README.md
CHANGED
|
@@ -112,6 +112,7 @@ All methods that you will most likely need when building a Crisp integration are
|
|
|
112
112
|
<li><a href="#website-analytics">Website Analytics</a></li>
|
|
113
113
|
<li><a href="#website-batch">Website Batch</a></li>
|
|
114
114
|
<li><a href="#website-inbox">Website Inbox</a></li>
|
|
115
|
+
<li><a href="#website-teams">Website Teams</a></li>
|
|
115
116
|
<li><a href="#website-verify">Website Verify</a></li>
|
|
116
117
|
<li><a href="#website-campaigns">Website Campaigns</a></li>
|
|
117
118
|
<li><a href="#website-campaign">Website Campaign</a></li>
|
|
@@ -2469,6 +2470,7 @@ _👉 Notice: The `peopleID` argument can be an email or the `peopleID`._
|
|
|
2469
2470
|
var settings = {
|
|
2470
2471
|
"name": "Crisp",
|
|
2471
2472
|
"domain": "crisp.chat",
|
|
2473
|
+
"domain_alternates": [],
|
|
2472
2474
|
"logo": "https://storage.crisp.chat/users/avatar/website/8c842203-7ed8-4e29-a608-7cf78a7d2fcc/b6c2948d-b061-405e-91a9-2fdf855d1cc0.png",
|
|
2473
2475
|
"audit": {
|
|
2474
2476
|
"log": true
|
|
@@ -2485,6 +2487,7 @@ _👉 Notice: The `peopleID` argument can be an email or the `peopleID`._
|
|
|
2485
2487
|
"emails": {
|
|
2486
2488
|
"rating": true,
|
|
2487
2489
|
"transcript": true,
|
|
2490
|
+
"trackers": true,
|
|
2488
2491
|
"junk_filter": true
|
|
2489
2492
|
},
|
|
2490
2493
|
"chatbox": {
|
|
@@ -2509,6 +2512,7 @@ _👉 Notice: The `peopleID` argument can be an email or the `peopleID`._
|
|
|
2509
2512
|
"visitor_compose": false,
|
|
2510
2513
|
"file_transfer": true,
|
|
2511
2514
|
"audio_record": true,
|
|
2515
|
+
"guard_level": "default",
|
|
2512
2516
|
"mode_initial": "chat",
|
|
2513
2517
|
"home": true,
|
|
2514
2518
|
"overlay_search": true,
|
|
@@ -3242,6 +3246,103 @@ _👉 Notice: The `peopleID` argument can be an email or the `peopleID`._
|
|
|
3242
3246
|
</details>
|
|
3243
3247
|
|
|
3244
3248
|
|
|
3249
|
+
* #### **Website Teams**
|
|
3250
|
+
* **List Teams**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-teams)
|
|
3251
|
+
* `CrispClient.website.listTeams(websiteID, pageNumber)`
|
|
3252
|
+
* <details>
|
|
3253
|
+
<summary>See Example</summary>
|
|
3254
|
+
|
|
3255
|
+
```javascript
|
|
3256
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
3257
|
+
var pageNumber = 1;
|
|
3258
|
+
|
|
3259
|
+
CrispClient.website.listTeams(websiteID, pageNumber);
|
|
3260
|
+
```
|
|
3261
|
+
</details>
|
|
3262
|
+
|
|
3263
|
+
* **Create A New Team**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#create-a-new-team)
|
|
3264
|
+
* `CrispClient.website.createNewTeam(websiteID, team)`
|
|
3265
|
+
* <details>
|
|
3266
|
+
<summary>See Example</summary>
|
|
3267
|
+
|
|
3268
|
+
```javascript
|
|
3269
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
3270
|
+
|
|
3271
|
+
var team = {
|
|
3272
|
+
"name": "Sales",
|
|
3273
|
+
"emoji": "💰",
|
|
3274
|
+
|
|
3275
|
+
"operators": [
|
|
3276
|
+
"a4c32c68-be91-4e29-8a05-976e93abbe3f"
|
|
3277
|
+
]
|
|
3278
|
+
};
|
|
3279
|
+
|
|
3280
|
+
CrispClient.website.createNewTeam(websiteID, team);
|
|
3281
|
+
```
|
|
3282
|
+
</details>
|
|
3283
|
+
|
|
3284
|
+
* **Check If Team Exists**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#check-if-team-exists)
|
|
3285
|
+
* `CrispClient.website.checkTeamExists(websiteID, teamID)`
|
|
3286
|
+
* <details>
|
|
3287
|
+
<summary>See Example</summary>
|
|
3288
|
+
|
|
3289
|
+
```javascript
|
|
3290
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
3291
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
3292
|
+
|
|
3293
|
+
CrispClient.website.checkTeamExists(websiteID, teamID);
|
|
3294
|
+
```
|
|
3295
|
+
</details>
|
|
3296
|
+
|
|
3297
|
+
* **Get Team**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#get-a-team)
|
|
3298
|
+
* `CrispClient.website.getTeam(websiteID, teamID)`
|
|
3299
|
+
* <details>
|
|
3300
|
+
<summary>See Example</summary>
|
|
3301
|
+
|
|
3302
|
+
```javascript
|
|
3303
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
3304
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
3305
|
+
|
|
3306
|
+
CrispClient.website.getTeam(websiteID, teamID);
|
|
3307
|
+
```
|
|
3308
|
+
</details>
|
|
3309
|
+
|
|
3310
|
+
* **Save Team**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#save-a-team)
|
|
3311
|
+
* `CrispClient.website.saveTeam(websiteID, teamID, team)`
|
|
3312
|
+
* <details>
|
|
3313
|
+
<summary>See Example</summary>
|
|
3314
|
+
|
|
3315
|
+
```javascript
|
|
3316
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
3317
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
3318
|
+
|
|
3319
|
+
var team = {
|
|
3320
|
+
"name": "Sales",
|
|
3321
|
+
"emoji": "💰",
|
|
3322
|
+
|
|
3323
|
+
"operators": [
|
|
3324
|
+
"a4c32c68-be91-4e29-8a05-976e93abbe3f"
|
|
3325
|
+
]
|
|
3326
|
+
};
|
|
3327
|
+
|
|
3328
|
+
CrispClient.website.saveTeam(websiteID, teamID, team);
|
|
3329
|
+
```
|
|
3330
|
+
</details>
|
|
3331
|
+
|
|
3332
|
+
* **Delete Team**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#remove-a-team)
|
|
3333
|
+
* `CrispClient.website.deleteTeam(websiteID, teamID)`
|
|
3334
|
+
* <details>
|
|
3335
|
+
<summary>See Example</summary>
|
|
3336
|
+
|
|
3337
|
+
```javascript
|
|
3338
|
+
var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc";
|
|
3339
|
+
var teamID = "d09fbd42-e517-45a4-9776-ba8226e00ba8";
|
|
3340
|
+
|
|
3341
|
+
CrispClient.website.deleteTeam(websiteID, teamID);
|
|
3342
|
+
```
|
|
3343
|
+
</details>
|
|
3344
|
+
|
|
3345
|
+
|
|
3245
3346
|
* #### **Website Verify**
|
|
3246
3347
|
* **Get Verify Settings**: [Reference](https://docs.crisp.chat/references/rest-api/v1/#get-verify-settings)
|
|
3247
3348
|
* `CrispClient.website.getVerifySettings(websiteID)`
|
package/dist/crisp.js
CHANGED
|
@@ -46,7 +46,7 @@ const AVAILABLE_RTM_MODES = [
|
|
|
46
46
|
"websockets",
|
|
47
47
|
"webhooks"
|
|
48
48
|
];
|
|
49
|
-
const VERSION = "10.
|
|
49
|
+
const VERSION = "10.11.0";
|
|
50
50
|
// Base configuration
|
|
51
51
|
const DEFAULT_REQUEST_TIMEOUT = 10000;
|
|
52
52
|
const DEFAULT_SOCKET_TIMEOUT = 10000;
|
|
@@ -204,7 +204,7 @@ class Crisp {
|
|
|
204
204
|
this._loopback = null;
|
|
205
205
|
this._lastEventRebind = null;
|
|
206
206
|
this._brokerScheduler = null;
|
|
207
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
208
|
this._brokerBindHooks = [];
|
|
209
209
|
this._boundEvents = {};
|
|
210
210
|
this._prepareServices();
|
|
@@ -329,7 +329,7 @@ class Crisp {
|
|
|
329
329
|
/**
|
|
330
330
|
* Binds RTM event
|
|
331
331
|
*/
|
|
332
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
332
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
333
333
|
on(event, callback) {
|
|
334
334
|
// Ensure all input arguments are set
|
|
335
335
|
if (typeof event !== "string") {
|
|
@@ -355,7 +355,7 @@ class Crisp {
|
|
|
355
355
|
this._emitter.on(event, callback);
|
|
356
356
|
// Subscribe event on the broker
|
|
357
357
|
if (this._boundEvents[event] !== true) {
|
|
358
|
-
|
|
358
|
+
const rtmMode = this._rtm.mode;
|
|
359
359
|
// Mark event as bound
|
|
360
360
|
this._boundEvents[event] = true;
|
|
361
361
|
// Broker not connected? Connect now.
|
|
@@ -499,7 +499,7 @@ class Crisp {
|
|
|
499
499
|
* Binds broker to the main object
|
|
500
500
|
*/
|
|
501
501
|
__prepareBroker(
|
|
502
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
502
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
503
503
|
fnBindHook) {
|
|
504
504
|
return new Promise((resolve, reject) => {
|
|
505
505
|
const rtmMode = this._rtm.mode;
|
|
@@ -515,7 +515,7 @@ class Crisp {
|
|
|
515
515
|
if (this._socket || this._loopback) {
|
|
516
516
|
throw new Error("[Crisp] prepareBroker: illegal call to prepare broker (tie break)");
|
|
517
517
|
}
|
|
518
|
-
// @ts-
|
|
518
|
+
// @ts-expect-error - rtmMode is a string
|
|
519
519
|
this._brokerScheduler = setTimeout(() => {
|
|
520
520
|
switch (rtmMode) {
|
|
521
521
|
case "websockets": {
|
|
@@ -535,7 +535,7 @@ class Crisp {
|
|
|
535
535
|
}
|
|
536
536
|
default: {
|
|
537
537
|
const unsupportedError = new Error("[Crisp] prepareBroker: mode of RTM broker unsupported " +
|
|
538
|
-
"('" + rtmMode + "')");
|
|
538
|
+
"('" + String(rtmMode) + "')");
|
|
539
539
|
reject(unsupportedError);
|
|
540
540
|
}
|
|
541
541
|
}
|
|
@@ -597,7 +597,6 @@ class Crisp {
|
|
|
597
597
|
})
|
|
598
598
|
.then((endpoints) => {
|
|
599
599
|
var _a, _b, _c;
|
|
600
|
-
// @ts-ignore
|
|
601
600
|
const rtmHostAffinity = (((_a = endpoints === null || endpoints === void 0 ? void 0 : endpoints.socket) === null || _a === void 0 ? void 0 : _a.app) || null);
|
|
602
601
|
// No RTM API host acquired?
|
|
603
602
|
if (rtmHostAffinity === null) {
|
|
@@ -607,7 +606,6 @@ class Crisp {
|
|
|
607
606
|
// Parse target RTM API host as an URL object
|
|
608
607
|
const rtmHostUrl = new url_1.URL(rtmHostAffinity);
|
|
609
608
|
// Connect to socket
|
|
610
|
-
// @ts-ignore
|
|
611
609
|
this._socket = (0, socket_io_client_1.io)(rtmHostUrl.origin, {
|
|
612
610
|
path: (rtmHostUrl.pathname || "/"),
|
|
613
611
|
transports: ["websocket"],
|
|
@@ -670,12 +668,8 @@ class Crisp {
|
|
|
670
668
|
/**
|
|
671
669
|
* Performs a request to REST API
|
|
672
670
|
*/
|
|
673
|
-
__request(resource, method, query, body,
|
|
674
|
-
|
|
675
|
-
resolve,
|
|
676
|
-
// eslint-disable-next-line no-unused-vars
|
|
677
|
-
reject) {
|
|
678
|
-
let requestParameters = {
|
|
671
|
+
__request(resource, method, query, body, resolve, reject) {
|
|
672
|
+
const requestParameters = {
|
|
679
673
|
responseType: "json",
|
|
680
674
|
timeout: DEFAULT_REQUEST_TIMEOUT,
|
|
681
675
|
headers: Object.assign({ "User-Agent": this._useragent, "X-Crisp-Tier": this.auth.tier }, this._customHeaders),
|
|
@@ -683,12 +677,12 @@ class Crisp {
|
|
|
683
677
|
};
|
|
684
678
|
// Add authorization?
|
|
685
679
|
if (this.auth.token) {
|
|
686
|
-
// @ts-
|
|
680
|
+
// @ts-expect-error - requestParameters.headers is a Record<string, string>
|
|
687
681
|
requestParameters.headers.Authorization = ("Basic " + this.auth.token);
|
|
688
682
|
}
|
|
689
683
|
// Add body?
|
|
690
684
|
if (body) {
|
|
691
|
-
// @ts-
|
|
685
|
+
// @ts-expect-error - requestParameters.json is a Record<string, unknown>
|
|
692
686
|
requestParameters.json = body;
|
|
693
687
|
}
|
|
694
688
|
// Add query?
|
|
@@ -705,7 +699,7 @@ class Crisp {
|
|
|
705
699
|
params.append(key, String(value));
|
|
706
700
|
}
|
|
707
701
|
});
|
|
708
|
-
// @ts-
|
|
702
|
+
// @ts-expect-error - requestParameters.searchParams is a URLSearchParams
|
|
709
703
|
requestParameters.searchParams = params;
|
|
710
704
|
}
|
|
711
705
|
// Proceed request
|
|
@@ -729,7 +723,7 @@ class Crisp {
|
|
|
729
723
|
}
|
|
730
724
|
// Response error?
|
|
731
725
|
if (response.statusCode >= 400) {
|
|
732
|
-
|
|
726
|
+
const reasonMessage = this.__readErrorResponseReason(method, response.statusCode, response);
|
|
733
727
|
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) || "");
|
|
734
728
|
return reject({
|
|
735
729
|
reason: "error",
|
|
@@ -764,7 +758,6 @@ class Crisp {
|
|
|
764
758
|
}
|
|
765
759
|
// Other methods must hold a response body, therefore we can fallback on \
|
|
766
760
|
// an HTTP error if we fail to acquire any reason at all.
|
|
767
|
-
// @ts-ignore
|
|
768
761
|
return ((((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.reason) || "http_error"));
|
|
769
762
|
}
|
|
770
763
|
/**
|
|
@@ -777,12 +770,12 @@ class Crisp {
|
|
|
777
770
|
return false;
|
|
778
771
|
}
|
|
779
772
|
// Compute local trace
|
|
780
|
-
|
|
773
|
+
const localTrace = ("[" + timestamp + ";" + JSON.stringify(body) + "]");
|
|
781
774
|
// Create local HMAC
|
|
782
|
-
|
|
775
|
+
const localMac = crypto_1.default.createHmac("sha256", secret);
|
|
783
776
|
localMac.update(localTrace);
|
|
784
777
|
// Compute local signature, and compare
|
|
785
|
-
|
|
778
|
+
const localSignature = localMac.digest("hex");
|
|
786
779
|
return ((signature === localSignature) ? true : false);
|
|
787
780
|
}
|
|
788
781
|
}
|
package/dist/events/Events.d.ts
CHANGED
|
@@ -496,7 +496,7 @@ export interface EventsPlanSubscriptionUpdated extends EventsWebsiteGeneric {
|
|
|
496
496
|
* EVENT MAP
|
|
497
497
|
***************************************************************************/
|
|
498
498
|
/**
|
|
499
|
-
* Maps each event name to the shape of the payload delivered to its listener,
|
|
499
|
+
* Maps each event name to the shape of the payload delivered to its listener, \
|
|
500
500
|
* whether received over WebSockets or Web Hooks.
|
|
501
501
|
*/
|
|
502
502
|
export interface EventsMap {
|
|
@@ -588,7 +588,7 @@ export interface EventsMap {
|
|
|
588
588
|
*/
|
|
589
589
|
export type EventName = keyof EventsMap;
|
|
590
590
|
/**
|
|
591
|
-
* Shape of a Web Hook body, as received on the HTTP endpoint before being
|
|
591
|
+
* Shape of a Web Hook body, as received on the HTTP endpoint before being \
|
|
592
592
|
* dispatched with 'receiveHook'.
|
|
593
593
|
*/
|
|
594
594
|
export type EventsWebHookBody<Name extends EventName = EventName> = {
|
|
@@ -40,7 +40,7 @@ class PluginConnect extends BaseResource_1.default {
|
|
|
40
40
|
*/
|
|
41
41
|
listAllConnectWebsites(pageNumber, filterConfigured, includePlan) {
|
|
42
42
|
// Generate query
|
|
43
|
-
|
|
43
|
+
const query = {
|
|
44
44
|
filter_configured: ((filterConfigured === true) ? "1" : "0"),
|
|
45
45
|
include_plan: ((includePlan === true) ? "1" : "0")
|
|
46
46
|
};
|
|
@@ -54,12 +54,12 @@ class PluginConnect extends BaseResource_1.default {
|
|
|
54
54
|
*/
|
|
55
55
|
listConnectWebsitesSince(dateSince, filterConfigured, includePlan) {
|
|
56
56
|
// Generate query
|
|
57
|
-
|
|
57
|
+
const query = {
|
|
58
58
|
filter_configured: ((filterConfigured === true) ? "1" : "0"),
|
|
59
59
|
include_plan: ((includePlan === true) ? "1" : "0")
|
|
60
60
|
};
|
|
61
61
|
if (dateSince) {
|
|
62
|
-
// @ts-
|
|
62
|
+
// @ts-expect-error - dateSince is a string
|
|
63
63
|
query.date_since = dateSince;
|
|
64
64
|
}
|
|
65
65
|
return this.crisp.get(this.crisp.prepareRestUrl([
|
|
@@ -36,11 +36,6 @@ export type WebsiteFilter = {
|
|
|
36
36
|
declare class WebsiteBase extends BaseResource {
|
|
37
37
|
/**
|
|
38
38
|
* Check If Website Exists
|
|
39
|
-
* @memberof WebsiteBase
|
|
40
|
-
* @public
|
|
41
|
-
* @method checkWebsiteExists
|
|
42
|
-
* @param {string} domain
|
|
43
|
-
* @return {Promise}
|
|
44
39
|
*/
|
|
45
40
|
checkWebsiteExists(domain: string): Promise<any>;
|
|
46
41
|
/**
|
|
@@ -49,11 +44,6 @@ declare class WebsiteBase extends BaseResource {
|
|
|
49
44
|
createWebsite(websiteData: WebsiteCreate): Promise<Website>;
|
|
50
45
|
/**
|
|
51
46
|
* Get A Website
|
|
52
|
-
* @memberof WebsiteBase
|
|
53
|
-
* @public
|
|
54
|
-
* @method getWebsite
|
|
55
|
-
* @param {string} websiteID
|
|
56
|
-
* @return {Promise}
|
|
57
47
|
*/
|
|
58
48
|
getWebsite(websiteID: string): Promise<Website>;
|
|
59
49
|
/**
|
|
@@ -23,11 +23,6 @@ const BaseResource_1 = __importDefault(require("./BaseResource"));
|
|
|
23
23
|
class WebsiteBase extends BaseResource_1.default {
|
|
24
24
|
/**
|
|
25
25
|
* Check If Website Exists
|
|
26
|
-
* @memberof WebsiteBase
|
|
27
|
-
* @public
|
|
28
|
-
* @method checkWebsiteExists
|
|
29
|
-
* @param {string} domain
|
|
30
|
-
* @return {Promise}
|
|
31
26
|
*/
|
|
32
27
|
checkWebsiteExists(domain) {
|
|
33
28
|
return this.crisp.head(this.crisp.prepareRestUrl(["website"]), {
|
|
@@ -44,11 +39,6 @@ class WebsiteBase extends BaseResource_1.default {
|
|
|
44
39
|
;
|
|
45
40
|
/**
|
|
46
41
|
* Get A Website
|
|
47
|
-
* @memberof WebsiteBase
|
|
48
|
-
* @public
|
|
49
|
-
* @method getWebsite
|
|
50
|
-
* @param {string} websiteID
|
|
51
|
-
* @return {Promise}
|
|
52
42
|
*/
|
|
53
43
|
getWebsite(websiteID) {
|
|
54
44
|
return this.crisp.get(this.crisp.prepareRestUrl(["website", websiteID]));
|
|
@@ -58,12 +58,6 @@ declare class WebsiteBatch extends BaseResource {
|
|
|
58
58
|
batchUnresolveConversations(websiteID: string, operation: WebsiteBatchConversationsOperation): Promise<any>;
|
|
59
59
|
/**
|
|
60
60
|
* Batch Read Conversations
|
|
61
|
-
* @memberof WebsiteBatch
|
|
62
|
-
* @public
|
|
63
|
-
* @method batchReadConversations
|
|
64
|
-
* @param {string} websiteID
|
|
65
|
-
* @param {object} operation
|
|
66
|
-
* @return {Promise}
|
|
67
61
|
*/
|
|
68
62
|
batchReadConversations(websiteID: string, operation: WebsiteBatchConversationsOperation): Promise<any>;
|
|
69
63
|
/**
|
|
@@ -72,22 +66,10 @@ declare class WebsiteBatch extends BaseResource {
|
|
|
72
66
|
batchUnreadConversations(websiteID: string, operation: WebsiteBatchConversationsOperation): Promise<any>;
|
|
73
67
|
/**
|
|
74
68
|
* Batch Remove Conversations
|
|
75
|
-
* @memberof WebsiteBatch
|
|
76
|
-
* @public
|
|
77
|
-
* @method batchRemoveConversations
|
|
78
|
-
* @param {string} websiteID
|
|
79
|
-
* @param {object} operation
|
|
80
|
-
* @return {Promise}
|
|
81
69
|
*/
|
|
82
70
|
batchRemoveConversations(websiteID: string, operation: WebsiteBatchConversationsOperation): Promise<any>;
|
|
83
71
|
/**
|
|
84
72
|
* Batch Remove People
|
|
85
|
-
* @memberof WebsiteBatch
|
|
86
|
-
* @public
|
|
87
|
-
* @method batchRemovePeople
|
|
88
|
-
* @param {string} websiteID
|
|
89
|
-
* @param {object} people
|
|
90
|
-
* @return {Promise}
|
|
91
73
|
*/
|
|
92
74
|
batchRemovePeople(websiteID: string, people: WebsiteBatchPeopleOperationInner): Promise<any>;
|
|
93
75
|
/**
|
|
@@ -37,12 +37,6 @@ class WebsiteBatch extends BaseResource_1.default {
|
|
|
37
37
|
;
|
|
38
38
|
/**
|
|
39
39
|
* Batch Read Conversations
|
|
40
|
-
* @memberof WebsiteBatch
|
|
41
|
-
* @public
|
|
42
|
-
* @method batchReadConversations
|
|
43
|
-
* @param {string} websiteID
|
|
44
|
-
* @param {object} operation
|
|
45
|
-
* @return {Promise}
|
|
46
40
|
*/
|
|
47
41
|
batchReadConversations(websiteID, operation) {
|
|
48
42
|
return this.crisp.patch(this.crisp.prepareRestUrl(["website", websiteID, "batch", "read"]), null, operation);
|
|
@@ -57,12 +51,6 @@ class WebsiteBatch extends BaseResource_1.default {
|
|
|
57
51
|
;
|
|
58
52
|
/**
|
|
59
53
|
* Batch Remove Conversations
|
|
60
|
-
* @memberof WebsiteBatch
|
|
61
|
-
* @public
|
|
62
|
-
* @method batchRemoveConversations
|
|
63
|
-
* @param {string} websiteID
|
|
64
|
-
* @param {object} operation
|
|
65
|
-
* @return {Promise}
|
|
66
54
|
*/
|
|
67
55
|
batchRemoveConversations(websiteID, operation) {
|
|
68
56
|
return this.crisp.patch(this.crisp.prepareRestUrl(["website", websiteID, "batch", "remove"]), null, operation);
|
|
@@ -70,12 +58,6 @@ class WebsiteBatch extends BaseResource_1.default {
|
|
|
70
58
|
;
|
|
71
59
|
/**
|
|
72
60
|
* Batch Remove People
|
|
73
|
-
* @memberof WebsiteBatch
|
|
74
|
-
* @public
|
|
75
|
-
* @method batchRemovePeople
|
|
76
|
-
* @param {string} websiteID
|
|
77
|
-
* @param {object} people
|
|
78
|
-
* @return {Promise}
|
|
79
61
|
*/
|
|
80
62
|
batchRemovePeople(websiteID, people) {
|
|
81
63
|
return this.crisp.patch(this.crisp.prepareRestUrl(["website", websiteID, "batch", "remove"]), null, {
|
|
@@ -179,7 +179,6 @@ declare class WebsiteCampaign extends BaseResource {
|
|
|
179
179
|
removeCampaign(websiteID: string, campaignID: string): Promise<any>;
|
|
180
180
|
/**
|
|
181
181
|
* Dispatch A Campaign
|
|
182
|
-
* @return {Promise}
|
|
183
182
|
*/
|
|
184
183
|
dispatchCampaign(websiteID: string, campaignID: string): Promise<any>;
|
|
185
184
|
/**
|