@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.
@@ -13684,8 +13684,6 @@ class Checker {
13684
13684
  /* eslint-disable no-unused-vars */
13685
13685
  /* global window, document */
13686
13686
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13687
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13688
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13689
13687
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13690
13688
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13691
13689
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13698,6 +13696,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13698
13696
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13699
13697
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13700
13698
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13699
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13701
13700
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13702
13701
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13703
13702
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13711,6 +13710,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13711
13710
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13712
13711
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13713
13712
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13713
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13714
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13715
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13716
+
13717
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13718
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13714
13719
 
13715
13720
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13716
13721
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13720,22 +13725,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13720
13725
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13721
13726
 
13722
13727
  class Softphone {
13723
- url = 'https://softphone.wazo.io';
13724
- width = 500;
13725
- height = 600;
13726
- displayed = false;
13727
- iframe = null;
13728
+
13729
+
13730
+
13731
+
13732
+
13733
+
13734
+
13735
+ // Message waiting for the iframe to be loaded
13736
+
13728
13737
 
13729
13738
  onLinkEnabled(link ) {}
13730
13739
  onIFrameLoaded() {}
13731
13740
 
13741
+ onCallAnswered() {}
13732
13742
  onCallMade(call ) {}
13733
13743
  onCallIncoming(call ) {}
13734
13744
  onCallEnded(call , card , direction , fromExtension ) {}
13735
13745
  onCardSaved(card ) {}
13746
+ onCardCanceled() {}
13736
13747
  onAuthenticated(session ) {}
13737
13748
  onLoggedOut() {}
13738
- onSearchOptions(fieldId , query ) {}
13749
+
13750
+ onSearchOptions(fieldId , query ) {
13751
+ this.onOptionsResults(fieldId, []);
13752
+ }
13753
+
13739
13754
  onDisplayLinkedOption(optionId ) {}
13740
13755
  onWazoContactSearch(query ) {}
13741
13756
  onAgentLoggedIn() {}
@@ -13758,18 +13773,15 @@ class Softphone {
13758
13773
  onStopRecording() {}
13759
13774
  onUnHandledEvent(event ) {}
13760
13775
 
13761
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13762
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13763
- if (url) {
13764
- this.url = url;
13765
- }
13766
- if (width) {
13767
- this.width = width;
13768
- }
13769
- if (height) {
13770
- this.height = height;
13771
- }
13776
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13777
+ this.url = url || 'https://softphone.wazo.io';
13778
+ this.width = width || 500;
13779
+ this.height = height || 600;
13780
+ this.displayed = false;
13781
+ this.iframeLoaded = false;
13772
13782
 
13783
+ this.iframeLoaded = false;
13784
+ this._pendingMessages = [];
13773
13785
  window.addEventListener('message', this._onMessage.bind(this), false);
13774
13786
 
13775
13787
  if (!server) {
@@ -13777,25 +13789,26 @@ class Softphone {
13777
13789
  server = 'stack.dev.wazo.io';
13778
13790
  }
13779
13791
 
13780
- this._createIframe(() => {
13781
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13782
- config: {
13783
- server,
13784
- port,
13785
- language,
13786
- wrapUpDuration,
13787
- shouldDisplayLinkedEntities,
13788
- allowContactCreation,
13789
- },
13790
- });
13792
+ const config = { server };
13793
+ if (language) {
13794
+ config.language = language;
13795
+ }
13796
+ if (port) {
13797
+ config.port = port;
13798
+ }
13799
+ if (wrapUpDuration) {
13800
+ config.wrapUpDuration = wrapUpDuration;
13801
+ }
13791
13802
 
13792
- if (withCard) {
13793
- this._sendMessage(BRIDGE_ENABLE_CARD);
13794
- }
13803
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13795
13804
 
13796
- if (subscriptionType) {
13797
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13798
- }
13805
+ if (enableAgent) {
13806
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13807
+ }
13808
+
13809
+ this._createIframe(() => {
13810
+ this.iframeLoaded = true;
13811
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13799
13812
 
13800
13813
  this.onIFrameLoaded();
13801
13814
  });
@@ -13856,6 +13869,18 @@ class Softphone {
13856
13869
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13857
13870
  }
13858
13871
 
13872
+ setCardValue(field , value ) {
13873
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13874
+ }
13875
+
13876
+ injectCss(css ) {
13877
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13878
+ }
13879
+
13880
+ customizeAppearance(themes , translations , assets ) {
13881
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13882
+ }
13883
+
13859
13884
  _createIframe(cb = () => {}) {
13860
13885
  this.iframe = document.createElement('iframe');
13861
13886
  // $FlowFixMe
@@ -13990,6 +14015,12 @@ class Softphone {
13990
14015
  case BRIDGE_ON_STOP_RECORDING:
13991
14016
  this.onStopRecording();
13992
14017
  break;
14018
+ case BRIDGE_ON_CARD_CANCELED:
14019
+ this.onCardCanceled();
14020
+ break;
14021
+ case BRIDGE_ON_CALL_ANSWERED:
14022
+ this.onCallAnswered();
14023
+ break;
13993
14024
  default:
13994
14025
  this.onUnHandledEvent(event);
13995
14026
  break;
@@ -13997,8 +14028,8 @@ class Softphone {
13997
14028
  }
13998
14029
 
13999
14030
  _sendMessage(type , payload = {}) {
14000
- if (!this.iframe) {
14001
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14031
+ if (!this.iframe || !this.iframeLoaded) {
14032
+ this._pendingMessages.push([type, payload]);
14002
14033
  return;
14003
14034
  }
14004
14035
 
@@ -13665,8 +13665,6 @@ class Checker {
13665
13665
  /* eslint-disable no-unused-vars */
13666
13666
  /* global window, document */
13667
13667
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13668
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13669
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13670
13668
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13671
13669
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13672
13670
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13679,6 +13677,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13679
13677
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13680
13678
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13681
13679
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13680
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13682
13681
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13683
13682
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13684
13683
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13692,6 +13691,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13692
13691
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13693
13692
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13694
13693
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13694
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13695
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13696
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13697
+
13698
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13699
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13695
13700
 
13696
13701
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13697
13702
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13701,22 +13706,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13701
13706
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13702
13707
 
13703
13708
  class Softphone {
13704
- url = 'https://softphone.wazo.io';
13705
- width = 500;
13706
- height = 600;
13707
- displayed = false;
13708
- iframe = null;
13709
+
13710
+
13711
+
13712
+
13713
+
13714
+
13715
+
13716
+ // Message waiting for the iframe to be loaded
13717
+
13709
13718
 
13710
13719
  onLinkEnabled(link ) {}
13711
13720
  onIFrameLoaded() {}
13712
13721
 
13722
+ onCallAnswered() {}
13713
13723
  onCallMade(call ) {}
13714
13724
  onCallIncoming(call ) {}
13715
13725
  onCallEnded(call , card , direction , fromExtension ) {}
13716
13726
  onCardSaved(card ) {}
13727
+ onCardCanceled() {}
13717
13728
  onAuthenticated(session ) {}
13718
13729
  onLoggedOut() {}
13719
- onSearchOptions(fieldId , query ) {}
13730
+
13731
+ onSearchOptions(fieldId , query ) {
13732
+ this.onOptionsResults(fieldId, []);
13733
+ }
13734
+
13720
13735
  onDisplayLinkedOption(optionId ) {}
13721
13736
  onWazoContactSearch(query ) {}
13722
13737
  onAgentLoggedIn() {}
@@ -13739,18 +13754,15 @@ class Softphone {
13739
13754
  onStopRecording() {}
13740
13755
  onUnHandledEvent(event ) {}
13741
13756
 
13742
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13743
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13744
- if (url) {
13745
- this.url = url;
13746
- }
13747
- if (width) {
13748
- this.width = width;
13749
- }
13750
- if (height) {
13751
- this.height = height;
13752
- }
13757
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13758
+ this.url = url || 'https://softphone.wazo.io';
13759
+ this.width = width || 500;
13760
+ this.height = height || 600;
13761
+ this.displayed = false;
13762
+ this.iframeLoaded = false;
13753
13763
 
13764
+ this.iframeLoaded = false;
13765
+ this._pendingMessages = [];
13754
13766
  window.addEventListener('message', this._onMessage.bind(this), false);
13755
13767
 
13756
13768
  if (!server) {
@@ -13758,25 +13770,26 @@ class Softphone {
13758
13770
  server = 'stack.dev.wazo.io';
13759
13771
  }
13760
13772
 
13761
- this._createIframe(() => {
13762
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13763
- config: {
13764
- server,
13765
- port,
13766
- language,
13767
- wrapUpDuration,
13768
- shouldDisplayLinkedEntities,
13769
- allowContactCreation,
13770
- },
13771
- });
13773
+ const config = { server };
13774
+ if (language) {
13775
+ config.language = language;
13776
+ }
13777
+ if (port) {
13778
+ config.port = port;
13779
+ }
13780
+ if (wrapUpDuration) {
13781
+ config.wrapUpDuration = wrapUpDuration;
13782
+ }
13772
13783
 
13773
- if (withCard) {
13774
- this._sendMessage(BRIDGE_ENABLE_CARD);
13775
- }
13784
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13776
13785
 
13777
- if (subscriptionType) {
13778
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13779
- }
13786
+ if (enableAgent) {
13787
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13788
+ }
13789
+
13790
+ this._createIframe(() => {
13791
+ this.iframeLoaded = true;
13792
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13780
13793
 
13781
13794
  this.onIFrameLoaded();
13782
13795
  });
@@ -13837,6 +13850,18 @@ class Softphone {
13837
13850
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13838
13851
  }
13839
13852
 
13853
+ setCardValue(field , value ) {
13854
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13855
+ }
13856
+
13857
+ injectCss(css ) {
13858
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13859
+ }
13860
+
13861
+ customizeAppearance(themes , translations , assets ) {
13862
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13863
+ }
13864
+
13840
13865
  _createIframe(cb = () => {}) {
13841
13866
  this.iframe = document.createElement('iframe');
13842
13867
  // $FlowFixMe
@@ -13971,6 +13996,12 @@ class Softphone {
13971
13996
  case BRIDGE_ON_STOP_RECORDING:
13972
13997
  this.onStopRecording();
13973
13998
  break;
13999
+ case BRIDGE_ON_CARD_CANCELED:
14000
+ this.onCardCanceled();
14001
+ break;
14002
+ case BRIDGE_ON_CALL_ANSWERED:
14003
+ this.onCallAnswered();
14004
+ break;
13974
14005
  default:
13975
14006
  this.onUnHandledEvent(event);
13976
14007
  break;
@@ -13978,8 +14009,8 @@ class Softphone {
13978
14009
  }
13979
14010
 
13980
14011
  _sendMessage(type , payload = {}) {
13981
- if (!this.iframe) {
13982
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
14012
+ if (!this.iframe || !this.iframeLoaded) {
14013
+ this._pendingMessages.push([type, payload]);
13983
14014
  return;
13984
14015
  }
13985
14016
 
@@ -13573,8 +13573,6 @@ class Checker {
13573
13573
  /* eslint-disable no-unused-vars */
13574
13574
  /* global window, document */
13575
13575
  const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13576
- const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
13577
- const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
13578
13576
  const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13579
13577
  const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13580
13578
  const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
@@ -13587,6 +13585,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13587
13585
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13588
13586
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13589
13587
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13588
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13590
13589
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13591
13590
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13592
13591
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13600,6 +13599,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
13600
13599
  const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13601
13600
  const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13602
13601
  const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13602
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13603
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13604
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13605
+
13606
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13607
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13603
13608
 
13604
13609
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13605
13610
  const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
@@ -13609,22 +13614,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13609
13614
  const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13610
13615
 
13611
13616
  class Softphone {
13612
- url = 'https://softphone.wazo.io';
13613
- width = 500;
13614
- height = 600;
13615
- displayed = false;
13616
- iframe = null;
13617
+
13618
+
13619
+
13620
+
13621
+
13622
+
13623
+
13624
+ // Message waiting for the iframe to be loaded
13625
+
13617
13626
 
13618
13627
  onLinkEnabled(link ) {}
13619
13628
  onIFrameLoaded() {}
13620
13629
 
13630
+ onCallAnswered() {}
13621
13631
  onCallMade(call ) {}
13622
13632
  onCallIncoming(call ) {}
13623
13633
  onCallEnded(call , card , direction , fromExtension ) {}
13624
13634
  onCardSaved(card ) {}
13635
+ onCardCanceled() {}
13625
13636
  onAuthenticated(session ) {}
13626
13637
  onLoggedOut() {}
13627
- onSearchOptions(fieldId , query ) {}
13638
+
13639
+ onSearchOptions(fieldId , query ) {
13640
+ this.onOptionsResults(fieldId, []);
13641
+ }
13642
+
13628
13643
  onDisplayLinkedOption(optionId ) {}
13629
13644
  onWazoContactSearch(query ) {}
13630
13645
  onAgentLoggedIn() {}
@@ -13647,18 +13662,15 @@ class Softphone {
13647
13662
  onStopRecording() {}
13648
13663
  onUnHandledEvent(event ) {}
13649
13664
 
13650
- init({ url, width, height, server, port, language, wrapUpDuration, shouldDisplayLinkedEntities,
13651
- allowContactCreation, withCard, subscriptionType, enableAgent } = {}) {
13652
- if (url) {
13653
- this.url = url;
13654
- }
13655
- if (width) {
13656
- this.width = width;
13657
- }
13658
- if (height) {
13659
- this.height = height;
13660
- }
13665
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13666
+ this.url = url || 'https://softphone.wazo.io';
13667
+ this.width = width || 500;
13668
+ this.height = height || 600;
13669
+ this.displayed = false;
13670
+ this.iframeLoaded = false;
13661
13671
 
13672
+ this.iframeLoaded = false;
13673
+ this._pendingMessages = [];
13662
13674
  window.addEventListener('message', this._onMessage.bind(this), false);
13663
13675
 
13664
13676
  if (!server) {
@@ -13666,25 +13678,26 @@ class Softphone {
13666
13678
  server = 'stack.dev.wazo.io';
13667
13679
  }
13668
13680
 
13669
- this._createIframe(() => {
13670
- this._sendMessage(BRIDGE_CONFIG_RETRIEVED, {
13671
- config: {
13672
- server,
13673
- port,
13674
- language,
13675
- wrapUpDuration,
13676
- shouldDisplayLinkedEntities,
13677
- allowContactCreation,
13678
- },
13679
- });
13681
+ const config = { server };
13682
+ if (language) {
13683
+ config.language = language;
13684
+ }
13685
+ if (port) {
13686
+ config.port = port;
13687
+ }
13688
+ if (wrapUpDuration) {
13689
+ config.wrapUpDuration = wrapUpDuration;
13690
+ }
13680
13691
 
13681
- if (withCard) {
13682
- this._sendMessage(BRIDGE_ENABLE_CARD);
13683
- }
13692
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13684
13693
 
13685
- if (subscriptionType) {
13686
- this._sendMessage(BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE, { subscriptionType });
13687
- }
13694
+ if (enableAgent) {
13695
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13696
+ }
13697
+
13698
+ this._createIframe(() => {
13699
+ this.iframeLoaded = true;
13700
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13688
13701
 
13689
13702
  this.onIFrameLoaded();
13690
13703
  });
@@ -13745,6 +13758,18 @@ class Softphone {
13745
13758
  this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13746
13759
  }
13747
13760
 
13761
+ setCardValue(field , value ) {
13762
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13763
+ }
13764
+
13765
+ injectCss(css ) {
13766
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13767
+ }
13768
+
13769
+ customizeAppearance(themes , translations , assets ) {
13770
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13771
+ }
13772
+
13748
13773
  _createIframe(cb = () => {}) {
13749
13774
  this.iframe = document.createElement('iframe');
13750
13775
  // $FlowFixMe
@@ -13879,6 +13904,12 @@ class Softphone {
13879
13904
  case BRIDGE_ON_STOP_RECORDING:
13880
13905
  this.onStopRecording();
13881
13906
  break;
13907
+ case BRIDGE_ON_CARD_CANCELED:
13908
+ this.onCardCanceled();
13909
+ break;
13910
+ case BRIDGE_ON_CALL_ANSWERED:
13911
+ this.onCallAnswered();
13912
+ break;
13882
13913
  default:
13883
13914
  this.onUnHandledEvent(event);
13884
13915
  break;
@@ -13886,8 +13917,8 @@ class Softphone {
13886
13917
  }
13887
13918
 
13888
13919
  _sendMessage(type , payload = {}) {
13889
- if (!this.iframe) {
13890
- console.warn(`Could not send message of type ${type} to the Wazo Softphone, iframe not created yet`);
13920
+ if (!this.iframe || !this.iframeLoaded) {
13921
+ this._pendingMessages.push([type, payload]);
13891
13922
  return;
13892
13923
  }
13893
13924