Class UnbluClientConfiguration.Builder
- java.lang.Object
-
- com.unblu.sdk.core.configuration.UnbluClientConfiguration.Builder
-
- Enclosing class:
- UnbluClientConfiguration
public static final class UnbluClientConfiguration.Builder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder(UnbluClientConfiguration unbluClientConfiguration)
Constructs an api configuration.Builder(java.lang.String unbluBaseUrl, java.lang.String apiKey, UnbluPreferencesStorage preferencesStorage, UnbluDownloadHandler downloadHandler, UnbluExternalLinkHandler externalLinkHandler)
Constructs an api configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnbluClientConfiguration
build()
UnbluClientConfiguration.Builder
registerModule(UnbluModule module)
Registers a module which should be used.UnbluClientConfiguration.Builder
setAccessToken(java.lang.String accessToken)
Defines the Access token for SSO authentication, e.g.UnbluClientConfiguration.Builder
setApiKey(java.lang.String apiKey)
Changes the api key inside this configuration to the given value.UnbluClientConfiguration.Builder
setAudioUploadsEnabled(boolean audioUploadsEnabled)
If set to false, audio uploads directly are disabled.UnbluClientConfiguration.Builder
setCameraUploadsEnabled(boolean cameraUploadsEnabled)
If set to false, uploads directly via the camera app are disabled.UnbluClientConfiguration.Builder
setCustomCookies(java.util.Set<UnbluCookie> customCookies)
Configures a set of cookies which will be set on the configured base url.UnbluClientConfiguration.Builder
setDownloadHandler(UnbluDownloadHandler downloadHandler)
Defines the listener for downloads.UnbluClientConfiguration.Builder
setEntryPath(java.lang.String entryPath)
Sets the entry path inside self configuration to the given value.UnbluClientConfiguration.Builder
setInternalUrlPatternWhitelist(java.util.List<java.util.regex.Pattern> internalUrlPatternWhitelist)
Sets the list of URL patterns that may be accessed by the WebView.UnbluClientConfiguration.Builder
setLanguage(java.lang.String language)
Sets the language which will be send to the server to define the language used inside the UI.UnbluClientConfiguration.Builder
setNamedArea(java.lang.String namedArea)
Sets the named area for which the configuration is loaded as soon as the api is initializing.UnbluClientConfiguration.Builder
setNotificationInterceptor(NotificationInterceptor notificationInterceptor)
Configures notification interceptor in order to transform the notification before its displayUnbluClientConfiguration.Builder
setNotificationsEnabled(boolean notificationsEnabled)
Configures if notifications via Unblu are enabled or notUnbluClientConfiguration.Builder
setOAuthToken(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.UnbluClientConfiguration.Builder
setPhotoUploadsEnabled(boolean photoUploadsEnabled)
If set to false, photo uploads directly are disabled.UnbluClientConfiguration.Builder
setPreferencesStorage(UnbluPreferencesStorage preferencesStorage)
Defines the storage implementation to save and retrieve preferences of the SDK.
A default implementation can be used viaUnbluPreferencesStorage.createSharedPreferencesStorage(Context)
which stores the preferences of the SDK inside the SharedPreferences of the app withContext.MODE_PRIVATE
.UnbluClientConfiguration.Builder
setUnbluBaseUrl(java.lang.String unbluBaseUrl)
UnbluClientConfiguration.Builder
setUnbluExternalLinkHandler(UnbluExternalLinkHandler externalLinkPatternWhitelist)
Sets the list of link patterns that may be opened in the system browser.UnbluClientConfiguration.Builder
setVideoUploadsEnabled(boolean videoUploadsEnabled)
If set to false, video uploads directly are disabled.UnbluClientConfiguration.Builder
unregisterModule(UnbluModule module)
Unregister a modle which should no longer be used.
-
-
-
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
andUnbluExternalLinkHandler
, seeExternalStorageDownloadHandler
,ExternalStorageDownloadHandler
andUnbluPatternMatchingExternalLinkHandler
.- 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 SDKdownloadHandler
- 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
-
setUnbluBaseUrl
public UnbluClientConfiguration.Builder setUnbluBaseUrl(@NonNull java.lang.String unbluBaseUrl)
-
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 permissionManifest.permission.READ_EXTERNAL_STORAGE
. It could be considered as unsafe for security reasons.This will set both
setVideoUploadsEnabled(boolean)
andsetPhotoUploadsEnabled(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 permissionManifest.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 permissionManifest.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
-
setPreferencesStorage
public UnbluClientConfiguration.Builder setPreferencesStorage(@NonNull UnbluPreferencesStorage preferencesStorage)
Defines the storage implementation to save and retrieve preferences of the SDK.
A default implementation can be used viaUnbluPreferencesStorage.createSharedPreferencesStorage(Context)
which stores the preferences of the SDK inside the SharedPreferences of the app withContext.MODE_PRIVATE
.- Parameters:
preferencesStorage
- The storage where the SDK will safe its preferences to.- 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
-
setDownloadHandler
public UnbluClientConfiguration.Builder setDownloadHandler(@NonNull UnbluDownloadHandler downloadHandler)
Defines the listener for downloads. This listener then has to handle the download completely.
A default implementation can be used viaUnbluDownloadHandler.createExternalStorageDownloadHandler(Application)
. It stores the files into the public downloads directory.- Parameters:
downloadHandler
- The listener which handles all file downloads- 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
-
build
public UnbluClientConfiguration build()
-
-