Class CallHttpApis.Builder

java.lang.Object
org.shakespeareframework.retrofit.CallHttpApis.Builder
Enclosing class:
CallHttpApis

public static class CallHttpApis.Builder extends Object
Builder wrapping a Retrofit.Builder and a OkHttpClient.Builder to allow setting both with one class.
  • Method Details

    • baseUrl

      public CallHttpApis.Builder baseUrl(String baseUrl)
      Sets the base URL to the retrofitBuilder.
      Parameters:
      baseUrl - base URL of the API
      Returns:
      the CallHttpApis.Builder
      See Also:
      • Retrofit.Builder.baseUrl(String)
    • addConverterFactory

      public CallHttpApis.Builder addConverterFactory(retrofit2.Converter.Factory converterFactory)
      Adds the given Converter.Factory to the retrofitBuilder.
      Parameters:
      converterFactory - a Converter.Factory to be added to the retrofitBuilder
      Returns:
      the CallHttpApis.Builder
      See Also:
      • Retrofit.Builder.addConverterFactory(Converter.Factory)
    • addScalarsConverterFactory

      public CallHttpApis.Builder addScalarsConverterFactory()
      Adds a ScalarsConverterFactory to the retrofitBuilder.
      Returns:
      the CallHttpApis.Builder
      See Also:
    • addJacksonConverterFactory

      public CallHttpApis.Builder addJacksonConverterFactory()
      Adds a JacksonConverterFactory to the retrofitBuilder.
      Returns:
      the CallHttpApis.Builder
      See Also:
    • addInterceptor

      public CallHttpApis.Builder addInterceptor(okhttp3.Interceptor interceptor)
      Adds the given Interceptor to the okHttpClientBuilder.
      Parameters:
      interceptor - an Interceptor to be added to the okHttpClientBuilder
      Returns:
      the CallHttpApis.Builder
      See Also:
      • OkHttpClient.Builder.addInterceptor(Interceptor)
    • authenticator

      public CallHttpApis.Builder authenticator(okhttp3.Authenticator authenticator)
    • build

      public <C> C build(Class<? extends C> clientClass)
      Finalizes the build and returns the client.
      Type Parameters:
      C - the type of the API client class
      Parameters:
      clientClass - the API client class
      Returns:
      an instance of clientClass to interact with the API
      See Also:
      • Retrofit.Builder.build()
      • OkHttpClient.Builder.build()
      • Retrofit.create(Class)