// Path: impala/src/main/java/hainguyen/impala/application/Constants.java
// public class Constants {
// 
//     public static final String LOGIN_URL = "http://private-2839e-impalasample.apiary-mock.com/";
// 
//     private Constants() {
//     }
// }
// 
// Path: impala/src/main/java/hainguyen/impala/network/LoginRepository.java
// public interface LoginRepository {
//     Observable<LoginResponse> login(LoginRequest request);
// }
// 
// Path: impala/src/main/java/hainguyen/impala/network/LoginRepositoryImpl.java
// public class LoginRepositoryImpl implements LoginRepository {
// 
//     private LoginService loginService;
// 
//     public LoginRepositoryImpl(LoginService service) {
//         this.loginService = service;
//     }
// 
//     @Override public Observable<LoginResponse> login(LoginRequest request) {
//         return loginService.login(request);
//     }
// }
// 
// Path: impala/src/main/java/hainguyen/impala/network/LoginService.java
// public interface LoginService {
//     @POST("impala/login") Observable<LoginResponse> login(@Body LoginRequest request);
// }
// 
// Path: impala/src/main/java/hainguyen/impala/util/ImpalaGsonTypeAdapter.java
// @GsonTypeAdapterFactory
// public abstract class ImpalaGsonTypeAdapter implements TypeAdapterFactory {
// 
//     // Static factory method to access the package
//     // private generated implementation
//     public static TypeAdapterFactory create() {
//         return new AutoValueGson_ImpalaGsonTypeAdapter();
//     }
// 
// }


import com.google.gson.GsonBuilder;
import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import hainguyen.impala.application.Constants;
import hainguyen.impala.network.LoginRepository;
import hainguyen.impala.network.LoginRepositoryImpl;
import hainguyen.impala.network.LoginService;
import hainguyen.impala.util.ImpalaGsonTypeAdapter;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
package hainguyen.impala.injection.module;




@Singleton
@Module
public class ApiModule {

    @Provides
    @Singleton
    @Named("LOGIN_URL")
    String provideLoginApiUrl() {
        return Constants.LOGIN_URL;
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttpClient() {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        return new OkHttpClient.Builder().addInterceptor(interceptor).build();
    }

    @Provides
    @Singleton
    Retrofit provideRetrofit(OkHttpClient client,
                             @Named("LOGIN_URL") String url) {
        return new Retrofit.Builder().baseUrl(url)
                .client(client)
                .addConverterFactory(GsonConverterFactory.create(
                        new GsonBuilder().registerTypeAdapterFactory(ImpalaGsonTypeAdapter.create())
                                .create()))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }

// Path: impala/src/main/java/hainguyen/impala/application/Constants.java
// public class Constants {
// 
//     public static final String LOGIN_URL = "http://private-2839e-impalasample.apiary-mock.com/";
// 
//     private Constants() {
//     }
// }
// 
// Path: impala/src/main/java/hainguyen/impala/network/LoginRepository.java
// public interface LoginRepository {
//     Observable<LoginResponse> login(LoginRequest request);
// }
// 
// Path: impala/src/main/java/hainguyen/impala/network/LoginRepositoryImpl.java
// public class LoginRepositoryImpl implements LoginRepository {
// 
//     private LoginService loginService;
// 
//     public LoginRepositoryImpl(LoginService service) {
//         this.loginService = service;
//     }
// 
//     @Override public Observable<LoginResponse> login(LoginRequest request) {
//         return loginService.login(request);
//     }
// }
// 
// Path: impala/src/main/java/hainguyen/impala/network/LoginService.java
// public interface LoginService {
//     @POST("impala/login") Observable<LoginResponse> login(@Body LoginRequest request);
// }
// 
// Path: impala/src/main/java/hainguyen/impala/util/ImpalaGsonTypeAdapter.java
// @GsonTypeAdapterFactory
// public abstract class ImpalaGsonTypeAdapter implements TypeAdapterFactory {
// 
//     // Static factory method to access the package
//     // private generated implementation
//     public static TypeAdapterFactory create() {
//         return new AutoValueGson_ImpalaGsonTypeAdapter();
//     }
// 
// }


// Path: impala/src/main/java/hainguyen/impala/injection/module/ApiModule.java
import com.google.gson.GsonBuilder;
import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import hainguyen.impala.application.Constants;
import hainguyen.impala.network.LoginRepository;
import hainguyen.impala.network.LoginRepositoryImpl;
import hainguyen.impala.network.LoginService;
import hainguyen.impala.util.ImpalaGsonTypeAdapter;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

package hainguyen.impala.injection.module;




@Singleton
@Module
public class ApiModule {

    @Provides
    @Singleton
    @Named("LOGIN_URL")
    String provideLoginApiUrl() {
        return Constants.LOGIN_URL;
    }

    @Provides
    @Singleton
    OkHttpClient provideOkHttpClient() {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        return new OkHttpClient.Builder().addInterceptor(interceptor).build();
    }

    @Provides
    @Singleton
    Retrofit provideRetrofit(OkHttpClient client,
                             @Named("LOGIN_URL") String url) {
        return new Retrofit.Builder().baseUrl(url)
                .client(client)
                .addConverterFactory(GsonConverterFactory.create(
                        new GsonBuilder().registerTypeAdapterFactory(ImpalaGsonTypeAdapter.create())
                                .create()))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }

    @Provides