crisp-api 9.13.0 → 10.0.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/crisp.d.ts +179 -0
  4. package/dist/crisp.js +773 -0
  5. package/dist/resources/BaseResource.d.ts +21 -0
  6. package/dist/resources/BaseResource.js +26 -0
  7. package/dist/resources/BucketURL.d.ts +37 -0
  8. package/dist/resources/BucketURL.js +35 -0
  9. package/dist/resources/MediaAnimation.d.ts +20 -0
  10. package/dist/resources/MediaAnimation.js +40 -0
  11. package/dist/resources/PluginConnect.d.ts +59 -0
  12. package/dist/resources/PluginConnect.js +79 -0
  13. package/dist/resources/PluginSubscription.d.ts +112 -0
  14. package/dist/resources/PluginSubscription.js +130 -0
  15. package/dist/resources/WebsiteAnalytics.d.ts +20 -0
  16. package/dist/resources/WebsiteAnalytics.js +37 -0
  17. package/dist/resources/WebsiteAvailability.d.ts +40 -0
  18. package/dist/resources/WebsiteAvailability.js +46 -0
  19. package/dist/resources/WebsiteBase.d.ts +69 -0
  20. package/dist/resources/WebsiteBase.js +77 -0
  21. package/dist/resources/WebsiteBatch.d.ts +61 -0
  22. package/dist/resources/WebsiteBatch.js +76 -0
  23. package/dist/resources/WebsiteCampaign.d.ts +208 -0
  24. package/dist/resources/WebsiteCampaign.js +201 -0
  25. package/dist/resources/WebsiteConversation.d.ts +710 -0
  26. package/dist/resources/WebsiteConversation.js +607 -0
  27. package/dist/resources/WebsiteHelpdesk.d.ts +356 -0
  28. package/dist/resources/WebsiteHelpdesk.js +593 -0
  29. package/dist/resources/WebsiteOperator.d.ts +88 -0
  30. package/dist/resources/WebsiteOperator.js +99 -0
  31. package/dist/resources/WebsitePeople.d.ts +257 -0
  32. package/dist/resources/WebsitePeople.js +282 -0
  33. package/dist/resources/WebsiteSettings.d.ts +168 -0
  34. package/dist/resources/WebsiteSettings.js +42 -0
  35. package/dist/resources/WebsiteVerify.d.ts +47 -0
  36. package/dist/resources/WebsiteVerify.js +56 -0
  37. package/dist/resources/WebsiteVisitors.d.ts +122 -0
  38. package/dist/resources/WebsiteVisitors.js +98 -0
  39. package/dist/resources/index.d.ts +20 -0
  40. package/dist/resources/index.js +42 -0
  41. package/dist/services/bucket.d.ts +19 -0
  42. package/dist/services/bucket.js +31 -0
  43. package/dist/services/media.d.ts +19 -0
  44. package/dist/services/media.js +31 -0
  45. package/dist/services/plugin.d.ts +20 -0
  46. package/dist/services/plugin.js +33 -0
  47. package/dist/services/website.d.ts +30 -0
  48. package/dist/services/website.js +53 -0
  49. package/eslint.config.mjs +208 -0
  50. package/lib/crisp.ts +1006 -0
  51. package/lib/resources/BaseResource.ts +37 -0
  52. package/lib/resources/BucketURL.ts +58 -0
  53. package/lib/resources/MediaAnimation.ts +44 -0
  54. package/lib/resources/PluginConnect.ts +135 -0
  55. package/lib/resources/PluginSubscription.ts +236 -0
  56. package/lib/resources/WebsiteAnalytics.ts +41 -0
  57. package/lib/resources/WebsiteAvailability.ts +74 -0
  58. package/lib/resources/WebsiteBase.ts +119 -0
  59. package/lib/resources/WebsiteBatch.ts +116 -0
  60. package/lib/resources/WebsiteCampaign.ts +432 -0
  61. package/lib/resources/WebsiteConversation.ts +1507 -0
  62. package/lib/resources/WebsiteHelpdesk.ts +1024 -0
  63. package/lib/resources/WebsiteOperator.ts +183 -0
  64. package/lib/resources/WebsitePeople.ts +568 -0
  65. package/lib/resources/WebsiteSettings.ts +207 -0
  66. package/lib/resources/WebsiteVerify.ts +90 -0
  67. package/lib/resources/WebsiteVisitors.ts +219 -0
  68. package/lib/resources/index.ts +28 -0
  69. package/lib/services/bucket.ts +36 -0
  70. package/lib/services/media.ts +36 -0
  71. package/lib/services/plugin.ts +40 -0
  72. package/lib/services/website.ts +70 -0
  73. package/package.json +16 -11
  74. package/tsconfig.json +12 -5
  75. package/lib/crisp.js +0 -1171
  76. package/lib/resources/BucketURL.js +0 -34
  77. package/lib/resources/MediaAnimation.js +0 -41
  78. package/lib/resources/PluginConnect.js +0 -119
  79. package/lib/resources/PluginSubscription.js +0 -234
  80. package/lib/resources/WebsiteAnalytics.js +0 -37
  81. package/lib/resources/WebsiteAvailability.js +0 -48
  82. package/lib/resources/WebsiteBase.js +0 -100
  83. package/lib/resources/WebsiteBatch.js +0 -92
  84. package/lib/resources/WebsiteCampaign.js +0 -396
  85. package/lib/resources/WebsiteConversation.js +0 -1261
  86. package/lib/resources/WebsiteHelpdesk.js +0 -1198
  87. package/lib/resources/WebsiteOperator.js +0 -167
  88. package/lib/resources/WebsitePeople.js +0 -516
  89. package/lib/resources/WebsiteSettings.js +0 -50
  90. package/lib/resources/WebsiteVerify.js +0 -79
  91. package/lib/resources/WebsiteVisitors.js +0 -148
  92. package/lib/services/Bucket.js +0 -28
  93. package/lib/services/Media.js +0 -28
  94. package/lib/services/Plugin.js +0 -29
  95. package/lib/services/Website.js +0 -39
  96. package/types/crisp.d.ts +0 -151
  97. package/types/resources/BucketURL.d.ts +0 -15
  98. package/types/resources/MediaAnimation.d.ts +0 -15
  99. package/types/resources/PluginConnect.d.ts +0 -15
  100. package/types/resources/PluginSubscription.d.ts +0 -15
  101. package/types/resources/WebsiteAnalytics.d.ts +0 -15
  102. package/types/resources/WebsiteAvailability.d.ts +0 -15
  103. package/types/resources/WebsiteBase.d.ts +0 -15
  104. package/types/resources/WebsiteBatch.d.ts +0 -15
  105. package/types/resources/WebsiteCampaign.d.ts +0 -15
  106. package/types/resources/WebsiteConversation.d.ts +0 -15
  107. package/types/resources/WebsiteHelpdesk.d.ts +0 -15
  108. package/types/resources/WebsiteOperator.d.ts +0 -15
  109. package/types/resources/WebsitePeople.d.ts +0 -15
  110. package/types/resources/WebsiteSettings.d.ts +0 -15
  111. package/types/resources/WebsiteVerify.d.ts +0 -15
  112. package/types/resources/WebsiteVisitors.d.ts +0 -15
  113. package/types/services/Bucket.d.ts +0 -14
  114. package/types/services/Media.d.ts +0 -14
  115. package/types/services/Plugin.d.ts +0 -14
  116. package/types/services/Website.d.ts +0 -14
