Class CallHttpApis.Builder
java.lang.Object
org.shakespeareframework.retrofit.CallHttpApis.Builder
- Enclosing class:
- CallHttpApis
Builder wrapping a
Retrofit.Builder and a OkHttpClient.Builder to allow setting
both with one class.-
Method Summary
Modifier and TypeMethodDescriptionaddConverterFactory(retrofit2.Converter.Factory converterFactory) Adds the givenConverter.Factoryto theretrofitBuilder.addInterceptor(okhttp3.Interceptor interceptor) Adds the givenInterceptorto theokHttpClientBuilder.Adds aJacksonConverterFactoryto theretrofitBuilder.addJacksonConverterFactory(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Adds aJacksonConverterFactoryusing the given objectMapper to theretrofitBuilder.Adds aScalarsConverterFactoryto theretrofitBuilder.authenticator(okhttp3.Authenticator authenticator) Sets theAuthenticatorof theokHttpClientBuilder.Sets the base URL to theretrofitBuilder.<C> CFinalizes the build and returns the client.
-
Method Details
-
baseUrl
Sets the base URL to theretrofitBuilder.- Parameters:
baseUrl- base URL of the API- Returns:
- the
CallHttpApis.Builder - See Also:
-
Retrofit.Builder.baseUrl(String)
-
addConverterFactory
Adds the givenConverter.Factoryto theretrofitBuilder.- Parameters:
converterFactory- aConverter.Factoryto be added to theretrofitBuilder- Returns:
- the
CallHttpApis.Builder - See Also:
-
Retrofit.Builder.addConverterFactory(Converter.Factory)
-
addScalarsConverterFactory
Adds aScalarsConverterFactoryto theretrofitBuilder.- Returns:
- the
CallHttpApis.Builder - See Also:
-
addConverterFactory(Converter.Factory)ScalarsConverterFactory
-
addJacksonConverterFactory
Adds aJacksonConverterFactoryto theretrofitBuilder.- Returns:
- the
CallHttpApis.Builder - See Also:
-
addConverterFactory(Converter.Factory)JacksonConverterFactory
-
addJacksonConverterFactory
public CallHttpApis.Builder addJacksonConverterFactory(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Adds aJacksonConverterFactoryusing the given objectMapper to theretrofitBuilder.- Parameters:
objectMapper- theObjectMapperto be used by theJacksonConverterFactory- Returns:
- the
CallHttpApis.Builder - See Also:
-
addConverterFactory(Converter.Factory)JacksonConverterFactory
-
addInterceptor
Adds the givenInterceptorto theokHttpClientBuilder.- Parameters:
interceptor- anInterceptorto be added to theokHttpClientBuilder- Returns:
- the
CallHttpApis.Builder - See Also:
-
OkHttpClient.Builder.addInterceptor(Interceptor)
-
authenticator
Sets theAuthenticatorof theokHttpClientBuilder.- Parameters:
authenticator- theAuthenticatorto be set- Returns:
- the
CallHttpApis.Builder - See Also:
-
OkHttpClient.Builder.authenticator(Authenticator)
-
build
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)
-