// Path: databoundary/src/main/java/eu/rampsoftware/er/data/SingleValue.java
// public class SingleValue {
//     private Date mDate;
//     private double mValue;
// 
//     public SingleValue(final Date date, final double value) {
//         mDate = date;
//         mValue = value;
//     }
// 
//     public Date getDate() {
//         return mDate;
//     }
// 
//     public double getValue() {
//         return mValue;
//     }
// 
//     @Override
//     public String toString() {
//         return "SingleValue{" +
//                 "mDate=" + mDate +
//                 ", mValue=" + mValue +
//                 '}';
//     }
// }
// 
// Path: domain/src/main/java/eu/rampsoftware/er/domain/usecases/GetCurrencySeriesUseCase.java
// public class GetCurrencySeriesUseCase extends QueryUseCase<SingleValue, GetCurrencySeriesUseCase.CurrencySeriesParam> {
// 
//     private final CurrencyRepository mRepository;
// 
//     public GetCurrencySeriesUseCase(final Scheduler workScheduler,
//                                     final Scheduler observeScheduler,
//                                     CurrencyRepository repository) {
//         super(workScheduler, observeScheduler);
//         mRepository = repository;
// 
//     }
// 
//     @Override
//     protected Observable<SingleValue> buildUseCaseObservable(final CurrencySeriesParam params) {
//         return mRepository.getSeries(params.from, params.to, params.currencyCode);
//     }
// 
//     public static class CurrencySeriesParam {
//         Date from;
//         Date to;
//         String currencyCode;
// 
//         public CurrencySeriesParam(final Date from,
//                                    final Date to,
//                                    final String currencyCode) {
//             this.from = checkNotNull(from);
//             this.to = checkNotNull(to);
//             this.currencyCode = checkNotNull(currencyCode);
//             if(currencyCode.isEmpty()){
//                 throw new InvalidParameterException("CURRENCY CODE parameter cannot be empty");
//             }
//             if(from.getTime() > to.getTime()){
//                 throw new InvalidParameterException("START date cannot be after TO date.");
//             }
//         }
//     }
// }
// 
// Path: presentation/src/main/java/eu/rampsoftware/er/viewmodel/BaseDisposableViewModel.java
// public abstract class BaseDisposableViewModel extends BaseObservable implements BaseViewModel {
// 
//     private final CompositeDisposable mDisposables;
// 
//     protected BaseDisposableViewModel() {
//         mDisposables = new CompositeDisposable();
//     }
// 
//     public void dispose() {
//         if (!mDisposables.isDisposed()) {
//             mDisposables.dispose();
//         }
//     }
// 
//     protected void addDisposable(Disposable disposable) {
//         mDisposables.add(disposable);
//     }
// 
// }
// 
// Path: presentation/src/main/java/eu/rampsoftware/er/viewmodel/BaseViewModel.java
// public interface BaseViewModel {
//     /**
//      * Invoked when view is initialized and is ready to display the data exposed by view model.
//      * @param bundle additional to be passed to the viewmodel.
//      */
//     void onLoad(final Bundle bundle);
// 
//     void dispose();
// }
// 
// Path: domain/src/main/java/eu/rampsoftware/er/domain/usecases/GetCurrencySeriesUseCase.java
// public static class CurrencySeriesParam {
//     Date from;
//     Date to;
//     String currencyCode;
// 
//     public CurrencySeriesParam(final Date from,
//                                final Date to,
//                                final String currencyCode) {
//         this.from = checkNotNull(from);
//         this.to = checkNotNull(to);
//         this.currencyCode = checkNotNull(currencyCode);
//         if(currencyCode.isEmpty()){
//             throw new InvalidParameterException("CURRENCY CODE parameter cannot be empty");
//         }
//         if(from.getTime() > to.getTime()){
//             throw new InvalidParameterException("START date cannot be after TO date.");
//         }
//     }
// }


