Class BridgeManager

java.lang.Object
com.subaio.fintechbridge.BridgeManager

public final class BridgeManager
extends java.lang.Object
Singleton-class for managing global setup of BridgeViews. Before creating views, `BridgeManager.getInstance().configure` and `BridgeManager.getInstance().setLanguage should be invoked. The manager automatically maintains a valid token and requests new ones using the `TokenHandler.onTokenRequired` callback whenever necessary.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static interface  BridgeManager.TokenHandler  
    class  BridgeManager.TokenResultHandler  
  • Constructor Summary

    Constructors 
    Constructor Description
    BridgeManager()  
  • Method Summary

    Modifier and Type Method Description
    void configure​(java.lang.String baseUrl, java.lang.String language, BridgeManager.TokenHandler tokenHandler, RequestHandler requestHandler, java.util.Map<java.lang.String,​java.lang.String> customConfig, boolean allowExternalUrls, boolean allowShare)
    Configure Subaio Manager to use specified configuration object.
    java.util.Map<java.lang.String,​java.lang.String> getCustomConfig()  
    static BridgeManager getInstance()
    Shared instance of the Subaio Manager.
    boolean getIsConfigured()  
    java.lang.String getLanguage()
    Current language as a BCP-47 string.
    com.subaio.fintechbridge.TemplateHelper getTemplateHelper()  
    Token getToken()
    Token to be used by Subaio for all calls to Subaio backend.
    void prewarm​(android.content.Context context)
    Read currently cached base-HTML/placeholder images.
    void refreshToken()
    Force a refresh of the token.
    void setCustomConfig​(java.util.Map<java.lang.String,​java.lang.String> customConfig)  
    void setLanguage​(java.lang.String language)
    Language to be used by all Subaio views as a BCP-47 string.
    void setTokenHandler​(BridgeManager.TokenHandler tokenHandler)  
    ConfigurationHelper startConfiguration()
    Start configuration flow with fluid interface.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getInstance

      public static BridgeManager getInstance()
      Shared instance of the Subaio Manager. Use this to set token and configure Subaio.
      Returns:
      BridgeManager
    • configure

      public void configure​(@NonNull java.lang.String baseUrl, @NonNull java.lang.String language, @NonNull BridgeManager.TokenHandler tokenHandler, @NonNull RequestHandler requestHandler, java.util.Map<java.lang.String,​java.lang.String> customConfig, boolean allowExternalUrls, boolean allowShare) throws java.net.MalformedURLException
      Configure Subaio Manager to use specified configuration object. It is recommended to use the fluent interface accessible by calling startConfiguration instead of calling configure manually.
      Parameters:
      baseUrl - URL pointing to root of Subaio template, e.g. if template is at `https://www.bar.foo/template`, then baseUrl should be `https://www.bar.foo`
      language - BCP-47 language tag
      tokenHandler - Handle requests for authentication tokens
      requestHandler - Request handler used for SSL pinning requests
      customConfig - Custom named values (such as customizable colors) sent to the views.
      allowExternalUrls - Allow opening of external urls
      allowShare - Allow sharing events
      Throws:
      java.net.MalformedURLException
    • startConfiguration

      public ConfigurationHelper startConfiguration()
      Start configuration flow with fluid interface. Call .apply() to finish configuration. You must call setBaseUrl, setLanguage, setTokenHandler and setRequestHandler as part of the configuration.
    • setLanguage

      public void setLanguage​(@Nullable java.lang.String language)
      Language to be used by all Subaio views as a BCP-47 string. Assigning `language` automatically updates all views and triggers a token refetch if configure has already been called. If it is set to nil or not set, views will never exit their loading-state.
      Parameters:
      language - Language code.
    • setCustomConfig

      public void setCustomConfig​(@Nullable java.util.Map<java.lang.String,​java.lang.String> customConfig)
    • getLanguage

      @Nullable public java.lang.String getLanguage()
      Current language as a BCP-47 string.
      Returns:
      language code.
    • getCustomConfig

      @Nullable public java.util.Map<java.lang.String,​java.lang.String> getCustomConfig()
    • getToken

      @Nullable public Token getToken()
      Token to be used by Subaio for all calls to Subaio backend.
    • getTemplateHelper

      public com.subaio.fintechbridge.TemplateHelper getTemplateHelper()
    • setTokenHandler

      public void setTokenHandler​(BridgeManager.TokenHandler tokenHandler)
    • getIsConfigured

      public boolean getIsConfigured()
    • refreshToken

      public void refreshToken()
      Force a refresh of the token. This is necessary if the user changes authentication status (user logs out, user logs in, user is changed) to ensure that the token (or lack thereof) is correct. Only works after configure and setLanguage has been called.
    • prewarm

      public void prewarm​(@NonNull android.content.Context context)
      Read currently cached base-HTML/placeholder images. If no cache exists, it is fetched asynchronously. Optionally call to avoid a flash of white when creating the very first BridgeView. If not called, this is automatically handled as part of view creation.