Class UnbluClientConfiguration.Builder

  • Enclosing class:
    UnbluClientConfiguration

    public static final class UnbluClientConfiguration.Builder
    extends java.lang.Object
    • Constructor Detail

      • Builder

        public Builder​(@NonNull
                       UnbluClientConfiguration unbluClientConfiguration)
        Constructs an api configuration.

        Parameters:
        unbluClientConfiguration - The current UnbluConfiguration object
      • Builder

        public Builder​(@NonNull
                       java.lang.String unbluBaseUrl,
                       @NonNull
                       java.lang.String apiKey,
                       @NonNull
                       UnbluPreferencesStorage preferencesStorage,
                       @NonNull
                       UnbluDownloadHandler downloadHandler,
                       UnbluExternalLinkHandler externalLinkHandler)
        Constructs an api configuration.

        Default implementations can be used for UnbluPreferencesStorage, UnbluDownloadHandler and UnbluExternalLinkHandler, see ExternalStorageDownloadHandler, ExternalStorageDownloadHandler and UnbluPatternMatchingExternalLinkHandler.

        Parameters:
        unbluBaseUrl - The url to the Unblu server. (full URL: http(s)://domain:port)
        apiKey - Your Unblu API key (can be retrieved / created on the Unblu agent desk).
        preferencesStorage - The storage implementation to save and retrieve preferences of the SDK
        downloadHandler - The download handler implementation to handle file downloads.
        externalLinkHandler - The link handler used by Unblu to determine what action to take when an external link is tapped in a conversation.
    • Method Detail

      • setApiKey

        public UnbluClientConfiguration.Builder setApiKey​(@NonNull
                                                          java.lang.String apiKey)
        Changes the api key inside this configuration to the given value.
        Parameters:
        apiKey - Your Unblu API key (can be retrieved / created on the Unblu agent desk).
        Returns:
        The configuration to chain multiple calls.
      • setInternalUrlPatternWhitelist

        public UnbluClientConfiguration.Builder setInternalUrlPatternWhitelist​(@NonNull
                                                                               java.util.List<java.util.regex.Pattern> internalUrlPatternWhitelist)
        Sets the list of URL patterns that may be accessed by the WebView.

        This restricts access to:

        • URLs loaded in the WebView
        • all assets (css, js, images, ...)
        • AJAX requests

        The configured baseURL will be automatically added to the list. This is mainly required if you use redirects from the initial base url to a different domain or if resources like web fonts are loaded from other locations.

        Parameters:
        internalUrlPatternWhitelist - List of url patterns which may be accessed by the WebView
        Returns:
        The configuration to chain multiple calls.
      • setUnbluExternalLinkHandler

        public UnbluClientConfiguration.Builder setUnbluExternalLinkHandler​(@NonNull
                                                                            UnbluExternalLinkHandler externalLinkPatternWhitelist)
        Sets the list of link patterns that may be opened in the system browser.

        Those are typical links from the chat which are clicked by the user.

        The following patterns are added per default, and will be overridden by calling this function.

        • ^\Qhttps://\E.*
        • ^\Qmailto://\E.*
        • ^\Qtel:\E.*

        If a link does not match one of those patterns, clicking on it, will not do anything with it.

        Parameters:
        externalLinkPatternWhitelist - List of url patterns which may be opened in the system browser
        Returns:
        The configuration to chain multiple calls.
      • setEntryPath

        public UnbluClientConfiguration.Builder setEntryPath​(@Nullable
                                                             java.lang.String entryPath)
        Sets the entry path inside self configuration to the given value. Default is null and will use "/unblu" for visitor and "/app" for agent client.
        Do not miss the leading slash!
        Parameters:
        entryPath - The entry path used to connect to the Unblu server. Typical value is "/unblu" or "/app".
        Returns:
        The configuration to chain multiple calls
      • setOAuthToken

        public UnbluClientConfiguration.Builder setOAuthToken​(@Nullable
                                                              java.lang.String token)
        Sets the initial OAuth 2.0 token received from an identity provider, which will pass to service worker and used in the authorization header.
        Parameters:
        token - The token value.
        Returns:
        The configuration to chain multiple calls
      • setCustomCookies

        public UnbluClientConfiguration.Builder setCustomCookies​(@NonNull
                                                                 java.util.Set<UnbluCookie> customCookies)
        Configures a set of cookies which will be set on the configured base url. It will store only a copy of the given map.
        Parameters:
        customCookies - The cookies which will later be used on the configured base url.
        Returns:
        The configuration to chain multiple calls.
      • setLanguage

        public UnbluClientConfiguration.Builder setLanguage​(@Nullable
                                                            java.lang.String language)
        Sets the language which will be send to the server to define the language used inside the UI. If the language is not explicitly defined, the system language of the device is used.
        Parameters:
        language - The language which is set to the server.
        Returns:
        The configuration to chain multiple calls.
      • setNamedArea

        public UnbluClientConfiguration.Builder setNamedArea​(@Nullable
                                                             java.lang.String namedArea)
        Sets the named area for which the configuration is loaded as soon as the api is initializing. When sessions are started and are put into the queue on the agent desk, they can be filtered by the defined named area. The named area must be configured inside the agent desk.
        Parameters:
        namedArea - The named area meta tag id configured in the agent desk.
        Returns:
        The configuration to chain multiple calls.
      • setNotificationsEnabled

        public UnbluClientConfiguration.Builder setNotificationsEnabled​(boolean notificationsEnabled)
        Configures if notifications via Unblu are enabled or not
        Parameters:
        notificationsEnabled - : if true, notifications are enabled. Otherwise they are disabled
        Returns:
        The configuration to chain multiple calls
      • setCameraUploadsEnabled

        public UnbluClientConfiguration.Builder setCameraUploadsEnabled​(boolean cameraUploadsEnabled)
        If set to false, uploads directly via the camera app are disabled. Default is true.
        The images captured via the camera app are stored in a temporary file inside the external storage folder, where they could be accessed by other apps with the permission Manifest.permission.READ_EXTERNAL_STORAGE. It could be considered as unsafe for security reasons.

        This will set both setVideoUploadsEnabled(boolean) and setPhotoUploadsEnabled(boolean) to the specified value

        Parameters:
        cameraUploadsEnabled - If set to true, uploads directly via the camera app are enabled.
        Returns:
        The configuration to chain multiple calls
      • setVideoUploadsEnabled

        public UnbluClientConfiguration.Builder setVideoUploadsEnabled​(boolean videoUploadsEnabled)
        If set to false, video uploads directly are disabled. Default is true.
        The videos captured are stored in a temporary file inside the external storage folder, where they could be accessed by other apps with the permission Manifest.permission.READ_EXTERNAL_STORAGE. It could be considered as unsafe for security reasons.
        Parameters:
        videoUploadsEnabled - If set to true, video uploads directly via the camera app are enabled.
        Returns:
        The configuration to chain multiple calls
      • setAudioUploadsEnabled

        public UnbluClientConfiguration.Builder setAudioUploadsEnabled​(boolean audioUploadsEnabled)
        If set to false, audio uploads directly are disabled. Default is true.
        Parameters:
        audioUploadsEnabled - If set to true, audio uploads are enabled.
        Returns:
        The configuration to chain multiple calls
      • setPhotoUploadsEnabled

        public UnbluClientConfiguration.Builder setPhotoUploadsEnabled​(boolean photoUploadsEnabled)
        If set to false, photo uploads directly are disabled. Default is true.
        The images captured via the camera app are stored in a temporary file inside the external storage folder, where they could be accessed by other apps with the permission Manifest.permission.READ_EXTERNAL_STORAGE. It could be considered as unsafe for security reasons.
        Parameters:
        photoUploadsEnabled - If set to true, photo uploads directly via the camera app are enabled.
        Returns:
        The configuration to chain multiple calls
      • registerModule

        public UnbluClientConfiguration.Builder registerModule​(@NonNull
                                                               UnbluModule module)
        Registers a module which should be used. E.g. call or co-browsing module
        Parameters:
        module - The module to register
        Returns:
        The configuration to chain multiple calls
      • unregisterModule

        public UnbluClientConfiguration.Builder unregisterModule​(@NonNull
                                                                 UnbluModule module)
        Unregister a modle which should no longer be used. E.g. call or co-browsing module
        Parameters:
        module - The module to unregister
        Returns:
        The configuration to chain multiple calls
      • setNotificationInterceptor

        public UnbluClientConfiguration.Builder setNotificationInterceptor​(NotificationInterceptor notificationInterceptor)
        Configures notification interceptor in order to transform the notification before its display
        Parameters:
        notificationInterceptor - the notification interceptor implementation
        Returns:
        The configuration to chain multiple calls
      • setAccessToken

        public UnbluClientConfiguration.Builder setAccessToken​(@NonNull
                                                               java.lang.String accessToken)
        Defines the Access token for SSO authentication, e.g. this could be a Json Web Token
        Parameters:
        accessToken - The string value for the access token
        Returns:
        The configuration to chain multiple calls