@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.
@@ -12842,8 +12842,6 @@ class Checker {
12842
12842
  /* eslint-disable no-unused-vars */
12843
12843
  /* global window, document */
12844
12844
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
12845
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
12846
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
12847
12845
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
12848
12846
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
12849
12847
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -12856,6 +12854,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
12856
12854
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
12857
12855
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12858
12856
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12857
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
12859
12858
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12860
12859
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12861
12860
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12869,6 +12868,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
12869
12868
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
12870
12869
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
12871
12870
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
12871
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
12872
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
12873
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
12874
+
12875
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
12876
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
12872
12877
 
12873
12878
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
12874
12879
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -12878,22 +12883,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
12878
12883
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
12879
12884
 
12880
12885
  class Softphone {
12881
- url = 'https://softphone.wazo.io';
12882
- width = 500;
12883
- height = 600;
12884
- displayed = false;
12885
- iframe = null;
12886
+
12887
+
12888
+
12889
+
12890
+
12891
+
12892
+
12893
+ // Message waiting for the iframe to be loaded
12894
+
12886
12895
 
12887
12896
  onLinkEnabled(link ) {}
12888
12897
  onIFrameLoaded() {}
12889
12898
 
12899
+ onCallAnswered() {}
12890
12900
  onCallMade(call ) {}
12891
12901
  onCallIncoming(call ) {}
12892
12902
  onCallEnded(call , card , direction , fromExtension ) {}
12893
12903
  onCardSaved(card ) {}
12904
+ onCardCanceled() {}
12894
12905
  onAuthenticated(session ) {}
12895
12906
  onLoggedOut() {}
12896
- onSearchOptions(fieldId , query ) {}
12907
+
12908
+ onSearchOptions(fieldId , query ) {
12909
+ this.onOptionsResults(fieldId, []);
12910
+ }
12911
+
12897
12912
  onDisplayLinkedOption(optionId ) {}
12898
12913
  onWazoContactSearch(query ) {}
12899
12914
  onAgentLoggedIn() {}
@@ -12916,18 +12931,15 @@ class Softphone {
12916
12931
  onStopRecording() {}
12917
12932
  onUnHandledEvent(event ) {}
12918
12933
 
12919
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
12920
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
12921
- if (url) {
12922
- this.url = url;
12923
- }
12924
- if (width) {
12925
- this.width = width;
12926
- }
12927
- if (height) {
12928
- this.height = height;
12929
- }
12934
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
12935
+ this.url = url || 'https://softphone.wazo.io';
12936
+ this.width = width || 500;
12937
+ this.height = height || 600;
12938
+ this.displayed = false;
12939
+ this.iframeLoaded = false;
12930
12940
 
12941
+ this.iframeLoaded = false;
12942
+ this._pendingMessages = [];
12931
12943
  window.addEventListener('message', this._onMessage.bind(this), false);
12932
12944
 
12933
12945
  if (!server) {
@@ -12935,25 +12947,26 @@ class Softphone {
12935
12947
  server = 'stack.dev.wazo.io';
12936
12948
  }
12937
12949
 
12938
- this._createIframe(() => {
12939
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
12940
- config: {
12941
- server,
12942
- port,
12943
- language,
12944
- wrapUpDuration,
12945
- shouldDisplayLinkedEntities,
12946
- allowContactCreation,
12947
- },
12948
- });
12950
+ const config = { server };
12951
+ if (language) {
12952
+ config.language = language;
12953
+ }
12954
+ if (port) {
12955
+ config.port = port;
12956
+ }
12957
+ if (wrapUpDuration) {
12958
+ config.wrapUpDuration = wrapUpDuration;
12959
+ }
12949
12960
 
12950
- if (withCard) {
12951
- this._sendMessage(BRIDGE_ENABLE_CARD);
12952
- }
12961
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
12953
12962
 
12954
- if (subscriptionType) {
12955
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
12956
- }
12963
+ if (enableAgent) {
12964
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
12965
+ }
12966
+
12967
+ this._createIframe(() => {
12968
+ this.iframeLoaded = true;
12969
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
12957
12970
 
12958
12971
  this.onIFrameLoaded();
12959
12972
  });
@@ -13014,6 +13027,18 @@ class Softphone {
13014
13027
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13015
13028
  }
13016
13029
 
13030
+ setCardValue(field , value ) {
13031
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13032
+ }
13033
+
13034
+ injectCss(css ) {
13035
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13036
+ }
13037
+
13038
+ customizeAppearance(themes , translations , assets ) {
13039
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13040
+ }
13041
+
13017
13042
  _createIframe(cb = () => {}) {
13018
13043
  this.iframe = document.createElement('iframe');
13019
13044
  // $FlowFixMe
@@ -13148,6 +13173,12 @@ class Softphone {
13148
13173
  case BRIDGE_ON_STOP_RECORDING:
13149
13174
  this.onStopRecording();
13150
13175
  break;
13176
+ case BRIDGE_ON_CARD_CANCELED:
13177
+ this.onCardCanceled();
13178
+ break;
13179
+ case BRIDGE_ON_CALL_ANSWERED:
13180
+ this.onCallAnswered();
13181
+ break;
13151
13182
  default:
13152
13183
  this.onUnHandledEvent(event);
13153
13184
  break;
@@ -13155,8 +13186,8 @@ class Softphone {
13155
13186
  }
13156
13187
 
13157
13188
  _sendMessage(type , payload = {}) {
13158
- if (!this.iframe) {
13159
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13189
+ if (!this.iframe || !this.iframeLoaded) {
13190
+ this._pendingMessages.push([type, payload]);
13160
13191
  return;
13161
13192
  }
13162
13193
 
@@ -12847,8 +12847,6 @@ class Checker {
12847
12847
  /* eslint-disable no-unused-vars */
12848
12848
  /* global window, document */
12849
12849
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
12850
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
12851
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
12852
12850
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
12853
12851
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
12854
12852
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -12861,6 +12859,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
12861
12859
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
12862
12860
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12863
12861
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12862
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
12864
12863
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12865
12864
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12866
12865
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -12874,6 +12873,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
12874
12873
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
12875
12874
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
12876
12875
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
12876
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
12877
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
12878
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
12879
+
12880
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
12881
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
12877
12882
 
12878
12883
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
12879
12884
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -12883,22 +12888,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
12883
12888
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
12884
12889
 
12885
12890
  class Softphone {
12886
- url = 'https://softphone.wazo.io';
12887
- width = 500;
12888
- height = 600;
12889
- displayed = false;
12890
- iframe = null;
12891
+
12892
+
12893
+
12894
+
12895
+
12896
+
12897
+
12898
+ // Message waiting for the iframe to be loaded
12899
+
12891
12900
 
12892
12901
  onLinkEnabled(link ) {}
12893
12902
  onIFrameLoaded() {}
12894
12903
 
12904
+ onCallAnswered() {}
12895
12905
  onCallMade(call ) {}
12896
12906
  onCallIncoming(call ) {}
12897
12907
  onCallEnded(call , card , direction , fromExtension ) {}
12898
12908
  onCardSaved(card ) {}
12909
+ onCardCanceled() {}
12899
12910
  onAuthenticated(session ) {}
12900
12911
  onLoggedOut() {}
12901
- onSearchOptions(fieldId , query ) {}
12912
+
12913
+ onSearchOptions(fieldId , query ) {
12914
+ this.onOptionsResults(fieldId, []);
12915
+ }
12916
+
12902
12917
  onDisplayLinkedOption(optionId ) {}
12903
12918
  onWazoContactSearch(query ) {}
12904
12919
  onAgentLoggedIn() {}
@@ -12921,18 +12936,15 @@ class Softphone {
12921
12936
  onStopRecording() {}
12922
12937
  onUnHandledEvent(event ) {}
12923
12938
 
12924
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
12925
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
12926
- if (url) {
12927
- this.url = url;
12928
- }
12929
- if (width) {
12930
- this.width = width;
12931
- }
12932
- if (height) {
12933
- this.height = height;
12934
- }
12939
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
12940
+ this.url = url || 'https://softphone.wazo.io';
12941
+ this.width = width || 500;
12942
+ this.height = height || 600;
12943
+ this.displayed = false;
12944
+ this.iframeLoaded = false;
12935
12945
 
12946
+ this.iframeLoaded = false;
12947
+ this._pendingMessages = [];
12936
12948
  window.addEventListener('message', this._onMessage.bind(this), false);
12937
12949
 
12938
12950
  if (!server) {
@@ -12940,25 +12952,26 @@ class Softphone {
12940
12952
  server = 'stack.dev.wazo.io';
12941
12953
  }
12942
12954
 
12943
- this._createIframe(() => {
12944
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
12945
- config: {
12946
- server,
12947
- port,
12948
- language,
12949
- wrapUpDuration,
12950
- shouldDisplayLinkedEntities,
12951
- allowContactCreation,
12952
- },
12953
- });
12955
+ const config = { server };
12956
+ if (language) {
12957
+ config.language = language;
12958
+ }
12959
+ if (port) {
12960
+ config.port = port;
12961
+ }
12962
+ if (wrapUpDuration) {
12963
+ config.wrapUpDuration = wrapUpDuration;
12964
+ }
12954
12965
 
12955
- if (withCard) {
12956
- this._sendMessage(BRIDGE_ENABLE_CARD);
12957
- }
12966
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
12958
12967
 
12959
- if (subscriptionType) {
12960
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
12961
- }
12968
+ if (enableAgent) {
12969
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
12970
+ }
12971
+
12972
+ this._createIframe(() => {
12973
+ this.iframeLoaded = true;
12974
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
12962
12975
 
12963
12976
  this.onIFrameLoaded();
12964
12977
  });
@@ -13019,6 +13032,18 @@ class Softphone {
13019
13032
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13020
13033
  }
13021
13034
 
13035
+ setCardValue(field , value ) {
13036
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13037
+ }
13038
+
13039
+ injectCss(css ) {
13040
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13041
+ }
13042
+
13043
+ customizeAppearance(themes , translations , assets ) {
13044
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13045
+ }
13046
+
13022
13047
  _createIframe(cb = () => {}) {
13023
13048
  this.iframe = document.createElement('iframe');
13024
13049
  // $FlowFixMe
@@ -13153,6 +13178,12 @@ class Softphone {
13153
13178
  case BRIDGE_ON_STOP_RECORDING:
13154
13179
  this.onStopRecording();
13155
13180
  break;
13181
+ case BRIDGE_ON_CARD_CANCELED:
13182
+ this.onCardCanceled();
13183
+ break;
13184
+ case BRIDGE_ON_CALL_ANSWERED:
13185
+ this.onCallAnswered();
13186
+ break;
13156
13187
  default:
13157
13188
  this.onUnHandledEvent(event);
13158
13189
  break;
@@ -13160,8 +13191,8 @@ class Softphone {
13160
13191
  }
13161
13192
 
13162
13193
  _sendMessage(type , payload = {}) {
13163
- if (!this.iframe) {
13164
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13194
+ if (!this.iframe || !this.iframeLoaded) {
13195
+ this._pendingMessages.push([type, payload]);
13165
13196
  return;
13166
13197
  }
13167
13198
 
@@ -13126,8 +13126,6 @@ class Checker {
13126
13126
  /* eslint-disable no-unused-vars */
13127
13127
  /* global window, document */
13128
13128
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13129
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13130
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13131
13129
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13132
13130
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13133
13131
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13140,6 +13138,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13140
13138
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13141
13139
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13142
13140
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13141
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13143
13142
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13144
13143
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13145
13144
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13153,6 +13152,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13153
13152
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13154
13153
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13155
13154
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13155
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13156
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13157
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13158
+
13159
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13160
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13156
13161
 
13157
13162
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13158
13163
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13162,22 +13167,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13162
13167
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13163
13168
 
13164
13169
  class Softphone {
13165
- url = 'https://softphone.wazo.io';
13166
- width = 500;
13167
- height = 600;
13168
- displayed = false;
13169
- iframe = null;
13170
+
13171
+
13172
+
13173
+
13174
+
13175
+
13176
+
13177
+ // Message waiting for the iframe to be loaded
13178
+
13170
13179
 
13171
13180
  onLinkEnabled(link ) {}
13172
13181
  onIFrameLoaded() {}
13173
13182
 
13183
+ onCallAnswered() {}
13174
13184
  onCallMade(call ) {}
13175
13185
  onCallIncoming(call ) {}
13176
13186
  onCallEnded(call , card , direction , fromExtension ) {}
13177
13187
  onCardSaved(card ) {}
13188
+ onCardCanceled() {}
13178
13189
  onAuthenticated(session ) {}
13179
13190
  onLoggedOut() {}
13180
- onSearchOptions(fieldId , query ) {}
13191
+
13192
+ onSearchOptions(fieldId , query ) {
13193
+ this.onOptionsResults(fieldId, []);
13194
+ }
13195
+
13181
13196
  onDisplayLinkedOption(optionId ) {}
13182
13197
  onWazoContactSearch(query ) {}
13183
13198
  onAgentLoggedIn() {}
@@ -13200,18 +13215,15 @@ class Softphone {
13200
13215
  onStopRecording() {}
13201
13216
  onUnHandledEvent(event ) {}
13202
13217
 
13203
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13204
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13205
- if (url) {
13206
- this.url = url;
13207
- }
13208
- if (width) {
13209
- this.width = width;
13210
- }
13211
- if (height) {
13212
- this.height = height;
13213
- }
13218
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13219
+ this.url = url || 'https://softphone.wazo.io';
13220
+ this.width = width || 500;
13221
+ this.height = height || 600;
13222
+ this.displayed = false;
13223
+ this.iframeLoaded = false;
13214
13224
 
13225
+ this.iframeLoaded = false;
13226
+ this._pendingMessages = [];
13215
13227
  window.addEventListener('message', this._onMessage.bind(this), false);
13216
13228
 
13217
13229
  if (!server) {
@@ -13219,25 +13231,26 @@ class Softphone {
13219
13231
  server = 'stack.dev.wazo.io';
13220
13232
  }
13221
13233
 
13222
- this._createIframe(() => {
13223
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13224
- config: {
13225
- server,
13226
- port,
13227
- language,
13228
- wrapUpDuration,
13229
- shouldDisplayLinkedEntities,
13230
- allowContactCreation,
13231
- },
13232
- });
13234
+ const config = { server };
13235
+ if (language) {
13236
+ config.language = language;
13237
+ }
13238
+ if (port) {
13239
+ config.port = port;
13240
+ }
13241
+ if (wrapUpDuration) {
13242
+ config.wrapUpDuration = wrapUpDuration;
13243
+ }
13233
13244
 
13234
- if (withCard) {
13235
- this._sendMessage(BRIDGE_ENABLE_CARD);
13236
- }
13245
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13237
13246
 
13238
- if (subscriptionType) {
13239
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13240
- }
13247
+ if (enableAgent) {
13248
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13249
+ }
13250
+
13251
+ this._createIframe(() => {
13252
+ this.iframeLoaded = true;
13253
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13241
13254
 
13242
13255
  this.onIFrameLoaded();
13243
13256
  });
@@ -13298,6 +13311,18 @@ class Softphone {
13298
13311
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13299
13312
  }
13300
13313
 
13314
+ setCardValue(field , value ) {
13315
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13316
+ }
13317
+
13318
+ injectCss(css ) {
13319
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13320
+ }
13321
+
13322
+ customizeAppearance(themes , translations , assets ) {
13323
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13324
+ }
13325
+
13301
13326
  _createIframe(cb = () => {}) {
13302
13327
  this.iframe = document.createElement('iframe');
13303
13328
  // $FlowFixMe
@@ -13432,6 +13457,12 @@ class Softphone {
13432
13457
  case BRIDGE_ON_STOP_RECORDING:
13433
13458
  this.onStopRecording();
13434
13459
  break;
13460
+ case BRIDGE_ON_CARD_CANCELED:
13461
+ this.onCardCanceled();
13462
+ break;
13463
+ case BRIDGE_ON_CALL_ANSWERED:
13464
+ this.onCallAnswered();
13465
+ break;
13435
13466
  default:
13436
13467
  this.onUnHandledEvent(event);
13437
13468
  break;
@@ -13439,8 +13470,8 @@ class Softphone {
13439
13470
  }
13440
13471
 
13441
13472
  _sendMessage(type , payload = {}) {
13442
- if (!this.iframe) {
13443
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13473
+ if (!this.iframe || !this.iframeLoaded) {
13474
+ this._pendingMessages.push([type, payload]);
13444
13475
  return;
13445
13476
  }
13446
13477