// Path: app/src/main/java/com/w9jds/marketbot/classes/CrestService.java
// public interface CrestService {
// 
//     @GET("/")
//     Observable<Response<CrestServerStatus>> getServer();
// 
//     @GET("/market/types/")
//     Call<CrestDictionary<CrestMarketType>> getMarketTypes(@Query("page") int page);
// 
//     @GET("/inventory/types/{typeId}/")
//     Call<CrestType> getTypeInfo(@Path("typeId") long id);
// 
//     @GET("/market/groups/")
//     Observable<Response<CrestDictionary<CrestMarketGroup>>> getMarketGroups();
// 
//     @GET("/regions/")
//     Observable<Response<CrestDictionary<CrestItem>>> getRegions();
// 
//     @GET("/market/{regionId}/orders/{orderType}/")
//     Observable<Response<CrestDictionary<CrestMarketOrder>>> getMarketOrders(@Path("regionId") long regionId,
//                                                                             @Path("orderType") String orderType,
//                                                                             @Query(value = "type", encoded = true) String typeId);
// 
//     @GET("/market/{regionId}/orders/")
//     Observable<Response<CrestDictionary<CrestMarketOrder>>> getMarketOrders(@Path("regionId") long regionId,
//                                                                             @Query(value = "type", encoded = true) String typeId);
// 
//     @GET("/market/{regionId}/history/")
//     Call<CrestDictionary<CrestMarketHistory>> getMarketHistory(@Path("regionId") final long regionId,
//                                                                @Query("type") final String typeRef);
// 
// }


import android.app.Application;
import com.w9jds.marketbot.classes.CrestService;
import java.io.IOException;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory;

    @Provides
    @Singleton
    Cache provideOkHttpCache(Application application) {
        int cacheSize = 10 * 1024 * 1024;
        return new Cache(application.getCacheDir(), cacheSize);
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttpClient(Cache cache, Interceptor interceptor) {
        return new OkHttpClient.Builder()
                .cache(cache)
                .addInterceptor(interceptor)
                .build();
    }

    @Provides
    @Singleton
    Retrofit providePublicRetrofit(OkHttpClient okHttpClient) {
        return new Retrofit.Builder()
            .baseUrl(TRANQUILITY)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(JacksonConverterFactory.create())
            .client(okHttpClient)
            .build();
    }

    @Provides
    @Singleton
// Path: app/src/main/java/com/w9jds/marketbot/classes/CrestService.java
// public interface CrestService {
// 
//     @GET("/")
//     Observable<Response<CrestServerStatus>> getServer();
// 
//     @GET("/market/types/")
//     Call<CrestDictionary<CrestMarketType>> getMarketTypes(@Query("page") int page);
// 
//     @GET("/inventory/types/{typeId}/")
//     Call<CrestType> getTypeInfo(@Path("typeId") long id);
// 
//     @GET("/market/groups/")
//     Observable<Response<CrestDictionary<CrestMarketGroup>>> getMarketGroups();
// 
//     @GET("/regions/")
//     Observable<Response<CrestDictionary<CrestItem>>> getRegions();
// 
//     @GET("/market/{regionId}/orders/{orderType}/")
//     Observable<Response<CrestDictionary<CrestMarketOrder>>> getMarketOrders(@Path("regionId") long regionId,
//                                                                             @Path("orderType") String orderType,
//                                                                             @Query(value = "type", encoded = true) String typeId);
// 
//     @GET("/market/{regionId}/orders/")
//     Observable<Response<CrestDictionary<CrestMarketOrder>>> getMarketOrders(@Path("regionId") long regionId,
//                                                                             @Query(value = "type", encoded = true) String typeId);
// 
//     @GET("/market/{regionId}/history/")
//     Call<CrestDictionary<CrestMarketHistory>> getMarketHistory(@Path("regionId") final long regionId,
//                                                                @Query("type") final String typeRef);
// 
// }


// Path: app/src/main/java/com/w9jds/marketbot/classes/modules/NetModule.java
import android.app.Application;
import com.w9jds.marketbot.classes.CrestService;
import java.io.IOException;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory;


    @Provides
    @Singleton
    Cache provideOkHttpCache(Application application) {
        int cacheSize = 10 * 1024 * 1024;
        return new Cache(application.getCacheDir(), cacheSize);
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttpClient(Cache cache, Interceptor interceptor) {
        return new OkHttpClient.Builder()
                .cache(cache)
                .addInterceptor(interceptor)
                .build();
    }

    @Provides
    @Singleton
    Retrofit providePublicRetrofit(OkHttpClient okHttpClient) {
        return new Retrofit.Builder()
            .baseUrl(TRANQUILITY)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(JacksonConverterFactory.create())
            .client(okHttpClient)
            .build();
    }

    @Provides
    @Singleton
    public CrestService providePublicCrest(Retrofit retrofit) {