@@ -0,0 +1,568 @@
1
+ /*
2
+ * node-crisp-api
3
+ *
4
+ * Copyright 2022, Crisp IM SAS
5
+ * Author: Baptiste Jamin <baptiste@crisp.chat>
6
+ */
7
+
8
+ /**************************************************************************
9
+ * IMPORTS
10
+ ***************************************************************************/
11
+
12
+ // PROJECT: RESOURCES
13
+ import BaseResource from "./BaseResource";
14
+
15
+ /**************************************************************************
16
+ * INTERFACES
17
+ ***************************************************************************/
18
+
19
+ export interface PeopleStatistics {
20
+ total?: number;
21
+ }
22
+
23
+ export interface PeopleSuggestedSegment {
24
+ segment?: string;
25
+ count?: number;
26
+ }
27
+
28
+ export interface PeopleSuggestedDataKey {
29
+ key?: string;
30
+ count?: number;
31
+ }
32
+
33
+ export interface PeopleSuggestedEvent {
34
+ text?: string;
35
+ count?: number;
36
+ }
37
+
38
+ export interface PeopleProfile extends PeopleProfileCard {
39
+ people_id?: string;
40
+ }
41
+
42
+ export interface PeopleProfileNew {
43
+ people_id?: string;
44
+ }
45
+
46
+ export interface PeopleProfileCard {
47
+ email?: string;
48
+ person?: PeopleProfileCardPerson;
49
+ company?: PeopleProfileCardCompany;
50
+ segments?: string[];
51
+ notepad?: string;
52
+ active?: PeopleProfileCardActive;
53
+ score?: number;
54
+ created_at?: number;
55
+ updated_at?: number;
56
+ }
57
+
58
+ export interface PeopleProfileUpdateCard {
59
+ email?: string;
60
+ person?: PeopleProfileCardPerson;
61
+ company?: PeopleProfileCardCompany;
62
+ segments?: string[];
63
+ notepad?: string;
64
+ active?: number;
65
+ }
66
+
67
+ export interface PeopleProfileCardPerson {
68
+ nickname?: string;
69
+ avatar?: string;
70
+ gender?: string;
71
+ phone?: string;
72
+ address?: string;
73
+ description?: string;
74
+ website?: string;
75
+ timezone?: number;
76
+ profiles?: PeopleProfileCardPersonProfile[];
77
+ employment?: PeopleProfileCardPersonEmployment;
78
+ geolocation?: PeopleProfileCardGeolocation;
79
+ locales?: string[];
80
+ }
81
+
82
+ export interface PeopleProfileCardPersonProfile {
83
+ type?: string;
84
+ handle?: string;
85
+ }
86
+
87
+ export interface PeopleProfileCardPersonEmployment {
88
+ name?: string;
89
+ domain?: string;
90
+ title?: string;
91
+ role?: string;
92
+ seniority?: string;
93
+ }
94
+
95
+ export interface PeopleProfileCardCompany {
96
+ name?: string;
97
+ legal_name?: string;
98
+ domain?: string;
99
+ url?: string;
100
+ description?: string;
101
+ timezone?: number;
102
+ phones?: string[];
103
+ emails?: string[];
104
+ geolocation?: PeopleProfileCardGeolocation;
105
+ metrics?: PeopleProfileCardCompanyMetrics;
106
+ tags?: string[];
107
+ }
108
+
109
+ export interface PeopleProfileCardCompanyMetrics {
110
+ employees?: number;
111
+ market_cap?: number;
112
+ raised?: number;
113
+ arr?: number;
114
+ }
115
+
116
+ export interface PeopleProfileCardGeolocation {
117
+ country?: string;
118
+ region?: string;
119
+ city?: string;
120
+ coordinates?: PeopleProfileCardGeolocationCoordinates;
121
+ }
122
+
123
+ export interface PeopleProfileCardGeolocationCoordinates {
124
+ latitude?: number;
125
+ longitude?: number;
126
+ }
127
+
128
+ export interface PeopleProfileCardActive {
129
+ now?: boolean;
130
+ last?: number;
131
+ }
132
+
133
+ export interface PeopleCampaign {
134
+ campaign_id?: string;
135
+ type?: string;
136
+ name?: string;
137
+ created_at?: number;
138
+ updated_at?: number;
139
+ dispatched_at?: number;
140
+ occurred_at?: number;
141
+ statistics?: string[];
142
+ }
143
+
144
+ export interface PeopleEvent {
145
+ text?: string;
146
+ data?: object;
147
+ color?: string;
148
+ timestamp?: number;
149
+ }
150
+
151
+ export interface PeopleData {
152
+ data?: Record<string, boolean|string|number>;
153
+ }
154
+
155
+ export interface PeopleSubscription {
156
+ email?: boolean;
157
+ }
158
+
159
+ export interface PeopleSubscriptionUpdate {
160
+ email?: boolean;
161
+ }
162
+
163
+ export interface PeopleProfileImportSetup {
164
+ url?: string;
165
+ mapping?: PeopleProfileImportSetupMapping[];
166
+ options?: PeopleProfileImportSetupOptions;
167
+ }
168
+
169
+ export interface PeopleProfileImportSetupMapping {
170
+ column?: number;
171
+ field?: string;
172
+ }
173
+
174
+ export interface PeopleProfileImportSetupOptions {
175
+ column_separator?: string;
176
+ skip_header?: boolean;
177
+ }
178
+
179
+ /**************************************************************************
180
+ * CLASSES
181
+ ***************************************************************************/
182
+
183
+ /**
184
+ * Crisp WebsitePeople Resource
185
+ * @class
186
+ * @classdesc This is the Crisp Website People Resource
187
+ */
188
+ class WebsitePeople extends BaseResource {
189
+ /**
190
+ * Get People Statistics
191
+ */
192
+ getPeopleStatistics(websiteID: string): Promise<PeopleStatistics> {
193
+ return this.crisp.get(
194
+ this.crisp.prepareRestUrl(["website", websiteID, "people", "stats"])
195
+ );
196
+ };
197
+
198
+ /**
199
+ * List Suggested People Segments
200
+ */
201
+ listSuggestedPeopleSegments(
202
+ websiteID: string, pageNumber: number = 1
203
+ ): Promise<PeopleSuggestedSegment[]> {
204
+ return this.crisp.get(
205
+ this.crisp.prepareRestUrl([
206
+ "website", websiteID, "people", "suggest", "segments", String(pageNumber)
207
+ ])
208
+ );
209
+ };
210
+
211
+ /**
212
+ * Delete Suggested People Segment
213
+ */
214
+ deleteSuggestedPeopleSegment(websiteID: string, segment: string) {
215
+ return this.crisp.delete(
216
+ this.crisp.prepareRestUrl([
217
+ "website", websiteID, "people", "suggest", "segment"
218
+ ]),
219
+
220
+ null,
221
+
222
+ {
223
+ segment: segment
224
+ }
225
+ );
226
+ };
227
+
228
+ /**
229
+ * List Suggested People Data Keys
230
+ */
231
+ listSuggestedPeopleDataKeys(
232
+ websiteID: string, pageNumber: number = 1
233
+ ): Promise<PeopleSuggestedDataKey[]> {
234
+ return this.crisp.get(
235
+ this.crisp.prepareRestUrl([
236
+ "website", websiteID, "people", "suggest", "data", String(pageNumber)
237
+ ])
238
+ );
239
+ };
240
+
241
+ /**
242
+ * Delete Suggested People Data Key
243
+ */
244
+ deleteSuggestedPeopleDataKey(websiteID: string, key: string) {
245
+ return this.crisp.delete(
246
+ this.crisp.prepareRestUrl([
247
+ "website", websiteID, "people", "suggest", "data"
248
+ ]),
249
+
250
+ null,
251
+
252
+ {
253
+ key: key
254
+ }
255
+ );
256
+ };
257
+
258
+ /**
259
+ * List Suggested People Events
260
+ */
261
+ listSuggestedPeopleEvents(
262
+ websiteID: string, pageNumber: number = 1
263
+ ): Promise<PeopleSuggestedEvent[]> {
264
+ return this.crisp.get(
265
+ this.crisp.prepareRestUrl([
266
+ "website", websiteID, "people", "suggest", "events", String(pageNumber)
267
+ ])
268
+ );
269
+ };
270
+
271
+ /**
272
+ * Delete Suggested People Event
273
+ */
274
+ deleteSuggestedPeopleEvent(websiteID: string, text: string) {
275
+ return this.crisp.delete(
276
+ this.crisp.prepareRestUrl([
277
+ "website", websiteID, "people", "suggest", "event"
278
+ ]),
279
+
280
+ null,
281
+
282
+ {
283
+ text: text
284
+ }
285
+ );
286
+ };
287
+
288
+ /**
289
+ * List People Profiles
290
+ */
291
+ listPeopleProfiles(
292
+ websiteID: string, pageNumber: number = 1, searchField?: string,
293
+ searchOrder?: string, searchOperator?: string, searchFilter?: string,
294
+ searchText?: string
295
+ ): Promise<PeopleProfile[]> {
296
+ // Generate query
297
+ let query = {};
298
+
299
+ if (searchField) {
300
+ // @ts-ignore
301
+ query.sort_field = searchField;
302
+ }
303
+
304
+ if (searchOrder) {
305
+ // @ts-ignore
306
+ query.sort_order = searchOrder;
307
+ }
308
+
309
+ if (searchOperator) {
310
+ // @ts-ignore
311
+ query.search_operator = searchOperator;
312
+ }
313
+
314
+ if (searchFilter) {
315
+ // @ts-ignore
316
+ query.search_filter = searchFilter;
317
+ }
318
+
319
+ if (searchText) {
320
+ // @ts-ignore
321
+ query.search_text = searchText;
322
+ }
323
+
324
+ return this.crisp.get(
325
+ this.crisp.prepareRestUrl([
326
+ "website", websiteID, "people", "profiles", String(pageNumber)
327
+ ]),
328
+
329
+ query
330
+ );
331
+ };
332
+
333
+ /**
334
+ * Add New People Profile
335
+ */
336
+ addNewPeopleProfile(websiteID: string, profile: PeopleProfileUpdateCard) {
337
+ return this.crisp.post(
338
+ this.crisp.prepareRestUrl(["website", websiteID, "people", "profile"]),
339
+
340
+ null, profile
341
+ );
342
+ };
343
+
344
+ /**
345
+ * Check If People Profile Exists
346
+ */
347
+ checkPeopleProfileExists(websiteID: string, peopleID: string) {
348
+ return this.crisp.head(
349
+ this.crisp.prepareRestUrl([
350
+ "website", websiteID, "people", "profile", peopleID
351
+ ])
352
+ );
353
+ };
354
+
355
+ /**
356
+ * Save People Profile
357
+ */
358
+ getPeopleProfile(websiteID: string, peopleID: string) {
359
+ return this.crisp.get(
360
+ this.crisp.prepareRestUrl([
361
+ "website", websiteID, "people", "profile", peopleID
362
+ ])
363
+ );
364
+ };
365
+
366
+ /**
367
+ * Get People Profile
368
+ */
369
+ savePeopleProfile(
370
+ websiteID: string, peopleID: string, profile: PeopleProfileUpdateCard
371
+ ) {
372
+ return this.crisp.put(
373
+ this.crisp.prepareRestUrl([
374
+ "website", websiteID, "people", "profile", peopleID
375
+ ]),
376
+
377
+ null, profile
378
+ );
379
+ };
380
+
381
+ /**
382
+ * Update People Profile
383
+ */
384
+ updatePeopleProfile(
385
+ websiteID: string, peopleID: string, profile: PeopleProfileUpdateCard
386
+ ) {
387
+ return this.crisp.patch(
388
+ this.crisp.prepareRestUrl([
389
+ "website", websiteID, "people", "profile", peopleID
390
+ ]),
391
+
392
+ null, profile
393
+ );
394
+ };
395
+
396
+ /**
397
+ * Remove People Profile
398
+ */
399
+ removePeopleProfile(websiteID: string, peopleID: string) {
400
+ return this.crisp.delete(
401
+ this.crisp.prepareRestUrl([
402
+ "website", websiteID, "people", "profile", peopleID
403
+ ])
404
+ );
405
+ };
406
+
407
+ /**
408
+ * List People Conversations
409
+ */
410
+ listPeopleConversations(
411
+ websiteID: string, peopleID: string, pageNumber: number = 1
412
+ ): Promise<string[]> {
413
+ return this.crisp.get(
414
+ this.crisp.prepareRestUrl([
415
+ "website", websiteID, "people", "conversations", peopleID, "list",
416
+ String(pageNumber)
417
+ ])
418
+ );
419
+ };
420
+
421
+ /**
422
+ * List People Campaigns
423
+ */
424
+ listPeopleCampaigns(
425
+ websiteID: string, peopleID: string, pageNumber: number = 1
426
+ ): Promise<PeopleCampaign[]> {
427
+ return this.crisp.get(
428
+ this.crisp.prepareRestUrl([
429
+ "website", websiteID, "people", "campaigns", peopleID, "list",
430
+ String(pageNumber)
431
+ ])
432
+ );
433
+ };
434
+
435
+ /**
436
+ * Add A People Event
437
+ */
438
+ addPeopleEvent(
439
+ websiteID: string, peopleID: string, peopleEvent: PeopleEvent
440
+ ) {
441
+ return this.crisp.post(
442
+ this.crisp.prepareRestUrl([
443
+ "website", websiteID, "people", "events", peopleID
444
+ ]),
445
+
446
+ null, peopleEvent
447
+ );
448
+ };
449
+
450
+ /**
451
+ * List People Events
452
+ */
453
+ listPeopleEvents(
454
+ websiteID: string, peopleID: string, pageNumber: number = 1
455
+ ): Promise<PeopleEvent[]> {
456
+ return this.crisp.get(
457
+ this.crisp.prepareRestUrl([
458
+ "website", websiteID, "people", "events", peopleID, "list",
459
+ String(pageNumber)
460
+ ])
461
+ );
462
+ };
463
+
464
+ /**
465
+ * Get People Data
466
+ */
467
+ getPeopleData(websiteID: string, peopleID: string): Promise<PeopleData> {
468
+ return this.crisp.get(
469
+ this.crisp.prepareRestUrl([
470
+ "website", websiteID, "people", "data", peopleID
471
+ ])
472
+ );
473
+ };
474
+
475
+ /**
476
+ * Save People Data
477
+ */
478
+ savePeopleData(
479
+ websiteID: string, peopleID: string, peopleData: Record<string, boolean|string|number>
480
+ ) {
481
+ return this.crisp.put(
482
+ this.crisp.prepareRestUrl([
483
+ "website", websiteID, "people", "data", peopleID
484
+ ]),
485
+
486
+ null, peopleData
487
+ );
488
+ };
489
+
490
+ /**
491
+ * Update People Data
492
+ */
493
+ updatePeopleData(
494
+ websiteID: string, peopleID: string,
495
+ peopleData: Record<string, boolean|string|number>
496
+ ) {
497
+ return this.crisp.patch(
498
+ this.crisp.prepareRestUrl([
499
+ "website", websiteID, "people", "data", peopleID
500
+ ]),
501
+
502
+ null, peopleData
503
+ );
504
+ };
505
+
506
+ /**
507
+ * Get People Subscription Status
508
+ */
509
+ getPeopleSubscriptionStatus(
510
+ websiteID: string, peopleID: string
511
+ ): Promise<PeopleSubscription> {
512
+ return this.crisp.get(
513
+ this.crisp.prepareRestUrl([
514
+ "website", websiteID, "people", "subscription", peopleID
515
+ ])
516
+ );
517
+ };
518
+
519
+ /**
520
+ * Update People Subscription Status
521
+ */
522
+ updatePeopleSubscriptionStatus(
523
+ websiteID: string, peopleID: string,
524
+ peopleSubscription: PeopleSubscriptionUpdate
525
+ ) {
526
+ return this.crisp.patch(
527
+ this.crisp.prepareRestUrl([
528
+ "website", websiteID, "people", "subscription", peopleID
529
+ ]),
530
+
531
+ null, peopleSubscription
532
+ );
533
+ };
534
+
535
+ /**
536
+ * Export People Profiles
537
+ */
538
+ exportPeopleProfiles(websiteID: string) {
539
+ return this.crisp.post(
540
+ this.crisp.prepareRestUrl([
541
+ "website", websiteID, "people", "export", "profiles"
542
+ ]),
543
+
544
+ null, null
545
+ );
546
+ };
547
+
548
+ /**
549
+ * Import People Profiles
550
+ */
551
+ importPeopleProfiles(
552
+ websiteID: string, importSetup: PeopleProfileImportSetup
553
+ ) {
554
+ return this.crisp.post(
555
+ this.crisp.prepareRestUrl([
556
+ "website", websiteID, "people", "import", "profiles"
557
+ ]),
558
+
559
+ null, importSetup
560
+ );
561
+ };
562
+ }
563
+
564
+ /**************************************************************************
565
+ * EXPORTS
566
+ ***************************************************************************/
567
+
568
+ export default WebsitePeople;