import android.databinding.Bindable;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import eu.rampsoftware.er.BR;
import eu.rampsoftware.er.data.SingleValue;
import eu.rampsoftware.er.domain.usecases.GetCurrencySeriesUseCase;
import eu.rampsoftware.er.viewmodel.BaseDisposableViewModel;
import eu.rampsoftware.er.viewmodel.BaseViewModel;
import static com.fernandocejas.arrow.checks.Preconditions.checkArgument;
import static com.fernandocejas.arrow.checks.Preconditions.checkNotNull;
import static eu.rampsoftware.er.domain.usecases.GetCurrencySeriesUseCase.CurrencySeriesParam;
    public void onLoad(final Bundle bundle) {
        checkNotNull(bundle);
        checkArgument(bundle.containsKey(KEY_CURRENCY_CODE), "Currency code must be provided to onLoad method");
        setCurrencyCode(bundle.getString(KEY_CURRENCY_CODE));
        performRequest();
    }

    @Bindable
    public boolean isProgressVisible() {
        return mIsProgressVisible;
    }

    public void setProgressVisible(final boolean progressVisible) {
        mIsProgressVisible = progressVisible;
        notifyPropertyChanged(BR.progressVisible);
    }

    public void performRefresh() {
        performRequest();
    }

    private void performRequest() {
        setProgressVisible(true);
        Date endDate = new Date();
        int daysRange = 10;
        mCurrencySeries.clear();
        final Calendar calendar = Calendar.getInstance();
        calendar.setTime(endDate);
        calendar.add(Calendar.DAY_OF_YEAR, -daysRange);
        Date from = calendar.getTime();
// Path: databoundary/src/main/java/eu/rampsoftware/er/data/SingleValue.java
// public class SingleValue {
//     private Date mDate;
//     private double mValue;
// 
//     public SingleValue(final Date date, final double value) {
//         mDate = date;
//         mValue = value;
//     }
// 
//     public Date getDate() {
//         return mDate;
//     }
// 
//     public double getValue() {
//         return mValue;
//     }
// 
//     @Override
//     public String toString() {
//         return "SingleValue{" +
//                 "mDate=" + mDate +
//                 ", mValue=" + mValue +
//                 '}';
//     }
// }
// 
// Path: domain/src/main/java/eu/rampsoftware/er/domain/usecases/GetCurrencySeriesUseCase.java
// public class GetCurrencySeriesUseCase extends QueryUseCase<SingleValue, GetCurrencySeriesUseCase.CurrencySeriesParam> {
// 
//     private final CurrencyRepository mRepository;
// 
//     public GetCurrencySeriesUseCase(final Scheduler workScheduler,
//                                     final Scheduler observeScheduler,
//                                     CurrencyRepository repository) {
//         super(workScheduler, observeScheduler);
//         mRepository = repository;
// 
//     }
// 
//     @Override
//     protected Observable<SingleValue> buildUseCaseObservable(final CurrencySeriesParam params) {
//         return mRepository.getSeries(params.from, params.to, params.currencyCode);
//     }
// 
//     public static class CurrencySeriesParam {
//         Date from;
//         Date to;
//         String currencyCode;
// 
//         public CurrencySeriesParam(final Date from,
//                                    final Date to,
//                                    final String currencyCode) {
//             this.from = checkNotNull(from);
//             this.to = checkNotNull(to);
//             this.currencyCode = checkNotNull(currencyCode);
//             if(currencyCode.isEmpty()){
//                 throw new InvalidParameterException("CURRENCY CODE parameter cannot be empty");
//             }
//             if(from.getTime() > to.getTime()){
//                 throw new InvalidParameterException("START date cannot be after TO date.");
//             }
//         }
//     }
// }
// 
// Path: presentation/src/main/java/eu/rampsoftware/er/viewmodel/BaseDisposableViewModel.java
// public abstract class BaseDisposableViewModel extends BaseObservable implements BaseViewModel {
// 
//     private final CompositeDisposable mDisposables;
// 
//     protected BaseDisposableViewModel() {
//         mDisposables = new CompositeDisposable();
//     }
// 
//     public void dispose() {
//         if (!mDisposables.isDisposed()) {
//             mDisposables.dispose();
//         }
//     }
// 
//     protected void addDisposable(Disposable disposable) {
//         mDisposables.add(disposable);
//     }
// 
// }
// 
// Path: presentation/src/main/java/eu/rampsoftware/er/viewmodel/BaseViewModel.java
// public interface BaseViewModel {
//     /**
//      * Invoked when view is initialized and is ready to display the data exposed by view model.
//      * @param bundle additional to be passed to the viewmodel.
//      */
//     void onLoad(final Bundle bundle);
// 
//     void dispose();
// }
// 
// Path: domain/src/main/java/eu/rampsoftware/er/domain/usecases/GetCurrencySeriesUseCase.java
// public static class CurrencySeriesParam {
//     Date from;
//     Date to;
//     String currencyCode;
// 
//     public CurrencySeriesParam(final Date from,
//                                final Date to,
//                                final String currencyCode) {
//         this.from = checkNotNull(from);
//         this.to = checkNotNull(to);
//         this.currencyCode = checkNotNull(currencyCode);
//         if(currencyCode.isEmpty()){
//             throw new InvalidParameterException("CURRENCY CODE parameter cannot be empty");
//         }
//         if(from.getTime() > to.getTime()){
//             throw new InvalidParameterException("START date cannot be after TO date.");
//         }
//     }
// }


// Path: presentation/src/main/java/eu/rampsoftware/er/viewmodel/details/CurrencyDetailsViewModel.java
import android.databinding.Bindable;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import eu.rampsoftware.er.BR;
import eu.rampsoftware.er.data.SingleValue;
import eu.rampsoftware.er.domain.usecases.GetCurrencySeriesUseCase;
import eu.rampsoftware.er.viewmodel.BaseDisposableViewModel;
import eu.rampsoftware.er.viewmodel.BaseViewModel;
import static com.fernandocejas.arrow.checks.Preconditions.checkArgument;
import static com.fernandocejas.arrow.checks.Preconditions.checkNotNull;
import static eu.rampsoftware.er.domain.usecases.GetCurrencySeriesUseCase.CurrencySeriesParam;

    public void onLoad(final Bundle bundle) {
        checkNotNull(bundle);
        checkArgument(bundle.containsKey(KEY_CURRENCY_CODE), "Currency code must be provided to onLoad method");
        setCurrencyCode(bundle.getString(KEY_CURRENCY_CODE));
        performRequest();
    }

    @Bindable
    public boolean isProgressVisible() {
        return mIsProgressVisible;
    }

    public void setProgressVisible(final boolean progressVisible) {
        mIsProgressVisible = progressVisible;
        notifyPropertyChanged(BR.progressVisible);
    }

    public void performRefresh() {
        performRequest();
    }

    private void performRequest() {
        setProgressVisible(true);
        Date endDate = new Date();
        int daysRange = 10;
        mCurrencySeries.clear();
        final Calendar calendar = Calendar.getInstance();
        calendar.setTime(endDate);
        calendar.add(Calendar.DAY_OF_YEAR, -daysRange);
        Date from = calendar.getTime();
        CurrencySeriesParam params = new CurrencySeriesParam(from, endDate, mCurrencyCode);