package info.metadude.java.library.brockman;

import com.squareup.moshi.Moshi;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.OkHttpClient;
import info.metadude.java.library.brockman.adapters.StreamAdapter;
import info.metadude.java.library.brockman.adapters.StreamTypeAdapter;
import info.metadude.java.library.brockman.adapters.VideoSizeAdapter;
import retrofit.MoshiConverterFactory;
import retrofit.Retrofit;

import java.util.List;

public final class ApiModule {

    public static StreamsService provideStreamsService(final String baseUrl) {
        return provideStreamsService(baseUrl, null);
    }

    public static StreamsService provideStreamsService(
            final String baseUrl, final List<Interceptor> httpClientInterceptors) {
        return createRetrofit(baseUrl, httpClientInterceptors)
                .create(StreamsService.class);
    }

    private static Retrofit createRetrofit(String baseUrl, List<Interceptor> httpClientInterceptors) {
        OkHttpClient httpClient = new OkHttpClient();
        if (httpClientInterceptors != null) {
            httpClient.interceptors().addAll(httpClientInterceptors);
        }

        Moshi moshi = new Moshi.Builder()
                .add(new StreamTypeAdapter())
                .add(new StreamAdapter())
                .add(new VideoSizeAdapter())
                .build();

        return new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(MoshiConverterFactory.create(moshi))
                .client(httpClient)
                .build();
    }

}

@@ -722,48 +722,33 @@
 nal 
-List%3CInterceptor%3E httpClientInterceptors
+OkHttpClient okHttpClient
 ) %7B%0A
@@ -786,17 +786,19 @@
 aseUrl, 
-h
+okH
 ttpClien
@@ -798,28 +798,16 @@
 tpClient
-Interceptors
 )%0A      
@@ -917,91 +917,22 @@
 rl, 
-List%3CInterceptor%3E httpClientInterceptors) %7B%0A        OkHttpClient httpClient = new O
+OkHttpClient o
 kHtt
@@ -938,19 +938,19 @@
 tpClient
-();
+) %7B
 %0A       
@@ -954,17 +954,19 @@
     if (
-h
+okH
 ttpClien
@@ -970,22 +970,10 @@
 ient
-Interceptors !
+ =
 = nu
@@ -990,17 +990,19 @@
         
-h
+okH
 ttpClien
@@ -1006,53 +1006,28 @@
 ient
-.interceptors().addAll(httpClientInterceptors
+ = new OkHttpClient(
 );%0A 
@@ -1408,17 +1408,19 @@
 .client(
-h
+okH
 ttpClien

Allow to pass in OkHttpClient from application.