Class CMAClient.Builder

  • Enclosing class:
    CMAClient

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

      • Builder

        public Builder()
    • Method Detail

      • setAccessToken

        public CMAClient.Builder setAccessToken​(java.lang.String accessToken)
        Sets the access token for this client.
        Parameters:
        accessToken - access token
        Returns:
        this CMAClient.Builder instance
      • setEnvironmentId

        public CMAClient.Builder setEnvironmentId​(java.lang.String environmentId)
        Configure which environment to use if none is specified.
        Parameters:
        environmentId - the id of the environment to be used.
        Returns:
        this CMAClient.Builder instance.
        See Also:
        ModuleEntries.fetchAll()
      • setCoreCallFactory

        public CMAClient.Builder setCoreCallFactory​(okhttp3.Call.Factory callFactory)
        Sets a custom HTTP call factory for core modules.

        Please also add a AuthorizationHeaderInterceptor ContentTypeInterceptor if you are using a custom call factory to ensure properly setup http headers.

        Parameters:
        callFactory - Call.Factory instance
        Returns:
        this Builder instance
      • setUploadCallFactory

        public CMAClient.Builder setUploadCallFactory​(okhttp3.Call.Factory callFactory)
        Sets a custom HTTP call factory for the upload module.
        Parameters:
        callFactory - Call.Factory instance
        Returns:
        this Builder instance
        See Also:
        Call.Factory for needed interceptors.
      • setCallbackExecutor

        public CMAClient.Builder setCallbackExecutor​(java.util.concurrent.Executor executor)
        Sets the executor to use when invoking asynchronous callbacks.
        Parameters:
        executor - Executor on which any CMACallback methods will be invoked. This defaults to execute on the main thread for Android projects. For non-Android projects this defaults to the same thread of the HTTP client.
        Returns:
        this Builder instance
      • setLogger

        public CMAClient.Builder setLogger​(Logger logger)
        Sets the logger to be used for logging all network requests or all application requests.
        Parameters:
        logger - Logger
        Returns:
        this Builder instance
      • setApplication

        public CMAClient.Builder setApplication​(java.lang.String name,
                                                java.lang.String version)
        Tell the client which application this is.

        It might be used for internal tracking of Contentfuls tools.

        Parameters:
        name - the name of the app.
        version - the version in semver of the app.
        Returns:
        this builder for chaining.
      • setIntegration

        public CMAClient.Builder setIntegration​(java.lang.String name,
                                                java.lang.String version)
        Which integration is used.
        Parameters:
        name - name of the integration.
        version - the version of the integration.
        Returns:
        this builder for chaining.
      • setRateLimitListener

        public CMAClient.Builder setRateLimitListener​(RateLimitsListener listener)
        Add a listener to receive information about rate limits.
        Parameters:
        listener - a listener interface to be informed, as soon as a rate limit header is found.
        Returns:
        this builder for chaining.
      • defaultCoreCallFactoryBuilder

        public okhttp3.OkHttpClient.Builder defaultCoreCallFactoryBuilder()
        Returns:
        default core call factory builder, used by the sdk.
      • defaultUploadCallFactoryBuilder

        public okhttp3.OkHttpClient.Builder defaultUploadCallFactoryBuilder()
        Returns:
        default update api call factory builder, used by the sdk.