@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.
@@ -13844,8 +13844,6 @@ class Checker {
13844
13844
  /* eslint-disable no-unused-vars */
13845
13845
  /* global window, document */
13846
13846
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13847
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13848
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13849
13847
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13850
13848
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13851
13849
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13858,6 +13856,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13858
13856
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13859
13857
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13860
13858
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13859
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13861
13860
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13862
13861
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13863
13862
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13871,6 +13870,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13871
13870
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13872
13871
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13873
13872
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13873
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13874
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13875
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13876
+
13877
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13878
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13874
13879
 
13875
13880
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13876
13881
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13880,22 +13885,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13880
13885
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13881
13886
 
13882
13887
  class Softphone {
13883
- url = 'https://softphone.wazo.io';
13884
- width = 500;
13885
- height = 600;
13886
- displayed = false;
13887
- iframe = null;
13888
+
13889
+
13890
+
13891
+
13892
+
13893
+
13894
+
13895
+ // Message waiting for the iframe to be loaded
13896
+
13888
13897
 
13889
13898
  onLinkEnabled(link ) {}
13890
13899
  onIFrameLoaded() {}
13891
13900
 
13901
+ onCallAnswered() {}
13892
13902
  onCallMade(call ) {}
13893
13903
  onCallIncoming(call ) {}
13894
13904
  onCallEnded(call , card , direction , fromExtension ) {}
13895
13905
  onCardSaved(card ) {}
13906
+ onCardCanceled() {}
13896
13907
  onAuthenticated(session ) {}
13897
13908
  onLoggedOut() {}
13898
- onSearchOptions(fieldId , query ) {}
13909
+
13910
+ onSearchOptions(fieldId , query ) {
13911
+ this.onOptionsResults(fieldId, []);
13912
+ }
13913
+
13899
13914
  onDisplayLinkedOption(optionId ) {}
13900
13915
  onWazoContactSearch(query ) {}
13901
13916
  onAgentLoggedIn() {}
@@ -13918,18 +13933,15 @@ class Softphone {
13918
13933
  onStopRecording() {}
13919
13934
  onUnHandledEvent(event ) {}
13920
13935
 
13921
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13922
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13923
- if (url) {
13924
- this.url = url;
13925
- }
13926
- if (width) {
13927
- this.width = width;
13928
- }
13929
- if (height) {
13930
- this.height = height;
13931
- }
13936
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13937
+ this.url = url || 'https://softphone.wazo.io';
13938
+ this.width = width || 500;
13939
+ this.height = height || 600;
13940
+ this.displayed = false;
13941
+ this.iframeLoaded = false;
13932
13942
 
13943
+ this.iframeLoaded = false;
13944
+ this._pendingMessages = [];
13933
13945
  window.addEventListener('message', this._onMessage.bind(this), false);
13934
13946
 
13935
13947
  if (!server) {
@@ -13937,25 +13949,26 @@ class Softphone {
13937
13949
  server = 'stack.dev.wazo.io';
13938
13950
  }
13939
13951
 
13940
- this._createIframe(() => {
13941
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13942
- config: {
13943
- server,
13944
- port,
13945
- language,
13946
- wrapUpDuration,
13947
- shouldDisplayLinkedEntities,
13948
- allowContactCreation,
13949
- },
13950
- });
13952
+ const config = { server };
13953
+ if (language) {
13954
+ config.language = language;
13955
+ }
13956
+ if (port) {
13957
+ config.port = port;
13958
+ }
13959
+ if (wrapUpDuration) {
13960
+ config.wrapUpDuration = wrapUpDuration;
13961
+ }
13951
13962
 
13952
- if (withCard) {
13953
- this._sendMessage(BRIDGE_ENABLE_CARD);
13954
- }
13963
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13955
13964
 
13956
- if (subscriptionType) {
13957
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13958
- }
13965
+ if (enableAgent) {
13966
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13967
+ }
13968
+
13969
+ this._createIframe(() => {
13970
+ this.iframeLoaded = true;
13971
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13959
13972
 
13960
13973
  this.onIFrameLoaded();
13961
13974
  });
@@ -14016,6 +14029,18 @@ class Softphone {
14016
14029
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14017
14030
  }
14018
14031
 
14032
+ setCardValue(field , value ) {
14033
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14034
+ }
14035
+
14036
+ injectCss(css ) {
14037
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14038
+ }
14039
+
14040
+ customizeAppearance(themes , translations , assets ) {
14041
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14042
+ }
14043
+
14019
14044
  _createIframe(cb = () => {}) {
14020
14045
  this.iframe = document.createElement('iframe');
14021
14046
  // $FlowFixMe
@@ -14150,6 +14175,12 @@ class Softphone {
14150
14175
  case BRIDGE_ON_STOP_RECORDING:
14151
14176
  this.onStopRecording();
14152
14177
  break;
14178
+ case BRIDGE_ON_CARD_CANCELED:
14179
+ this.onCardCanceled();
14180
+ break;
14181
+ case BRIDGE_ON_CALL_ANSWERED:
14182
+ this.onCallAnswered();
14183
+ break;
14153
14184
  default:
14154
14185
  this.onUnHandledEvent(event);
14155
14186
  break;
@@ -14157,8 +14188,8 @@ class Softphone {
14157
14188
  }
14158
14189
 
14159
14190
  _sendMessage(type , payload = {}) {
14160
- if (!this.iframe) {
14161
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14191
+ if (!this.iframe || !this.iframeLoaded) {
14192
+ this._pendingMessages.push([type, payload]);
14162
14193
  return;
14163
14194
  }
14164
14195
 
@@ -13925,8 +13925,6 @@ class Checker {
13925
13925
  /* eslint-disable no-unused-vars */
13926
13926
  /* global window, document */
13927
13927
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13928
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13929
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13930
13928
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13931
13929
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13932
13930
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13939,6 +13937,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13939
13937
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13940
13938
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13941
13939
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13940
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13942
13941
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13943
13942
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13944
13943
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13952,6 +13951,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13952
13951
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13953
13952
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13954
13953
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13954
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13955
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13956
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13957
+
13958
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13959
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13955
13960
 
13956
13961
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13957
13962
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13961,22 +13966,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13961
13966
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13962
13967
 
13963
13968
  class Softphone {
13964
- url = 'https://softphone.wazo.io';
13965
- width = 500;
13966
- height = 600;
13967
- displayed = false;
13968
- iframe = null;
13969
+
13970
+
13971
+
13972
+
13973
+
13974
+
13975
+
13976
+ // Message waiting for the iframe to be loaded
13977
+
13969
13978
 
13970
13979
  onLinkEnabled(link ) {}
13971
13980
  onIFrameLoaded() {}
13972
13981
 
13982
+ onCallAnswered() {}
13973
13983
  onCallMade(call ) {}
13974
13984
  onCallIncoming(call ) {}
13975
13985
  onCallEnded(call , card , direction , fromExtension ) {}
13976
13986
  onCardSaved(card ) {}
13987
+ onCardCanceled() {}
13977
13988
  onAuthenticated(session ) {}
13978
13989
  onLoggedOut() {}
13979
- onSearchOptions(fieldId , query ) {}
13990
+
13991
+ onSearchOptions(fieldId , query ) {
13992
+ this.onOptionsResults(fieldId, []);
13993
+ }
13994
+
13980
13995
  onDisplayLinkedOption(optionId ) {}
13981
13996
  onWazoContactSearch(query ) {}
13982
13997
  onAgentLoggedIn() {}
@@ -13999,18 +14014,15 @@ class Softphone {
13999
14014
  onStopRecording() {}
14000
14015
  onUnHandledEvent(event ) {}
14001
14016
 
14002
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
14003
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
14004
- if (url) {
14005
- this.url = url;
14006
- }
14007
- if (width) {
14008
- this.width = width;
14009
- }
14010
- if (height) {
14011
- this.height = height;
14012
- }
14017
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14018
+ this.url = url || 'https://softphone.wazo.io';
14019
+ this.width = width || 500;
14020
+ this.height = height || 600;
14021
+ this.displayed = false;
14022
+ this.iframeLoaded = false;
14013
14023
 
14024
+ this.iframeLoaded = false;
14025
+ this._pendingMessages = [];
14014
14026
  window.addEventListener('message', this._onMessage.bind(this), false);
14015
14027
 
14016
14028
  if (!server) {
@@ -14018,25 +14030,26 @@ class Softphone {
14018
14030
  server = 'stack.dev.wazo.io';
14019
14031
  }
14020
14032
 
14021
- this._createIframe(() => {
14022
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
14023
- config: {
14024
- server,
14025
- port,
14026
- language,
14027
- wrapUpDuration,
14028
- shouldDisplayLinkedEntities,
14029
- allowContactCreation,
14030
- },
14031
- });
14033
+ const config = { server };
14034
+ if (language) {
14035
+ config.language = language;
14036
+ }
14037
+ if (port) {
14038
+ config.port = port;
14039
+ }
14040
+ if (wrapUpDuration) {
14041
+ config.wrapUpDuration = wrapUpDuration;
14042
+ }
14032
14043
 
14033
- if (withCard) {
14034
- this._sendMessage(BRIDGE_ENABLE_CARD);
14035
- }
14044
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
14036
14045
 
14037
- if (subscriptionType) {
14038
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
14039
- }
14046
+ if (enableAgent) {
14047
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
14048
+ }
14049
+
14050
+ this._createIframe(() => {
14051
+ this.iframeLoaded = true;
14052
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
14040
14053
 
14041
14054
  this.onIFrameLoaded();
14042
14055
  });
@@ -14097,6 +14110,18 @@ class Softphone {
14097
14110
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14098
14111
  }
14099
14112
 
14113
+ setCardValue(field , value ) {
14114
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14115
+ }
14116
+
14117
+ injectCss(css ) {
14118
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14119
+ }
14120
+
14121
+ customizeAppearance(themes , translations , assets ) {
14122
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14123
+ }
14124
+
14100
14125
  _createIframe(cb = () => {}) {
14101
14126
  this.iframe = document.createElement('iframe');
14102
14127
  // $FlowFixMe
@@ -14231,6 +14256,12 @@ class Softphone {
14231
14256
  case BRIDGE_ON_STOP_RECORDING:
14232
14257
  this.onStopRecording();
14233
14258
  break;
14259
+ case BRIDGE_ON_CARD_CANCELED:
14260
+ this.onCardCanceled();
14261
+ break;
14262
+ case BRIDGE_ON_CALL_ANSWERED:
14263
+ this.onCallAnswered();
14264
+ break;
14234
14265
  default:
14235
14266
  this.onUnHandledEvent(event);
14236
14267
  break;
@@ -14238,8 +14269,8 @@ class Softphone {
14238
14269
  }
14239
14270
 
14240
14271
  _sendMessage(type , payload = {}) {
14241
- if (!this.iframe) {
14242
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14272
+ if (!this.iframe || !this.iframeLoaded) {
14273
+ this._pendingMessages.push([type, payload]);
14243
14274
  return;
14244
14275
  }
14245
14276
 
@@ -13983,8 +13983,6 @@ class Checker {
13983
13983
  /* eslint-disable no-unused-vars */
13984
13984
  /* global window, document */
13985
13985
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13986
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13987
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13988
13986
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13989
13987
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13990
13988
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13997,6 +13995,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13997
13995
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13998
13996
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13999
13997
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13998
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
14000
13999
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14001
14000
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14002
14001
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14010,6 +14009,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
14010
14009
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
14011
14010
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
14012
14011
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14012
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
14013
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14014
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14015
+
14016
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14017
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14013
14018
 
14014
14019
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14015
14020
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -14019,22 +14024,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
14019
14024
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
14020
14025
 
14021
14026
  class Softphone {
14022
- url = 'https://softphone.wazo.io';
14023
- width = 500;
14024
- height = 600;
14025
- displayed = false;
14026
- iframe = null;
14027
+
14028
+
14029
+
14030
+
14031
+
14032
+
14033
+
14034
+ // Message waiting for the iframe to be loaded
14035
+
14027
14036
 
14028
14037
  onLinkEnabled(link ) {}
14029
14038
  onIFrameLoaded() {}
14030
14039
 
14040
+ onCallAnswered() {}
14031
14041
  onCallMade(call ) {}
14032
14042
  onCallIncoming(call ) {}
14033
14043
  onCallEnded(call , card , direction , fromExtension ) {}
14034
14044
  onCardSaved(card ) {}
14045
+ onCardCanceled() {}
14035
14046
  onAuthenticated(session ) {}
14036
14047
  onLoggedOut() {}
14037
- onSearchOptions(fieldId , query ) {}
14048
+
14049
+ onSearchOptions(fieldId , query ) {
14050
+ this.onOptionsResults(fieldId, []);
14051
+ }
14052
+
14038
14053
  onDisplayLinkedOption(optionId ) {}
14039
14054
  onWazoContactSearch(query ) {}
14040
14055
  onAgentLoggedIn() {}
@@ -14057,18 +14072,15 @@ class Softphone {
14057
14072
  onStopRecording() {}
14058
14073
  onUnHandledEvent(event ) {}
14059
14074
 
14060
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
14061
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
14062
- if (url) {
14063
- this.url = url;
14064
- }
14065
- if (width) {
14066
- this.width = width;
14067
- }
14068
- if (height) {
14069
- this.height = height;
14070
- }
14075
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14076
+ this.url = url || 'https://softphone.wazo.io';
14077
+ this.width = width || 500;
14078
+ this.height = height || 600;
14079
+ this.displayed = false;
14080
+ this.iframeLoaded = false;
14071
14081
 
14082
+ this.iframeLoaded = false;
14083
+ this._pendingMessages = [];
14072
14084
  window.addEventListener('message', this._onMessage.bind(this), false);
14073
14085
 
14074
14086
  if (!server) {
@@ -14076,25 +14088,26 @@ class Softphone {
14076
14088
  server = 'stack.dev.wazo.io';
14077
14089
  }
14078
14090
 
14079
- this._createIframe(() => {
14080
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
14081
- config: {
14082
- server,
14083
- port,
14084
- language,
14085
- wrapUpDuration,
14086
- shouldDisplayLinkedEntities,
14087
- allowContactCreation,
14088
- },
14089
- });
14091
+ const config = { server };
14092
+ if (language) {
14093
+ config.language = language;
14094
+ }
14095
+ if (port) {
14096
+ config.port = port;
14097
+ }
14098
+ if (wrapUpDuration) {
14099
+ config.wrapUpDuration = wrapUpDuration;
14100
+ }
14090
14101
 
14091
- if (withCard) {
14092
- this._sendMessage(BRIDGE_ENABLE_CARD);
14093
- }
14102
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
14094
14103
 
14095
- if (subscriptionType) {
14096
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
14097
- }
14104
+ if (enableAgent) {
14105
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
14106
+ }
14107
+
14108
+ this._createIframe(() => {
14109
+ this.iframeLoaded = true;
14110
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
14098
14111
 
14099
14112
  this.onIFrameLoaded();
14100
14113
  });
@@ -14155,6 +14168,18 @@ class Softphone {
14155
14168
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14156
14169
  }
14157
14170
 
14171
+ setCardValue(field , value ) {
14172
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14173
+ }
14174
+
14175
+ injectCss(css ) {
14176
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14177
+ }
14178
+
14179
+ customizeAppearance(themes , translations , assets ) {
14180
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14181
+ }
14182
+
14158
14183
  _createIframe(cb = () => {}) {
14159
14184
  this.iframe = document.createElement('iframe');
14160
14185
  // $FlowFixMe
@@ -14289,6 +14314,12 @@ class Softphone {
14289
14314
  case BRIDGE_ON_STOP_RECORDING:
14290
14315
  this.onStopRecording();
14291
14316
  break;
14317
+ case BRIDGE_ON_CARD_CANCELED:
14318
+ this.onCardCanceled();
14319
+ break;
14320
+ case BRIDGE_ON_CALL_ANSWERED:
14321
+ this.onCallAnswered();
14322
+ break;
14292
14323
  default:
14293
14324
  this.onUnHandledEvent(event);
14294
14325
  break;
@@ -14296,8 +14327,8 @@ class Softphone {
14296
14327
  }
14297
14328
 
14298
14329
  _sendMessage(type , payload = {}) {
14299
- if (!this.iframe) {
14300
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14330
+ if (!this.iframe || !this.iframeLoaded) {
14331
+ this._pendingMessages.push([type, payload]);
14301
14332
  return;
14302
14333
  }
14303
14334