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.

    • Constructor Detail

    • 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 of OkHttpClient 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()