// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
// 
//     String BASE_URL = "http://numbersapi.com";
// 
//     @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
//             @Path("numbers") String commaSeparatedNumbers
//     );
// 
// }


import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.Module;
import dagger.Provides;
import dagger.Reusable;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
package br.ufs.demos.rxmvp.playground.dagger.modules;


/**
 * Created by bira on 6/26/17.
 */

@Module
public class RestWebServiceModule {

    @Provides @Reusable static NumbersWebService webService(OkHttpClient customHttpClient) {

        Retrofit adapter = new Retrofit.Builder()
                .baseUrl(NumbersWebService.BASE_URL)
                .client(customHttpClient)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();

// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/webservice/NumbersWebService.java
// public interface NumbersWebService {
// 
//     String BASE_URL = "http://numbersapi.com";
// 
//     @GET("/{numbers}/trivia") Flowable<NumbersTriviaPayload> getTrivia(
//             @Path("numbers") String commaSeparatedNumbers
//     );
// 
// }


// Path: app/src/live/java/br/ufs/demos/rxmvp/playground/dagger/modules/RestWebServiceModule.java
import br.ufs.demos.rxmvp.playground.webservice.NumbersWebService;
import dagger.Module;
import dagger.Provides;
import dagger.Reusable;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

package br.ufs.demos.rxmvp.playground.dagger.modules;


/**
 * Created by bira on 6/26/17.
 */

@Module
public class RestWebServiceModule {

    @Provides @Reusable static NumbersWebService webService(OkHttpClient customHttpClient) {

        Retrofit adapter = new Retrofit.Builder()
                .baseUrl(NumbersWebService.BASE_URL)
                .client(customHttpClient)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        return adapter.create(NumbersWebService.class);