// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/data/Repository.java
// public interface Repository {
// 
//   @NonNull
//   Single<ServiceResponse> fetchResponse(@NonNull DateTime dateTime);
// 
// }
// 
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/data/Service.java
// @Singleton
// public class Service implements Repository {
// 
//   private static final int BAD_REQUEST = 400;
//   private static final int NOT_FOUND = 404;
// 
//   public interface Api {
//     @GET("provider.json")
//     Single<ServiceResponse> loadProviderJson(@Query("valid_date") String validDate);
//   }
// 
//   private final Api api;
// 
//   @Inject
//   public Service(@NonNull Api api) {
//     this.api = api;
//   }
// 
//   @NonNull
//   @Override
//   public Single<ServiceResponse> fetchResponse(@NonNull DateTime dateTime) {
//     try {
//       return api.loadProviderJson(DateHelper.encodeDate(dateTime))
//           .onErrorResumeNext(this::mapError);
//     } catch (UnsupportedEncodingException e) {
//       return Single.error(e);
//     }
//   }
// 
//   private Single<ServiceResponse> mapError(Throwable throwable) {
//     if (!(throwable instanceof HttpException)) {
//       return Single.error(throwable);
//     }
// 
//     HttpException exception = (HttpException) throwable;
//     if (exception.code() == NOT_FOUND) {
//       return Single.just(new ServiceResponse(null, Collections.emptyList()));
//     } else if (exception.code() == BAD_REQUEST) {
//       return Single.error(new BadRequestException(exception.message(), exception));
//     }
//     return Single.error(throwable);
//   }
// }


import android.content.Context;
import android.support.annotation.NonNull;
import javax.inject.Singleton;
import au.com.dius.pactconsumer.data.Repository;
import au.com.dius.pactconsumer.data.Service;
import dagger.Module;
import dagger.Provides;
import retrofit2.Retrofit;
package au.com.dius.pactconsumer.app.di;




@Module
public class ApplicationModule {

  private final Context context;

  public ApplicationModule(@NonNull Context context) {
    this.context = context;
  }

  @Singleton
  @Provides
  @NonNull
  public Context getContext() {
    return context;
  }

  @Singleton
  @Provides
  @NonNull
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/data/Repository.java
// public interface Repository {
// 
//   @NonNull
//   Single<ServiceResponse> fetchResponse(@NonNull DateTime dateTime);
// 
// }
// 
// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/data/Service.java
// @Singleton
// public class Service implements Repository {
// 
//   private static final int BAD_REQUEST = 400;
//   private static final int NOT_FOUND = 404;
// 
//   public interface Api {
//     @GET("provider.json")
//     Single<ServiceResponse> loadProviderJson(@Query("valid_date") String validDate);
//   }
// 
//   private final Api api;
// 
//   @Inject
//   public Service(@NonNull Api api) {
//     this.api = api;
//   }
// 
//   @NonNull
//   @Override
//   public Single<ServiceResponse> fetchResponse(@NonNull DateTime dateTime) {
//     try {
//       return api.loadProviderJson(DateHelper.encodeDate(dateTime))
//           .onErrorResumeNext(this::mapError);
//     } catch (UnsupportedEncodingException e) {
//       return Single.error(e);
//     }
//   }
// 
//   private Single<ServiceResponse> mapError(Throwable throwable) {
//     if (!(throwable instanceof HttpException)) {
//       return Single.error(throwable);
//     }
// 
//     HttpException exception = (HttpException) throwable;
//     if (exception.code() == NOT_FOUND) {
//       return Single.just(new ServiceResponse(null, Collections.emptyList()));
//     } else if (exception.code() == BAD_REQUEST) {
//       return Single.error(new BadRequestException(exception.message(), exception));
//     }
//     return Single.error(throwable);
//   }
// }


// Path: consumer/app/src/main/java/au/com/dius/pactconsumer/app/di/ApplicationModule.java
import android.content.Context;
import android.support.annotation.NonNull;
import javax.inject.Singleton;
import au.com.dius.pactconsumer.data.Repository;
import au.com.dius.pactconsumer.data.Service;
import dagger.Module;
import dagger.Provides;
import retrofit2.Retrofit;

package au.com.dius.pactconsumer.app.di;




@Module
public class ApplicationModule {

  private final Context context;

  public ApplicationModule(@NonNull Context context) {
    this.context = context;
  }

  @Singleton
  @Provides
  @NonNull
  public Context getContext() {
    return context;
  }

  @Singleton
  @Provides
  @NonNull
  public Repository getRepository(@NonNull Retrofit retrofit) {