@wazo/sdk 0.38.1 → 0.38.2

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.
@@ -12857,8 +12857,6 @@ class Checker {
12857
12857
  /* eslint-disable no-unused-vars */
12858
12858
  /* global window, document */
12859
12859
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
12860
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
12861
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
12862
12860
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
12863
12861
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
12864
12862
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -12871,6 +12869,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
12871
12869
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
12872
12870
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12873
12871
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12872
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
12874
12873
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12875
12874
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12876
12875
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12884,6 +12883,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
12884
12883
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
12885
12884
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
12886
12885
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
12886
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
12887
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
12888
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
12889
+
12890
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
12891
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
12887
12892
 
12888
12893
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
12889
12894
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -12893,22 +12898,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
12893
12898
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
12894
12899
 
12895
12900
  class Softphone {
12896
- url = 'https://softphone.wazo.io';
12897
- width = 500;
12898
- height = 600;
12899
- displayed = false;
12900
- iframe = null;
12901
+
12902
+
12903
+
12904
+
12905
+
12906
+
12907
+
12908
+ // Message waiting for the iframe to be loaded
12909
+
12901
12910
 
12902
12911
  onLinkEnabled(link ) {}
12903
12912
  onIFrameLoaded() {}
12904
12913
 
12914
+ onCallAnswered() {}
12905
12915
  onCallMade(call ) {}
12906
12916
  onCallIncoming(call ) {}
12907
12917
  onCallEnded(call , card , direction , fromExtension ) {}
12908
12918
  onCardSaved(card ) {}
12919
+ onCardCanceled() {}
12909
12920
  onAuthenticated(session ) {}
12910
12921
  onLoggedOut() {}
12911
- onSearchOptions(fieldId , query ) {}
12922
+
12923
+ onSearchOptions(fieldId , query ) {
12924
+ this.onOptionsResults(fieldId, []);
12925
+ }
12926
+
12912
12927
  onDisplayLinkedOption(optionId ) {}
12913
12928
  onWazoContactSearch(query ) {}
12914
12929
  onAgentLoggedIn() {}
@@ -12931,18 +12946,15 @@ class Softphone {
12931
12946
  onStopRecording() {}
12932
12947
  onUnHandledEvent(event ) {}
12933
12948
 
12934
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
12935
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
12936
- if (url) {
12937
- this.url = url;
12938
- }
12939
- if (width) {
12940
- this.width = width;
12941
- }
12942
- if (height) {
12943
- this.height = height;
12944
- }
12949
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
12950
+ this.url = url || 'https://softphone.wazo.io';
12951
+ this.width = width || 500;
12952
+ this.height = height || 600;
12953
+ this.displayed = false;
12954
+ this.iframeLoaded = false;
12945
12955
 
12956
+ this.iframeLoaded = false;
12957
+ this._pendingMessages = [];
12946
12958
  window.addEventListener('message', this._onMessage.bind(this), false);
12947
12959
 
12948
12960
  if (!server) {
@@ -12950,25 +12962,26 @@ class Softphone {
12950
12962
  server = 'stack.dev.wazo.io';
12951
12963
  }
12952
12964
 
12953
- this._createIframe(() => {
12954
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
12955
- config: {
12956
- server,
12957
- port,
12958
- language,
12959
- wrapUpDuration,
12960
- shouldDisplayLinkedEntities,
12961
- allowContactCreation,
12962
- },
12963
- });
12965
+ const config = { server };
12966
+ if (language) {
12967
+ config.language = language;
12968
+ }
12969
+ if (port) {
12970
+ config.port = port;
12971
+ }
12972
+ if (wrapUpDuration) {
12973
+ config.wrapUpDuration = wrapUpDuration;
12974
+ }
12964
12975
 
12965
- if (withCard) {
12966
- this._sendMessage(BRIDGE_ENABLE_CARD);
12967
- }
12976
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
12968
12977
 
12969
- if (subscriptionType) {
12970
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
12971
- }
12978
+ if (enableAgent) {
12979
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
12980
+ }
12981
+
12982
+ this._createIframe(() => {
12983
+ this.iframeLoaded = true;
12984
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
12972
12985
 
12973
12986
  this.onIFrameLoaded();
12974
12987
  });
@@ -13029,6 +13042,18 @@ class Softphone {
13029
13042
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13030
13043
  }
13031
13044
 
13045
+ setCardValue(field , value ) {
13046
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13047
+ }
13048
+
13049
+ injectCss(css ) {
13050
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13051
+ }
13052
+
13053
+ customizeAppearance(themes , translations , assets ) {
13054
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13055
+ }
13056
+
13032
13057
  _createIframe(cb = () => {}) {
13033
13058
  this.iframe = document.createElement('iframe');
13034
13059
  // $FlowFixMe
@@ -13163,6 +13188,12 @@ class Softphone {
13163
13188
  case BRIDGE_ON_STOP_RECORDING:
13164
13189
  this.onStopRecording();
13165
13190
  break;
13191
+ case BRIDGE_ON_CARD_CANCELED:
13192
+ this.onCardCanceled();
13193
+ break;
13194
+ case BRIDGE_ON_CALL_ANSWERED:
13195
+ this.onCallAnswered();
13196
+ break;
13166
13197
  default:
13167
13198
  this.onUnHandledEvent(event);
13168
13199
  break;
@@ -13170,8 +13201,8 @@ class Softphone {
13170
13201
  }
13171
13202
 
13172
13203
  _sendMessage(type , payload = {}) {
13173
- if (!this.iframe) {
13174
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13204
+ if (!this.iframe || !this.iframeLoaded) {
13205
+ this._pendingMessages.push([type, payload]);
13175
13206
  return;
13176
13207
  }
13177
13208
 
@@ -13136,8 +13136,6 @@ class Checker {
13136
13136
  /* eslint-disable no-unused-vars */
13137
13137
  /* global window, document */
13138
13138
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13139
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13140
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13141
13139
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13142
13140
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13143
13141
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13150,6 +13148,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13150
13148
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13151
13149
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13152
13150
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13151
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13153
13152
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13154
13153
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13155
13154
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13163,6 +13162,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13163
13162
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13164
13163
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13165
13164
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13165
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13166
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13167
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13168
+
13169
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13170
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13166
13171
 
13167
13172
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13168
13173
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13172,22 +13177,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13172
13177
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13173
13178
 
13174
13179
  class Softphone {
13175
- url = 'https://softphone.wazo.io';
13176
- width = 500;
13177
- height = 600;
13178
- displayed = false;
13179
- iframe = null;
13180
+
13181
+
13182
+
13183
+
13184
+
13185
+
13186
+
13187
+ // Message waiting for the iframe to be loaded
13188
+
13180
13189
 
13181
13190
  onLinkEnabled(link ) {}
13182
13191
  onIFrameLoaded() {}
13183
13192
 
13193
+ onCallAnswered() {}
13184
13194
  onCallMade(call ) {}
13185
13195
  onCallIncoming(call ) {}
13186
13196
  onCallEnded(call , card , direction , fromExtension ) {}
13187
13197
  onCardSaved(card ) {}
13198
+ onCardCanceled() {}
13188
13199
  onAuthenticated(session ) {}
13189
13200
  onLoggedOut() {}
13190
- onSearchOptions(fieldId , query ) {}
13201
+
13202
+ onSearchOptions(fieldId , query ) {
13203
+ this.onOptionsResults(fieldId, []);
13204
+ }
13205
+
13191
13206
  onDisplayLinkedOption(optionId ) {}
13192
13207
  onWazoContactSearch(query ) {}
13193
13208
  onAgentLoggedIn() {}
@@ -13210,18 +13225,15 @@ class Softphone {
13210
13225
  onStopRecording() {}
13211
13226
  onUnHandledEvent(event ) {}
13212
13227
 
13213
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13214
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13215
- if (url) {
13216
- this.url = url;
13217
- }
13218
- if (width) {
13219
- this.width = width;
13220
- }
13221
- if (height) {
13222
- this.height = height;
13223
- }
13228
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13229
+ this.url = url || 'https://softphone.wazo.io';
13230
+ this.width = width || 500;
13231
+ this.height = height || 600;
13232
+ this.displayed = false;
13233
+ this.iframeLoaded = false;
13224
13234
 
13235
+ this.iframeLoaded = false;
13236
+ this._pendingMessages = [];
13225
13237
  window.addEventListener('message', this._onMessage.bind(this), false);
13226
13238
 
13227
13239
  if (!server) {
@@ -13229,25 +13241,26 @@ class Softphone {
13229
13241
  server = 'stack.dev.wazo.io';
13230
13242
  }
13231
13243
 
13232
- this._createIframe(() => {
13233
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13234
- config: {
13235
- server,
13236
- port,
13237
- language,
13238
- wrapUpDuration,
13239
- shouldDisplayLinkedEntities,
13240
- allowContactCreation,
13241
- },
13242
- });
13244
+ const config = { server };
13245
+ if (language) {
13246
+ config.language = language;
13247
+ }
13248
+ if (port) {
13249
+ config.port = port;
13250
+ }
13251
+ if (wrapUpDuration) {
13252
+ config.wrapUpDuration = wrapUpDuration;
13253
+ }
13243
13254
 
13244
- if (withCard) {
13245
- this._sendMessage(BRIDGE_ENABLE_CARD);
13246
- }
13255
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13247
13256
 
13248
- if (subscriptionType) {
13249
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13250
- }
13257
+ if (enableAgent) {
13258
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13259
+ }
13260
+
13261
+ this._createIframe(() => {
13262
+ this.iframeLoaded = true;
13263
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13251
13264
 
13252
13265
  this.onIFrameLoaded();
13253
13266
  });
@@ -13308,6 +13321,18 @@ class Softphone {
13308
13321
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13309
13322
  }
13310
13323
 
13324
+ setCardValue(field , value ) {
13325
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13326
+ }
13327
+
13328
+ injectCss(css ) {
13329
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13330
+ }
13331
+
13332
+ customizeAppearance(themes , translations , assets ) {
13333
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13334
+ }
13335
+
13311
13336
  _createIframe(cb = () => {}) {
13312
13337
  this.iframe = document.createElement('iframe');
13313
13338
  // $FlowFixMe
@@ -13442,6 +13467,12 @@ class Softphone {
13442
13467
  case BRIDGE_ON_STOP_RECORDING:
13443
13468
  this.onStopRecording();
13444
13469
  break;
13470
+ case BRIDGE_ON_CARD_CANCELED:
13471
+ this.onCardCanceled();
13472
+ break;
13473
+ case BRIDGE_ON_CALL_ANSWERED:
13474
+ this.onCallAnswered();
13475
+ break;
13445
13476
  default:
13446
13477
  this.onUnHandledEvent(event);
13447
13478
  break;
@@ -13449,8 +13480,8 @@ class Softphone {
13449
13480
  }
13450
13481
 
13451
13482
  _sendMessage(type , payload = {}) {
13452
- if (!this.iframe) {
13453
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13483
+ if (!this.iframe || !this.iframeLoaded) {
13484
+ this._pendingMessages.push([type, payload]);
13454
13485
  return;
13455
13486
  }
13456
13487
 
@@ -13149,8 +13149,6 @@ class Checker {
13149
13149
  /* eslint-disable no-unused-vars */
13150
13150
  /* global window, document */
13151
13151
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13152
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13153
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13154
13152
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13155
13153
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13156
13154
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13163,6 +13161,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13163
13161
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13164
13162
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13165
13163
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13164
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13166
13165
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13167
13166
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13168
13167
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13176,6 +13175,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13176
13175
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13177
13176
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13178
13177
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13178
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13179
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13180
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13181
+
13182
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13183
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13179
13184
 
13180
13185
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13181
13186
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13185,22 +13190,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13185
13190
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13186
13191
 
13187
13192
  class Softphone {
13188
- url = 'https://softphone.wazo.io';
13189
- width = 500;
13190
- height = 600;
13191
- displayed = false;
13192
- iframe = null;
13193
+
13194
+
13195
+
13196
+
13197
+
13198
+
13199
+
13200
+ // Message waiting for the iframe to be loaded
13201
+
13193
13202
 
13194
13203
  onLinkEnabled(link ) {}
13195
13204
  onIFrameLoaded() {}
13196
13205
 
13206
+ onCallAnswered() {}
13197
13207
  onCallMade(call ) {}
13198
13208
  onCallIncoming(call ) {}
13199
13209
  onCallEnded(call , card , direction , fromExtension ) {}
13200
13210
  onCardSaved(card ) {}
13211
+ onCardCanceled() {}
13201
13212
  onAuthenticated(session ) {}
13202
13213
  onLoggedOut() {}
13203
- onSearchOptions(fieldId , query ) {}
13214
+
13215
+ onSearchOptions(fieldId , query ) {
13216
+ this.onOptionsResults(fieldId, []);
13217
+ }
13218
+
13204
13219
  onDisplayLinkedOption(optionId ) {}
13205
13220
  onWazoContactSearch(query ) {}
13206
13221
  onAgentLoggedIn() {}
@@ -13223,18 +13238,15 @@ class Softphone {
13223
13238
  onStopRecording() {}
13224
13239
  onUnHandledEvent(event ) {}
13225
13240
 
13226
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13227
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13228
- if (url) {
13229
- this.url = url;
13230
- }
13231
- if (width) {
13232
- this.width = width;
13233
- }
13234
- if (height) {
13235
- this.height = height;
13236
- }
13241
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13242
+ this.url = url || 'https://softphone.wazo.io';
13243
+ this.width = width || 500;
13244
+ this.height = height || 600;
13245
+ this.displayed = false;
13246
+ this.iframeLoaded = false;
13237
13247
 
13248
+ this.iframeLoaded = false;
13249
+ this._pendingMessages = [];
13238
13250
  window.addEventListener('message', this._onMessage.bind(this), false);
13239
13251
 
13240
13252
  if (!server) {
@@ -13242,25 +13254,26 @@ class Softphone {
13242
13254
  server = 'stack.dev.wazo.io';
13243
13255
  }
13244
13256
 
13245
- this._createIframe(() => {
13246
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13247
- config: {
13248
- server,
13249
- port,
13250
- language,
13251
- wrapUpDuration,
13252
- shouldDisplayLinkedEntities,
13253
- allowContactCreation,
13254
- },
13255
- });
13257
+ const config = { server };
13258
+ if (language) {
13259
+ config.language = language;
13260
+ }
13261
+ if (port) {
13262
+ config.port = port;
13263
+ }
13264
+ if (wrapUpDuration) {
13265
+ config.wrapUpDuration = wrapUpDuration;
13266
+ }
13256
13267
 
13257
- if (withCard) {
13258
- this._sendMessage(BRIDGE_ENABLE_CARD);
13259
- }
13268
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13260
13269
 
13261
- if (subscriptionType) {
13262
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13263
- }
13270
+ if (enableAgent) {
13271
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13272
+ }
13273
+
13274
+ this._createIframe(() => {
13275
+ this.iframeLoaded = true;
13276
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13264
13277
 
13265
13278
  this.onIFrameLoaded();
13266
13279
  });
@@ -13321,6 +13334,18 @@ class Softphone {
13321
13334
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13322
13335
  }
13323
13336
 
13337
+ setCardValue(field , value ) {
13338
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13339
+ }
13340
+
13341
+ injectCss(css ) {
13342
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13343
+ }
13344
+
13345
+ customizeAppearance(themes , translations , assets ) {
13346
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13347
+ }
13348
+
13324
13349
  _createIframe(cb = () => {}) {
13325
13350
  this.iframe = document.createElement('iframe');
13326
13351
  // $FlowFixMe
@@ -13455,6 +13480,12 @@ class Softphone {
13455
13480
  case BRIDGE_ON_STOP_RECORDING:
13456
13481
  this.onStopRecording();
13457
13482
  break;
13483
+ case BRIDGE_ON_CARD_CANCELED:
13484
+ this.onCardCanceled();
13485
+ break;
13486
+ case BRIDGE_ON_CALL_ANSWERED:
13487
+ this.onCallAnswered();
13488
+ break;
13458
13489
  default:
13459
13490
  this.onUnHandledEvent(event);
13460
13491
  break;
@@ -13462,8 +13493,8 @@ class Softphone {
13462
13493
  }
13463
13494
 
13464
13495
  _sendMessage(type , payload = {}) {
13465
- if (!this.iframe) {
13466
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13496
+ if (!this.iframe || !this.iframeLoaded) {
13497
+ this._pendingMessages.push([type, payload]);
13467
13498
  return;
13468
13499
  }
13469
13500