package info.metadude.java.library.halfnarp;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.squareup.okhttp.OkHttpClient;

import retrofit.JacksonConverterFactory;
import retrofit.Retrofit;

public final class ApiModule {

    public static TalkPreferencesService getTalkPreferencesService() {
        return createRetrofit(TalkPreferencesService.BASE_URL)
                .create(TalkPreferencesService.class);
    }

    private static Retrofit createRetrofit(final String baseUrl) {
        OkHttpClient httpClient = new OkHttpClient();

        return new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(JacksonConverterFactory.create(provideObjectMapper()))
                .client(httpClient)
                .build();
    }

    private static ObjectMapper provideObjectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setPropertyNamingStrategy(
                PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
        return objectMapper;
    }

}

@@ -153,16 +153,56 @@
 rategy;%0A
+import com.squareup.okhttp.Interceptor;%0A
 import c
@@ -234,17 +234,16 @@
 Client;%0A
-%0A
 import r
@@ -302,16 +302,40 @@
 rofit;%0A%0A
+import java.util.List;%0A%0A
 public f
@@ -425,24 +425,196 @@
 Service() %7B%0A
+        return getTalkPreferencesService(null);%0A    %7D%0A%0A    public static TalkPreferencesService getTalkPreferencesService(final List%3CInterceptor%3E httpClientInterceptors) %7B%0A
         retu
@@ -662,16 +662,40 @@
 BASE_URL
+, httpClientInterceptors
 )%0A      
@@ -813,16 +813,64 @@
  baseUrl
+, final List%3CInterceptor%3E httpClientInterceptors
 ) %7B%0A    
@@ -918,16 +918,142 @@
 lient();
+%0A        if (httpClientInterceptors != null) %7B%0A            httpClient.interceptors().addAll(httpClientInterceptors);%0A        %7D
 %0A%0A      

Allow intercepting the HTTP client.