Object ClientProvider
-
- All Implemented Interfaces:
public class ClientProviderFacilitates keeping a global reference to a Networking Client that has been initialized with all the necessary Authentication and other interceptors. Generally the application developer will set the initialized okHttpClient once and get it from any where a okHttpClient is needed for the server communication. The set must be called at least once.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringHTTP_HEADER_X_SMP_APPIDpublic final static StringHTTP_HEADER_X_SMP_DEVICEIDpublic final static StringHTTP_HEADER_X_SMP_APP_VERSIONpublic final static StringHTTP_HEADER_X_SMP_DEVICE_BRANDpublic final static StringHTTP_HEADER_X_SMP_DEVICE_MODELpublic final static StringHTTP_HEADER_X_SMP_DEVICE_MODEL_VERSIONpublic final static StringHTTP_HEADER_X_SMP_CLIENT_APPIDpublic final static StringHTTP_HEADER_X_SMP_PLATFORMpublic final static StringHTTP_HEADER_X_SMP_PLATFORM_VERSIONpublic final static StringHTTP_HEADER_X_SMP_DEVICE_INFOpublic final static StringHTTP_HEADER_X_API_KEYpublic final static StringHTTP_HEADER_X_SMP_SDK_VERSIONpublic final static StringHTTP_HEADER_X_APP_VERSION_INACTIVEpublic final static StringHTTP_HEADER_X_APP_VERSIONS_ACTIVEpublic final static StringHTTP_HEADER_X_MS_ATTESTATION_TOKENpublic final static StringHTTP_HEADER_X_MS_ATTESTATION_TOKEN_ERRORpublic final static StringHTTP_HEADER_ACCEPT_LANGUAGEpublic final static StringHTTP_HEADER_WEBSOCKET_UPGRADEpublic final static StringHTTP_HEADER_WEBSOCKET_ORIGINpublic final static StringHTTP_HEADER_APPROUTER_AUTHORIZATIONprivate final OkHttpClientwithApiKeyHeaderpublic final static ClientProviderINSTANCE
-
Method Summary
Modifier and Type Method Description final static Unitset(OkHttpClient client)Sets the okHttpClient in the provider for future access using get. final static OkHttpClientget()Returns the okHttpClient that can be used for server communication. final UnitputHeader(String name, String value)final static Map<String, String>getHeaders()final static Unitclear()final OkHttpClientgetWithApiKeyHeader()-
-
Method Detail
-
set
@Synchronized() final static Unit set(OkHttpClient client)
Sets the okHttpClient in the provider for future access using get. If SessionCreatedCheckInterceptor is not set by client code, it will be added to the okHttpClient. If the okHttpClient is not set before, CLIENT_PROVIDER_SET state event will be sent to the the observers.
- Parameters:
client- instance ofOkHttpClientthat has been built with interceptors needed for server communication
-
get
@Synchronized() final static OkHttpClient get()
Returns the okHttpClient that can be used for server communication. If set was not called at least once before the client will be null and an IllegalStateException is thrown.
- Returns:
okHttpClient instance of
OkHttpClientthat can be used for server communication
-
putHeader
final Unit putHeader(String name, String value)
-
getHeaders
final static Map<String, String> getHeaders()
-
clear
@RestrictTo(value = {RestrictTo.Scope.TESTS})@Synchronized() final static Unit clear()
-
getWithApiKeyHeader
@Synchronized()@RestrictTo(value = {RestrictTo.Scope.LIBRARY}) final OkHttpClient getWithApiKeyHeader()
-
-
-
-