webitel-sdk 0.1.89 → 0.1.93

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 (54) hide show
  1. package/bundles/index.esm.js +212 -44
  2. package/bundles/index.esm.js.map +1 -1
  3. package/bundles/index.esm.min.js +1 -1
  4. package/bundles/index.esm.min.js.map +1 -1
  5. package/bundles/index.umd.js +239 -45
  6. package/bundles/index.umd.js.map +1 -1
  7. package/bundles/index.umd.min.js +1 -1
  8. package/bundles/index.umd.min.js.map +1 -1
  9. package/esm2015/api/engine-patch-queue-bucket-request.js +13 -0
  10. package/esm2015/api/engine-patch-queue-bucket-request.js.map +1 -0
  11. package/esm2015/api/index.js.map +1 -1
  12. package/esm2015/api/queue-bucket-service-api.js +125 -27
  13. package/esm2015/api/queue-bucket-service-api.js.map +1 -1
  14. package/esm2015/sip/webrtc/index.js +1 -1
  15. package/esm2015/sip/webrtc/index.js.map +1 -1
  16. package/esm2015/socket/client.js +54 -5
  17. package/esm2015/socket/client.js.map +1 -1
  18. package/esm2015/socket/conversation.js +26 -9
  19. package/esm2015/socket/conversation.js.map +1 -1
  20. package/esm2015/socket/task.js +6 -2
  21. package/esm2015/socket/task.js.map +1 -1
  22. package/esm5/api/engine-patch-queue-bucket-request.js +13 -0
  23. package/esm5/api/engine-patch-queue-bucket-request.js.map +1 -0
  24. package/esm5/api/index.js.map +1 -1
  25. package/esm5/api/queue-bucket-service-api.js +138 -27
  26. package/esm5/api/queue-bucket-service-api.js.map +1 -1
  27. package/esm5/sip/webrtc/index.js +1 -1
  28. package/esm5/sip/webrtc/index.js.map +1 -1
  29. package/esm5/socket/client.js +58 -6
  30. package/esm5/socket/client.js.map +1 -1
  31. package/esm5/socket/conversation.js +31 -9
  32. package/esm5/socket/conversation.js.map +1 -1
  33. package/esm5/socket/task.js +11 -2
  34. package/esm5/socket/task.js.map +1 -1
  35. package/package.json +1 -1
  36. package/types/api/engine-create-queue-bucket-request.d.ts +8 -2
  37. package/types/api/engine-create-queue-bucket-request.d.ts.map +1 -1
  38. package/types/api/engine-patch-queue-bucket-request.d.ts +62 -0
  39. package/types/api/engine-patch-queue-bucket-request.d.ts.map +1 -0
  40. package/types/api/engine-queue-bucket.d.ts +12 -0
  41. package/types/api/engine-queue-bucket.d.ts.map +1 -1
  42. package/types/api/engine-update-queue-bucket-request.d.ts +8 -2
  43. package/types/api/engine-update-queue-bucket-request.d.ts.map +1 -1
  44. package/types/api/index.d.ts +1 -0
  45. package/types/api/index.d.ts.map +1 -1
  46. package/types/api/queue-bucket-service-api.d.ts +46 -16
  47. package/types/api/queue-bucket-service-api.d.ts.map +1 -1
  48. package/types/socket/call.d.ts +2 -2
  49. package/types/socket/call.d.ts.map +1 -1
  50. package/types/socket/client.d.ts.map +1 -1
  51. package/types/socket/conversation.d.ts +15 -5
  52. package/types/socket/conversation.d.ts.map +1 -1
  53. package/types/socket/task.d.ts +3 -0
  54. package/types/socket/task.d.ts.map +1 -1
@@ -16937,11 +16937,10 @@
16937
16937
  * @summary DeleteQueueRouting
16938
16938
  * @param {string} queueId
16939
16939
  * @param {string} id
16940
- * @param {string} [domainId]
16941
16940
  * @param {*} [options] Override http request option.
16942
16941
  * @throws {RequiredError}
16943
16942
  */
