// Path: app/src/main/java/com/pacoworks/dereference/network/LoggerInterceptor.java
// public class LoggerInterceptor implements Interceptor {
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         Timber.d("Started request ==> %s", chain.request().url().toString());
//         return chain.proceed(chain.request());
//     }
// }
// 
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
//     @GET("search/artists.json")
//     Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
//             @Query("query") String url);
// 
//     @GET("artists/{artist_id}/similar_artists.json")
//     Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
//             @Query("apikey") String apikey);
// }


import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import com.facebook.stetho.okhttp.StethoInterceptor;
import com.google.gson.Gson;
import com.pacoworks.dereference.network.LoggerInterceptor;
/*
 * Copyright (c) pakoito 2015
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.pacoworks.dereference.dependencies.modules;






@Module(includes = SerializationModule.class)
public class NetworkModule {
    static final int DEFAULT_READ_TIMEOUT_MILLIS = 20 * 1000; // 20s

    static final int DEFAULT_WRITE_TIMEOUT_MILLIS = 20 * 1000; // 20s

    static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 15 * 1000; // 15s

    private final String endpointUrl;

    private final long cacheSize;

    private File cacheDir;

    public NetworkModule(String endpointUrl, File cacheDir, long cacheSize) {
        this.cacheDir = cacheDir;
        this.endpointUrl = endpointUrl;
        this.cacheSize = cacheSize;
    }

    @Provides
    @Singleton
// Path: app/src/main/java/com/pacoworks/dereference/network/LoggerInterceptor.java
// public class LoggerInterceptor implements Interceptor {
//     @Override
//     public Response intercept(Chain chain) throws IOException {
//         Timber.d("Started request ==> %s", chain.request().url().toString());
//         return chain.proceed(chain.request());
//     }
// }
// 
// Path: app/src/main/java/com/pacoworks/dereference/network/SongkickApi.java
// public interface SongkickApi {
//     @GET("search/artists.json")
//     Observable<SearchResult> getSearchResult(@Query("apikey") String apikey,
//             @Query("query") String url);
// 
//     @GET("artists/{artist_id}/similar_artists.json")
//     Observable<SearchResult> getRelatedArtists(@Path("artist_id") String artistId,
//             @Query("apikey") String apikey);
// }


// Path: app/src/main/java/com/pacoworks/dereference/dependencies/modules/NetworkModule.java
import com.pacoworks.dereference.network.SongkickApi;
import com.squareup.okhttp.Cache;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.picasso.OkHttpDownloader;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.RxJavaCallAdapterFactory;
import com.facebook.stetho.okhttp.StethoInterceptor;
import com.google.gson.Gson;
import com.pacoworks.dereference.network.LoggerInterceptor;

/*
 * Copyright (c) pakoito 2015
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.pacoworks.dereference.dependencies.modules;






@Module(includes = SerializationModule.class)
public class NetworkModule {
    static final int DEFAULT_READ_TIMEOUT_MILLIS = 20 * 1000; // 20s

    static final int DEFAULT_WRITE_TIMEOUT_MILLIS = 20 * 1000; // 20s

    static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 15 * 1000; // 15s

    private final String endpointUrl;

    private final long cacheSize;

    private File cacheDir;

    public NetworkModule(String endpointUrl, File cacheDir, long cacheSize) {
        this.cacheDir = cacheDir;
        this.endpointUrl = endpointUrl;
        this.cacheSize = cacheSize;
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttp(final Cache cache, LoggerInterceptor loggerInterceptor,