Object ClientProvider
-
- All Implemented Interfaces:
public class ClientProvider
Facilitates 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 String
HTTP_HEADER_X_SMP_APPID
public final static String
HTTP_HEADER_X_SMP_DEVICEID
public final static String
HTTP_HEADER_X_SMP_APP_VERSION
public final static String
HTTP_HEADER_X_API_KEY
public final static String
HTTP_HEADER_X_SMP_SDK_VERSION
public final static String
HTTP_HEADER_X_APP_VERSION_INACTIVE
public final static String
HTTP_HEADER_X_APP_VERSIONS_ACTIVE
public final static String
HTTP_HEADER_X_SMP_SALT_FACTOR
public final static String
HTTP_HEADER_X_MS_ATTESTATION
public final static String
HTTP_HEADER_X_MS_ATTESTATION_TOKEN
public final static String
HTTP_HEADER_X_MS_ATTESTATION_TOKEN_EXPIRE_TIME
public final static String
HTTP_HEADER_X_MS_ATTESTATION_TOKEN_ERROR
public final static String
HTTP_HEADER_ACCEPT_LANGUAGE
private final OkHttpClient
withApiKeyHeader
public final static ClientProvider
INSTANCE
-
Method Summary
Modifier and Type Method Description final static Unit
set(OkHttpClient client)
Sets the okHttpClient in the provider for future access using get. final static OkHttpClient
get()
Returns the okHttpClient that can be used for server communication. final Unit
putHeader(String name, String value)
final static Map<String, String>
getHeaders()
final static Unit
clear()
final OkHttpClient
getWithApiKeyHeader()
-
-
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 ofOkHttpClient
that 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.
-
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()
-
-
-
-