16944
- deleteQueueBucket: function (queueId, id, domainId, options) {
16943
+ deleteQueueBucket: function (queueId, id, options) {
16945
16944
  if (options === void 0) { options = {}; }
16946
16945
  return tslib.__awaiter(_this, void 0, void 0, function () {
16947
16946
  var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, headersFromBaseOptions;
@@ -16981,14 +16980,82 @@
16981
16980
  localVarHeaderParameter['X-Webitel-Access'] = localVarApiKeyValue;
16982
16981
  _b.label = 5;
16983
16982
  case 5:
16984
- if (domainId !== undefined) {
16985
- localVarQueryParameter['domain_id'] = domainId;
16983
+ localVarUrlObj.query = tslib.__assign(tslib.__assign(tslib.__assign({}, localVarUrlObj.query), localVarQueryParameter), options.query);
16984
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
16985
+ delete localVarUrlObj.search;
16986
+ headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
16987
+ localVarRequestOptions.headers = tslib.__assign(tslib.__assign(tslib.__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
16988
+ return [2 /*return*/, {
16989
+ url: globalImportUrl.format(localVarUrlObj),
16990
+ options: localVarRequestOptions,
16991
+ }];
16992
+ }
16993
+ });
16994
+ });
16995
+ },
16996
+ /**
16997
+ *
16998
+ * @param {string} queueId
16999
+ * @param {string} id
17000
+ * @param {EnginePatchQueueBucketRequest} body
17001
+ * @param {*} [options] Override http request option.
17002
+ * @throws {RequiredError}
17003
+ */
17004
+ patchQueueBucket: function (queueId, id, body, options) {
17005
+ if (options === void 0) { options = {}; }
17006
+ return tslib.__awaiter(_this, void 0, void 0, function () {
17007
+ var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, headersFromBaseOptions, needsSerialization;
17008
+ return tslib.__generator(this, function (_b) {
17009
+ switch (_b.label) {
17010
+ case 0:
17011
+ // verify required parameter 'queueId' is not null or undefined
17012
+ if (queueId === null || queueId === undefined) {
17013
+ throw new RequiredError('queueId', 'Required parameter queueId was null or undefined when calling patchQueueBucket.');
17014
+ }
17015
+ // verify required parameter 'id' is not null or undefined
17016
+ if (id === null || id === undefined) {
17017
+ throw new RequiredError('id', 'Required parameter id was null or undefined when calling patchQueueBucket.');
17018
+ }
17019
+ // verify required parameter 'body' is not null or undefined
17020
+ if (body === null || body === undefined) {
17021
+ throw new RequiredError('body', 'Required parameter body was null or undefined when calling patchQueueBucket.');
17022
+ }
17023
+ localVarPath = "/call_center/queues/{queue_id}/buckets/{id}"
17024
+ .replace("{" + 'queue_id' + "}", encodeURIComponent(String(queueId)))
17025
+ .replace("{" + 'id' + "}", encodeURIComponent(String(id)));
17026
+ localVarUrlObj = globalImportUrl.parse(localVarPath, true);
17027
+ if (configuration) {
17028
+ baseOptions = configuration.baseOptions;
16986
17029
  }
17030
+ localVarRequestOptions = tslib.__assign(tslib.__assign({ method: 'PATCH' }, baseOptions), options);
17031
+ localVarHeaderParameter = {};
17032
+ localVarQueryParameter = {};
17033
+ if (!(configuration && configuration.apiKey)) return [3 /*break*/, 5];
17034
+ if (!(typeof configuration.apiKey === 'function')) return [3 /*break*/, 2];
17035
+ return [4 /*yield*/, configuration.apiKey('X-Webitel-Access')];
17036
+ case 1:
17037
+ _a = _b.sent();
17038
+ return [3 /*break*/, 4];
17039
+ case 2: return [4 /*yield*/, configuration.apiKey];
17040
+ case 3:
17041
+ _a = _b.sent();
17042
+ _b.label = 4;
17043
+ case 4:
17044
+ localVarApiKeyValue = _a;
17045
+ localVarHeaderParameter['X-Webitel-Access'] = localVarApiKeyValue;
17046
+ _b.label = 5;
17047
+ case 5:
17048
+ localVarHeaderParameter['Content-Type'] = 'application/json';
16987
17049
  localVarUrlObj.query = tslib.__assign(tslib.__assign(tslib.__assign({}, localVarUrlObj.query), localVarQueryParameter), options.query);
16988
17050
  // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
16989
17051
  delete localVarUrlObj.search;
16990
17052
  headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
16991
17053
  localVarRequestOptions.headers = tslib.__assign(tslib.__assign(tslib.__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
17054
+ needsSerialization = typeof body !== 'string' ||
17055
+ localVarRequestOptions.headers['Content-Type'] === 'application/json';
17056
+ localVarRequestOptions.data = needsSerialization
17057
+ ? JSON.stringify(body !== undefined ? body : {})
17058
+ : body || '';
16992
17059
  return [2 /*return*/, {
16993
17060
  url: globalImportUrl.format(localVarUrlObj),
16994
17061
  options: localVarRequestOptions,
@@ -17002,11 +17069,10 @@
17002
17069
  * @summary ReadQueueRouting
17003
17070
  * @param {string} queueId
17004
17071
  * @param {string} id
17005
- * @param {string} [domainId]
17006
17072
  * @param {*} [options] Override http request option.
17007
17073
  * @throws {RequiredError}
17008
17074
  */
17009
- readQueueBucket: function (queueId, id, domainId, options) {
17075
+ readQueueBucket: function (queueId, id, options) {
17010
17076
  if (options === void 0) { options = {}; }
17011
17077
  return tslib.__awaiter(_this, void 0, void 0, function () {
17012
17078
  var localVarPath, localVarUrlObj, baseOptions, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, localVarApiKeyValue, _a, headersFromBaseOptions;
@@ -17046,9 +17112,6 @@
17046
17112
  localVarHeaderParameter['X-Webitel-Access'] = localVarApiKeyValue;
17047
17113
  _b.label = 5;
17048
17114
  case 5:
17049
- if (domainId !== undefined) {
17050
- localVarQueryParameter['domain_id'] = domainId;
17051
- }
17052
17115
  localVarUrlObj.query = tslib.__assign(tslib.__assign(tslib.__assign({}, localVarUrlObj.query), localVarQueryParameter), options.query);
17053
17116
  // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
17054
17117
  delete localVarUrlObj.search;
@@ -17251,16 +17314,41 @@
17251
17314
  * @summary DeleteQueueRouting
17252
17315
  * @param {string} queueId
17253
17316
  * @param {string} id
17254
- * @param {string} [domainId]
17255
17317
  * @param {*} [options] Override http request option.
17256
17318
  * @throws {RequiredError}
17257
17319
  */
17258
- deleteQueueBucket: function (queueId, id, domainId, options) {
17320
+ deleteQueueBucket: function (queueId, id, options) {
17259
17321
  return tslib.__awaiter(this, void 0, void 0, function () {
17260
17322
  var localVarAxiosArgs;
17261
17323
  return tslib.__generator(this, function (_a) {
17262
17324
  switch (_a.label) {
17263
- case 0: return [4 /*yield*/, QueueBucketServiceApiAxiosParamCreator(configuration).deleteQueueBucket(queueId, id, domainId, options)];
17325
+ case 0: return [4 /*yield*/, QueueBucketServiceApiAxiosParamCreator(configuration).deleteQueueBucket(queueId, id, options)];
17326
+ case 1:
17327
+ localVarAxiosArgs = _a.sent();
17328
+ return [2 /*return*/, function (axios, basePath) {
17329
+ if (axios === void 0) { axios = globalAxios; }
17330
+ if (basePath === void 0) { basePath = BASE_PATH; }
17331
+ var axiosRequestArgs = tslib.__assign(tslib.__assign({}, localVarAxiosArgs.options), { url: basePath + localVarAxiosArgs.url });
17332
+ return axios.request(axiosRequestArgs);
17333
+ }];
17334
+ }
17335
+ });
17336
+ });
17337
+ },
17338
+ /**
17339
+ *
17340
+ * @param {string} queueId
17341
+ * @param {string} id
17342
+ * @param {EnginePatchQueueBucketRequest} body
17343
+ * @param {*} [options] Override http request option.
17344
+ * @throws {RequiredError}
17345
+ */
17346
+ patchQueueBucket: function (queueId, id, body, options) {
17347
+ return tslib.__awaiter(this, void 0, void 0, function () {
17348
+ var localVarAxiosArgs;
17349
+ return tslib.__generator(this, function (_a) {
17350
+ switch (_a.label) {
17351
+ case 0: return [4 /*yield*/, QueueBucketServiceApiAxiosParamCreator(configuration).patchQueueBucket(queueId, id, body, options)];
17264
17352
  case 1:
17265
17353
  localVarAxiosArgs = _a.sent();
17266
17354
  return [2 /*return*/, function (axios, basePath) {
@@ -17278,16 +17366,15 @@
17278
17366
  * @summary ReadQueueRouting
17279
17367
  * @param {string} queueId
17280
17368
  * @param {string} id
17281
- * @param {string} [domainId]
17282
17369
  * @param {*} [options] Override http request option.
17283
17370
  * @throws {RequiredError}
17284
17371
  */
17285
- readQueueBucket: function (queueId, id, domainId, options) {
17372
+ readQueueBucket: function (queueId, id, options) {
17286
17373
  return tslib.__awaiter(this, void 0, void 0, function () {
17287
17374
  var localVarAxiosArgs;
17288
17375
  return tslib.__generator(this, function (_a) {
17289
17376
  switch (_a.label) {
17290
- case 0: return [4 /*yield*/, QueueBucketServiceApiAxiosParamCreator(configuration).readQueueBucket(queueId, id, domainId, options)];
17377
+ case 0: return [4 /*yield*/, QueueBucketServiceApiAxiosParamCreator(configuration).readQueueBucket(queueId, id, options)];
17291
17378
  case 1:
17292
17379
  localVarAxiosArgs = _a.sent();
17293
17380
  return [2 /*return*/, function (axios, basePath) {
@@ -17384,13 +17471,25 @@
17384
17471
  * @summary DeleteQueueRouting
17385
17472
  * @param {string} queueId
17386
17473
  * @param {string} id
17387
- * @param {string} [domainId]
17388
17474
  * @param {*} [options] Override http request option.
17389
17475
  * @throws {RequiredError}
17390
17476
  */
17391
- deleteQueueBucket: function (queueId, id, domainId, options) {
17477
+ deleteQueueBucket: function (queueId, id, options) {
17392
17478
  return QueueBucketServiceApiFp(configuration)
17393
- .deleteQueueBucket(queueId, id, domainId, options)
17479
+ .deleteQueueBucket(queueId, id, options)
17480
+ .then(function (request) { return request(axios, basePath); });
17481
+ },
17482
+ /**
17483
+ *
17484
+ * @param {string} queueId
17485
+ * @param {string} id
17486
+ * @param {EnginePatchQueueBucketRequest} body
17487
+ * @param {*} [options] Override http request option.
17488
+ * @throws {RequiredError}
17489
+ */
17490
+ patchQueueBucket: function (queueId, id, body, options) {
17491
+ return QueueBucketServiceApiFp(configuration)
17492
+ .patchQueueBucket(queueId, id, body, options)
17394
17493
  .then(function (request) { return request(axios, basePath); });
17395
17494
  },
17396
17495
  /**
@@ -17398,13 +17497,12 @@
17398
17497
  * @summary ReadQueueRouting
17399
17498
  * @param {string} queueId
17400
17499
  * @param {string} id
17401
- * @param {string} [domainId]
17402
17500
  * @param {*} [options] Override http request option.
17403
17501
  * @throws {RequiredError}
17404
17502
  */
17405
- readQueueBucket: function (queueId, id, domainId, options) {
17503
+ readQueueBucket: function (queueId, id, options) {
17406
17504
  return QueueBucketServiceApiFp(configuration)
17407
- .readQueueBucket(queueId, id, domainId, options)
17505
+ .readQueueBucket(queueId, id, options)
17408
17506
  .then(function (request) { return request(axios, basePath); });
17409
17507
  },
17410
17508
  /**
@@ -17472,15 +17570,29 @@
17472
17570
  * @summary DeleteQueueRouting
17473
17571
  * @param {string} queueId
17474
17572
  * @param {string} id
17475
- * @param {string} [domainId]
17476
17573
  * @param {*} [options] Override http request option.
17477
17574
  * @throws {RequiredError}
17478
17575
  * @memberof QueueBucketServiceApi
17479
17576
  */
17480
- QueueBucketServiceApi.prototype.deleteQueueBucket = function (queueId, id, domainId, options) {
17577
+ QueueBucketServiceApi.prototype.deleteQueueBucket = function (queueId, id, options) {
17481
17578
  var _this = this;
17482
17579
  return QueueBucketServiceApiFp(this.configuration)
17483
- .deleteQueueBucket(queueId, id, domainId, options)
17580
+ .deleteQueueBucket(queueId, id, options)
17581
+ .then(function (request) { return request(_this.axios, _this.basePath); });
17582
+ };
17583
+ /**
17584
+ *
17585
+ * @param {string} queueId
17586
+ * @param {string} id
17587
+ * @param {EnginePatchQueueBucketRequest} body
17588
+ * @param {*} [options] Override http request option.
17589
+ * @throws {RequiredError}
17590
+ * @memberof QueueBucketServiceApi
17591
+ */
17592
+ QueueBucketServiceApi.prototype.patchQueueBucket = function (queueId, id, body, options) {
17593
+ var _this = this;
17594
+ return QueueBucketServiceApiFp(this.configuration)
17595
+ .patchQueueBucket(queueId, id, body, options)
17484
17596
  .then(function (request) { return request(_this.axios, _this.basePath); });
17485
17597
  };
17486
17598
  /**
@@ -17488,15 +17600,14 @@
17488
17600
  * @summary ReadQueueRouting
17489
17601
  * @param {string} queueId
17490
17602
  * @param {string} id
17491
- * @param {string} [domainId]
17492
17603
  * @param {*} [options] Override http request option.
17493
17604
  * @throws {RequiredError}
17494
17605
  * @memberof QueueBucketServiceApi
17495
17606
  */
17496
- QueueBucketServiceApi.prototype.readQueueBucket = function (queueId, id, domainId, options) {
17607
+ QueueBucketServiceApi.prototype.readQueueBucket = function (queueId, id, options) {
17497
17608
  var _this = this;
17498
17609
  return QueueBucketServiceApiFp(this.configuration)
17499
- .readQueueBucket(queueId, id, domainId, options)
17610
+ .readQueueBucket(queueId, id, options)
17500
17611
  .then(function (request) { return request(_this.axios, _this.basePath); });
17501
17612
  };
17502
17613
  /**
@@ -24833,7 +24944,7 @@
24833
24944
  switch (_a.label) {
24834
24945
  case 0:
24835
24946
  if (!this.ua) return [3 /*break*/, 2];
24836
- this.ua.ua.terminateSessions();
24947
+ this.ua.terminateSessions();
24837
24948
  this.ua.removeAllListeners();
24838
24949
  return [4 /*yield*/, this.ua.stop()];
24839
24950
  case 1:
@@ -25053,6 +25164,7 @@
25053
25164
  this.offeringAt = 0;
25054
25165
  this.answeredAt = 0;
25055
25166
  this.bridgedAt = 0;
25167
+ this.reportedAt = 0;
25056
25168
  this.startProcessingAt = 0;
25057
25169
  this.stopAt = 0;
25058
25170
  this.closedAt = 0;
@@ -25151,11 +25263,12 @@
25151
25263
  this.lastStatusChange = Date.now();
25152
25264
  };
25153
25265
  Task.prototype.setProcessing = function (p) {
25266
+ this.state = 'processing'; // todo
25154
25267
  if (!this.startProcessingAt) {
25155
25268
  this.startProcessingAt = Date.now();
25156
25269
  }
25157
25270
  if (p.sec) {
25158
- p.timeout = Date.now() + p.sec * 1000; // bug
25271
+ p.timeout = this.startProcessingAt + p.sec * 1000; // bug
25159
25272
  }
25160
25273
  this._processing = p;
25161
25274
  };
@@ -25232,8 +25345,15 @@
25232
25345
  };
25233
25346
  Task.prototype.reporting = function (reporting) {
25234
25347
  return tslib.__awaiter(this, void 0, void 0, function () {
25348
+ var res;
25235
25349
  return tslib.__generator(this, function (_a) {
25236
- return [2 /*return*/, this.client.request('cc_reporting', tslib.__assign({ attempt_id: this.id }, reporting))];
25350
+ switch (_a.label) {
25351
+ case 0: return [4 /*yield*/, this.client.request('cc_reporting', tslib.__assign({ attempt_id: this.id }, reporting))];
25352
+ case 1:
25353
+ res = _a.sent();
25354
+ this.reportedAt = Date.now();
25355
+ return [2 /*return*/, res];
25356
+ }
25237
25357
  });
25238
25358
  });
25239
25359
  };
@@ -26165,7 +26285,13 @@
26165
26285
  this.members = (members || []).map(function (i) { return wrapChannelMember(i); });
26166
26286
  this._messages = messages || [];
26167
26287
  this.state = exports.ConversationState.Invite;
26168
- this.variables = variables;
26288
+ this.variables = {};
26289
+ this._hasReporting = !!(variables && variables.cc_reporting === 'true');
26290
+ for (var k in variables) {
26291
+ if (!k.startsWith('cc_') && variables.hasOwnProperty(k)) {
26292
+ this.variables[k] = variables[k];
26293
+ }
26294
+ }
26169
26295
  if (variables &&
26170
26296
  variables.hasOwnProperty('cc_attempt_id') &&
26171
26297
  this.client.agent) {
@@ -26189,7 +26315,7 @@
26189
26315
  };
26190
26316
  Object.defineProperty(Conversation.prototype, "id", {
26191
26317
  get: function () {
26192
- return this.conversationId;
26318
+ return this.channelId || this.inviteId || this.conversationId;
26193
26319
  },
26194
26320
  enumerable: true,
26195
26321
  configurable: true
@@ -26211,6 +26337,7 @@
26211
26337
  channelId: i.channel_id,
26212
26338
  createdAt: i.created_at,
26213
26339
  updatedAt: i.updated_at,
26340
+ contact: null,
26214
26341
  };
26215
26342
  if (i.hasOwnProperty('file')) {
26216
26343
  i.file.url = _this.client.fileUrlDownload(i.file.id);
@@ -26219,6 +26346,9 @@
26219
26346
  if (i.hasOwnProperty('text')) {
26220
26347
  msg.text = i.text;
26221
26348
  }
26349
+ if (i.hasOwnProperty('contact')) {
26350
+ msg.contact = i.contact;
26351
+ }
26222
26352
  return msg;
26223
26353
  });
26224
26354
  };
@@ -26269,7 +26399,19 @@
26269
26399
  });
26270
26400
  Object.defineProperty(Conversation.prototype, "hasReporting", {
26271
26401
  get: function () {
26272
- return this.variables && this.variables.cc_reporting === 'true';
26402
+ return this._hasReporting;
26403
+ },
26404
+ enumerable: true,
26405
+ configurable: true
26406
+ });
26407
+ Object.defineProperty(Conversation.prototype, "membersId", {
26408
+ get: function () {
26409
+ var res = [this.id];
26410
+ for (var _i = 0, _a = this.members; _i < _a.length; _i++) {
26411
+ var m = _a[_i];
26412
+ res.push(m.id);
26413
+ }
26414
+ return res;
26273
26415
  },
26274
26416
  enumerable: true,
26275
26417
  configurable: true
@@ -26306,7 +26448,7 @@
26306
26448
  throw new Error('This conversation not active');
26307
26449
  return [2 /*return*/, this.client.request("close_chat", {
26308
26450
  channel_id: this.channelId,
26309
- conversation_id: this.id,
26451
+ conversation_id: this.conversationId,
26310
26452
  cause: cause,
26311
26453
  })];
26312
26454
  });
@@ -26319,7 +26461,7 @@
26319
26461
  throw new Error('This conversation not active');
26320
26462
  return [2 /*return*/, this.client.request("leave_chat", {
26321
26463
  channel_id: this.channelId,
26322
- conversation_id: this.id,
26464
+ conversation_id: this.conversationId,
26323
26465
  cause: cause,
26324
26466
  })];
26325
26467
  });
@@ -26362,14 +26504,14 @@
26362
26504
  var storedFiles, f;
26363
26505
  return tslib.__generator(this, function (_a) {
26364
26506
  switch (_a.label) {
26365
- case 0: return [4 /*yield*/, this.client.storeFile(this.id, [file], cb)];
26507
+ case 0: return [4 /*yield*/, this.client.storeFile(this.conversationId, [file], cb)];
26366
26508
  case 1:
26367
26509
  storedFiles = _a.sent();
26368
26510
  f = storedFiles[0];
26369
26511
  // todo bug if chat response error
26370
26512
  return [2 /*return*/, this.client.request("send_file_chat", {
26371
26513
  channel_id: this.channelId,
26372
- conversation_id: this.id,
26514
+ conversation_id: this.conversationId,
26373
26515
  id: f.id,
26374
26516
  name: file.name,
26375
26517
  mime: f.mime,
@@ -26401,7 +26543,7 @@
26401
26543
  return tslib.__generator(this, function (_a) {
26402
26544
  return [2 /*return*/, this.client.request("add_to_chat", {
26403
26545
  channel_id: this.channelId,
26404
- conversation_id: this.id,
26546
+ conversation_id: this.conversationId,
26405
26547
  user_id: userId,
26406
26548
  title: title,
26407
26549
  })];
@@ -26449,7 +26591,7 @@
26449
26591
  Conversation.prototype.sendMessageTextChunk = function (text) {
26450
26592
  return this.client.request("send_text_chat", {
26451
26593
  channel_id: this.channelId,
26452
- conversation_id: this.id,
26594
+ conversation_id: this.conversationId,
26453
26595
  text: text,
26454
26596
  });
26455
26597
  };
@@ -26613,7 +26755,7 @@
26613
26755
  call.answeredAt = c.answered_at || 0;
26614
26756
  call.bridgedAt = c.bridged_at || 0;
26615
26757
  call.hangupAt = c.hangup_at || 0;
26616
- call.reportingAt = c.reporting_at || 0;
26758
+ // call.reportingAt = c.reporting_at || 0
26617
26759
  if (c.task) {
26618
26760
  call.task = new Task(this, {
26619
26761
  attempt_id: c.task.attempt_id,
@@ -26623,6 +26765,14 @@
26623
26765
  }, c.task // todo add app_id
26624
26766
  );
26625
26767
  call.queue.reporting = 'true';
26768
+ if (c.leaving_at && c.task.processing_sec) {
26769
+ call.task.startProcessingAt = c.leaving_at;
26770
+ call.task.setProcessing({
26771
+ sec: c.task.processing_sec || 0,
26772
+ timeout: Date.now() - c.leaving_at + (c.task.processing_sec || 0) * 1000,
26773
+ renewal_sec: c.task.processing_renewal_sec || 0,
26774
+ });
26775
+ }
26626
26776
  }
26627
26777
  this.callStore.set(call.id, call);
26628
26778
  }
@@ -26647,6 +26797,26 @@
26647
26797
  messages = conv.messages.reverse();
26648
26798
  c = new Conversation(this, conv.id, conv.title, conv.members, messages, conv.variables);
26649
26799
  c.createdAt = conv.created_at;
26800
+ c.closedAt = conv.closed_at;
26801
+ if (conv.task) {
26802
+ c.task = new Task(this, {
26803
+ attempt_id: conv.task.attempt_id,
26804
+ channel: conv.task.channel,
26805
+ status: conv.task.status,
26806
+ timestamp: Date.now(),
26807
+ }, conv.task // todo add app_id
26808
+ );
26809
+ if (conv.leaving_at && conv.task.processing_sec) {
26810
+ c.task.startProcessingAt = conv.leaving_at;
26811
+ c.task.setProcessing({
26812
+ sec: conv.task.processing_sec || 0,
26813
+ timeout: Date.now() -
26814
+ conv.leaving_at +
26815
+ (conv.task.processing_sec || 0) * 1000,
26816
+ renewal_sec: conv.task.processing_renewal_sec || 0,
26817
+ });
26818
+ }
26819
+ }
26650
26820
  if (conv.invite_id) {
26651
26821
  c.setInvite(conv.invite_id, conv.created_at);
26652
26822
  }
@@ -27356,8 +27526,8 @@
27356
27526
  };
27357
27527
  Client.prototype.handleChatEvents = function (event) {
27358
27528
  return tslib.__awaiter(this, void 0, void 0, function () {
27359
- var conversation, timestamp, inv, joined, message, e;
27360
- return tslib.__generator(this, function (_a) {
27529
+ var conversation, timestamp, inv, joined, message, _i, _a, v, c, _b, _c, v, l, e;
27530
+ return tslib.__generator(this, function (_d) {
27361
27531
  timestamp = Date.now() // todo bug
27362
27532
  ;
27363
27533
  switch (event.action) {
@@ -27369,7 +27539,7 @@
27369
27539
  break;
27370
27540
  case exports.ChatActions.Joined:
27371
27541
  joined = event.data;
27372
- conversation = this.conversationById(joined.conversation_id);
27542
+ conversation = this.conversationById(joined.member.id);
27373
27543
  if (conversation) {
27374
27544
  conversation.setAnswered(joined.member.id, timestamp, joined.member);
27375
27545
  }
@@ -27377,16 +27547,40 @@
27377
27547
  case exports.ChatActions.Message:
27378
27548
  message = event.data;
27379
27549
  message.timestamp = timestamp;
27380
- conversation = this.conversationById(message.conversation_id);
27550
+ // fixme
27551
+ for (_i = 0, _a = this.allConversations(); _i < _a.length; _i++) {
27552
+ v = _a[_i];
27553
+ if (!v.closedAt && v.membersId.indexOf(message.channel_id) > -1) {
27554
+ conversation = v;
27555
+ }
27556
+ }
27381
27557
  if (conversation) {
27382
27558
  conversation.newMessage(message);
27383
27559
  }
27384
27560
  break;
27385
27561
  case exports.ChatActions.Close:
27562
+ c = event.data;
27563
+ // fixme
27564
+ for (_b = 0, _c = this.allConversations(); _b < _c.length; _b++) {
27565
+ v = _c[_b];
27566
+ if (!v.closedAt && v.membersId.indexOf(c.from_channel_id) > -1) {
27567
+ conversation = v;
27568
+ }
27569
+ }
27570
+ if (conversation) {
27571
+ conversation.setClosed(timestamp);
27572
+ }
27573
+ break;
27386
27574
  case exports.ChatActions.Leave:
27575
+ l = event.data;
27576
+ conversation = this.conversationById(l.leaved_channel_id);
27577
+ if (conversation) {
27578
+ conversation.setClosed(timestamp);
27579
+ }
27580
+ break;
27387
27581
  case exports.ChatActions.Decline:
27388
27582
  e = event.data;
27389
- conversation = this.conversationById(e.conversation_id);
27583
+ conversation = this.conversationById(e.invite_id);
27390
27584
  if (conversation) {
27391
27585
  conversation.setClosed(timestamp);
27392
27586
  }