// Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
//     Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
// 
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
//     String URL_BASE = "https://api.github.com";
//     String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
// 
//     @Headers({HEADER_API_VERSION})
//     @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
// 
//     @Headers({HEADER_API_VERSION})
//     @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
// 
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
// 
//     @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
//         super(restApi, rxProviders, ui);
//     }
// 
//     @Override public Observable<UserDemoEntity> searchByUserName(final String  username) {
//         return restApi.getUser(username).map(response -> {
//             handleError(response);
//             final UserDemoEntity user = response.body();
//             return user;
//         });
//     }
// 
//     @Override public Observable<List<UserDemoEntity>> askForUsers() {
//         return restApi.getUsers().map(response -> {
//             handleError(response);
//             return response.body();
//         });
//     }
// 
//     @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
//         return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
//     }
// 
//     @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
//         return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
//                 .map(user-> true);
//     }
// }
// 
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
//     File cacheDirectory();
// }
// 
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
//     Observable<UserDemoEntity> searchByUserName(String nameUser);
//     Observable<List<UserDemoEntity>> askForUsers();
//     Observable<UserDemoEntity> getSelectedUserDemoList();
//     Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }


import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
/*
 * Copyright 2015 RefineriaWeb
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package data.internal.di;



/**
 * Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
 * to generate every endpoint required
 *
 * {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
 * in the domain layer, it required to be able to launch the application.
 */
@Module
public class DataModule {

    @Singleton @Provides RestApi provideRestApi() {
        return new Retrofit.Builder()
                .baseUrl(RestApi.URL_BASE)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RestApi.class);
    }

    @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
        return new RxCache.Builder()
                .persistence(repositoryAdapter.cacheDirectory())
                .using(RxProviders.class);
    }

// Path: data/src/main/java/data/cache/RxProviders.java
// public interface RxProviders {
//     Observable<UserDemoEntity> getSelectedUserDemoList(Observable<UserDemoEntity> oUserSelected, EvictProvider evictProvider);
// }
// 
// Path: data/src/main/java/data/net/RestApi.java
// public interface RestApi {
//     String URL_BASE = "https://api.github.com";
//     String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";
// 
//     @Headers({HEADER_API_VERSION})
//     @GET("/users/{username}") Observable<Response<UserDemoEntity>> getUser(@Path("username") String username);
// 
//     @Headers({HEADER_API_VERSION})
//     @GET("/users") Observable<Response<List<UserDemoEntity>>> getUsers();
// }
// 
// Path: data/src/main/java/data/sections/user_demo/UserDemoDataRepository.java
// public class UserDemoDataRepository extends DataRepository implements UserDemoRepository {
// 
//     @Inject public UserDemoDataRepository(RestApi restApi, RxProviders rxProviders, UI ui) {
//         super(restApi, rxProviders, ui);
//     }
// 
//     @Override public Observable<UserDemoEntity> searchByUserName(final String  username) {
//         return restApi.getUser(username).map(response -> {
//             handleError(response);
//             final UserDemoEntity user = response.body();
//             return user;
//         });
//     }
// 
//     @Override public Observable<List<UserDemoEntity>> askForUsers() {
//         return restApi.getUsers().map(response -> {
//             handleError(response);
//             return response.body();
//         });
//     }
// 
//     @Override public Observable<UserDemoEntity> getSelectedUserDemoList() {
//         return rxProviders.getSelectedUserDemoList(Observable.just(null), new EvictProvider(false));
//     }
// 
//     @Override public Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity userSelected) {
//         return rxProviders.getSelectedUserDemoList(Observable.just(userSelected), new EvictProvider(true))
//                 .map(user-> true);
//     }
// }
// 
// Path: data/src/main/java/data/storage/RepositoryAdapter.java
// public interface RepositoryAdapter {
//     File cacheDirectory();
// }
// 
// Path: domain/src/main/java/domain/sections/user_demo/UserDemoRepository.java
// public interface UserDemoRepository extends Repository {
//     Observable<UserDemoEntity> searchByUserName(String nameUser);
//     Observable<List<UserDemoEntity>> askForUsers();
//     Observable<UserDemoEntity> getSelectedUserDemoList();
//     Observable<Boolean> saveSelectedUserDemoList(UserDemoEntity user);
// }


// Path: data/src/main/java/data/internal/di/DataModule.java
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import data.cache.RxProviders;
import data.net.RestApi;
import data.sections.user_demo.UserDemoDataRepository;
import data.storage.RepositoryAdapter;
import domain.sections.user_demo.UserDemoRepository;
import io.rx_cache.internal.RxCache;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/*
 * Copyright 2015 RefineriaWeb
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package data.internal.di;



/**
 * Dagger module for data layer. {@link #provideRestApi} define the interface used by retrofit in order
 * to generate every endpoint required
 *
 * {@link #provideUserDemoDataRepository} is an example of repository. UserDemoDataRepository implements the interface defined
 * in the domain layer, it required to be able to launch the application.
 */
@Module
public class DataModule {

    @Singleton @Provides RestApi provideRestApi() {
        return new Retrofit.Builder()
                .baseUrl(RestApi.URL_BASE)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RestApi.class);
    }

    @Singleton @Provides RxProviders provideRxProviders(RepositoryAdapter repositoryAdapter) {
        return new RxCache.Builder()
                .persistence(repositoryAdapter.cacheDirectory())
                .using(RxProviders.class);
    }

    @Provides @Singleton public UserDemoRepository provideUserDemoDataRepository(UserDemoDataRepository userDemoDataRepository) {