webitel-sdk 0.1.105 → 0.1.108

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.
@@ -23816,8 +23816,13 @@ class Call {
23816
23816
  /* Call control */
23817
23817
  async answer(req) {
23818
23818
  if (this.sip && this.client.phone) {
23819
- const params = await this.client.phone.callOption(req);
23820
- await this.sip.answer(params);
23819
+ try {
23820
+ const params = await this.client.phone.callOption(req);
23821
+ await this.sip.answer(params);
23822
+ }
23823
+ catch (e) {
23824
+ this.client.handleError(e);
23825
+ }
23821
23826
  return true;
23822
23827
  }
23823
23828
  return false;
@@ -24296,6 +24301,10 @@ const WEBSOCKET_EVENT_AGENT_STATUS = 'agent_status';
24296
24301
  const WEBSOCKET_EVENT_CHANNEL_STATUS = 'channel';
24297
24302
  const TASK_EVENT = 'task';
24298
24303
  const WEBSOCKET_EVENT_SIP = 'sip';
24304
+ var HandleError;
24305
+ (function (HandleError) {
24306
+ HandleError["NotFoundError"] = "NotFoundError";
24307
+ })(HandleError || (HandleError = {}));
24299
24308
  var Response;
24300
24309
  (function (Response) {
24301
24310
  Response["STATUS_FAIL"] = "FAIL";
@@ -24555,13 +24564,7 @@ class Client extends EventEmitter {
24555
24564
  await this.phone.call(req);
24556
24565
  }
24557
24566
  catch (e) {
24558
- switch (e.name) {
24559
- case 'NotFoundError':
24560
- this.emit('error', new DeviceNotFoundError(e));
24561
- break;
24562
- default:
24563
- this.emit('error', e);
24564
- }
24567
+ this.handleError(e);
24565
24568
  }
24566
24569
  }
24567
24570
  else {
@@ -24600,8 +24603,9 @@ class Client extends EventEmitter {
24600
24603
  return this.request(WEBSOCKET_MAKE_USER_CALL, req);
24601
24604
  }
24602
24605
  async answer(id, req) {
24603
- if (this.phone) {
24604
- return this.phone.answer(id, req);
24606
+ const call = this.callById(id);
24607
+ if (call) {
24608
+ return call.answer(req);
24605
24609
  }
24606
24610
  }
24607
24611
  request(action, data) {
@@ -24700,6 +24704,17 @@ class Client extends EventEmitter {
24700
24704
  fileUrlStream(fileId) {
24701
24705
  return `${this.basePath}/api/storage/file/${fileId}/stream?access_token=${this._config.token}`;
24702
24706
  }
24707
+ handleError(e) {
24708
+ if (e) {
24709
+ switch (e.name) {
24710
+ case HandleError.NotFoundError:
24711
+ this.emit('error', new DeviceNotFoundError(e.message));
24712
+ break;
24713
+ default:
24714
+ this.emit('error', e);
24715
+ }
24716
+ }
24717
+ }
24703
24718
  async onMessage(message) {
24704
24719
  this.log.debug('receive message: ', message);
24705
24720
  if (message.seq_reply > 0) {