// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/api/OauthApi.java
// public interface OauthApi {
//     @POST("/oauth/token")
//     Single<AccessTokenEntity> fetchToken(
//             @Query("client_id")     String clientId,
//             @Query("client_secret") String clientSecret,
//             @Query("grant_type")    String grantType,
//             @Query("redirect_uri")  String redirectUri,
//             @Query("code")          String code
//     );
// 
//     @POST("/oauth/revoke")
//     Completable revoke(
//             @Header("Authorization") String authorization
//     );
// }
// 
// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/api/UsersApi.java
// public interface UsersApi {
//     @GET("/v1/user")
//     Single<AuthorizedUserEntity> fetch(
//             @Query("access_token") String accessToken
//     );
// }
// 
// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/cache/LoginCache.java
// public interface LoginCache {
//     long getUserId();
//     void putUserId(long userId);
//     String getTeamId();
//     void putTeamName(String teamName);
//     void removeAll();
//     boolean isUserCached();
//     boolean isTeamCached();
// }
// 
// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/entity/OauthParams.java
// public class OauthParams {
//     public static final String TAG = OauthParams.class.getSimpleName();
// 
//     public final String endpoint;
//     public final String clientId;
//     public final String clientSecret;
//     public final String redirectUri;
//     public final String scope;
//     public final String responseType;
//     public final String authorizePath;
//     public final String grantType;
// 
//     public OauthParams(String endpoint, String clientId, String clientSecret, String redirectUri, String scope, String responseType, String authorizePath, String grantType) {
//         this.endpoint = endpoint;
//         this.clientId = clientId;
//         this.clientSecret = clientSecret;
//         this.redirectUri = redirectUri;
//         this.scope = scope;
//         this.responseType = responseType;
//         this.authorizePath = authorizePath;
//         this.grantType = grantType;
//     }
// 
//     public String getAuthorizeUri() {
//         return endpoint + authorizePath
//                 + "?client_id="     + clientId
//                 + "&redirect_uri="  + redirectUri
//                 + "&scope="         + scope
//                 + "&response_type=" + responseType;
//     }
// }


import info.izumin.android.sunazuri.infrastructure.api.OauthApi;
import info.izumin.android.sunazuri.infrastructure.api.UsersApi;
import info.izumin.android.sunazuri.infrastructure.cache.LoginCache;
import info.izumin.android.sunazuri.infrastructure.dao.AccessTokenDao;
import info.izumin.android.sunazuri.infrastructure.entity.OauthParams;
import info.izumin.android.sunazuri.infrastructure.util.Encryptor;
import javax.inject.Inject;
import javax.inject.Singleton;
package info.izumin.android.sunazuri.infrastructure.repository.source.oauth;



/**
 * Created by izumin on 5/13/2016 AD.
 */
@Singleton
class OauthDataSourceFactoryImpl implements OauthDataSourceFactory {
    public static final String TAG = OauthDataSourceFactoryImpl.class.getSimpleName();

    private final UsersApi usersApi;
    private final OauthApi oauthApi;
    private final OauthParams oauthParams;
    private final AccessTokenDao accessTokenDao;
    private final Encryptor encryptor;
    private final LoginCache loginCache;

    @Inject
    OauthDataSourceFactoryImpl(UsersApi usersApi,
                               OauthApi oauthApi,
                               OauthParams oauthParams,
                               AccessTokenDao accessTokenDao,
                               Encryptor encryptor,
                               LoginCache loginCache) {
        this.usersApi = usersApi;
        this.oauthApi = oauthApi;
        this.oauthParams = oauthParams;
        this.accessTokenDao = accessTokenDao;
        this.encryptor = encryptor;
        this.loginCache = loginCache;
    }

    @Override
    public OauthDataSource createLocalDataSource() {
        return new OauthLocalDataSource(accessTokenDao, loginCache);
    }

// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/api/OauthApi.java
// public interface OauthApi {
//     @POST("/oauth/token")
//     Single<AccessTokenEntity> fetchToken(
//             @Query("client_id")     String clientId,
//             @Query("client_secret") String clientSecret,
//             @Query("grant_type")    String grantType,
//             @Query("redirect_uri")  String redirectUri,
//             @Query("code")          String code
//     );
// 
//     @POST("/oauth/revoke")
//     Completable revoke(
//             @Header("Authorization") String authorization
//     );
// }
// 
// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/api/UsersApi.java
// public interface UsersApi {
//     @GET("/v1/user")
//     Single<AuthorizedUserEntity> fetch(
//             @Query("access_token") String accessToken
//     );
// }
// 
// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/cache/LoginCache.java
// public interface LoginCache {
//     long getUserId();
//     void putUserId(long userId);
//     String getTeamId();
//     void putTeamName(String teamName);
//     void removeAll();
//     boolean isUserCached();
//     boolean isTeamCached();
// }
// 
// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/entity/OauthParams.java
// public class OauthParams {
//     public static final String TAG = OauthParams.class.getSimpleName();
// 
//     public final String endpoint;
//     public final String clientId;
//     public final String clientSecret;
//     public final String redirectUri;
//     public final String scope;
//     public final String responseType;
//     public final String authorizePath;
//     public final String grantType;
// 
//     public OauthParams(String endpoint, String clientId, String clientSecret, String redirectUri, String scope, String responseType, String authorizePath, String grantType) {
//         this.endpoint = endpoint;
//         this.clientId = clientId;
//         this.clientSecret = clientSecret;
//         this.redirectUri = redirectUri;
//         this.scope = scope;
//         this.responseType = responseType;
//         this.authorizePath = authorizePath;
//         this.grantType = grantType;
//     }
// 
//     public String getAuthorizeUri() {
//         return endpoint + authorizePath
//                 + "?client_id="     + clientId
//                 + "&redirect_uri="  + redirectUri
//                 + "&scope="         + scope
//                 + "&response_type=" + responseType;
//     }
// }


// Path: app/src/main/java/info/izumin/android/sunazuri/infrastructure/repository/source/oauth/OauthDataSourceFactoryImpl.java
import info.izumin.android.sunazuri.infrastructure.api.OauthApi;
import info.izumin.android.sunazuri.infrastructure.api.UsersApi;
import info.izumin.android.sunazuri.infrastructure.cache.LoginCache;
import info.izumin.android.sunazuri.infrastructure.dao.AccessTokenDao;
import info.izumin.android.sunazuri.infrastructure.entity.OauthParams;
import info.izumin.android.sunazuri.infrastructure.util.Encryptor;
import javax.inject.Inject;
import javax.inject.Singleton;

package info.izumin.android.sunazuri.infrastructure.repository.source.oauth;



/**
 * Created by izumin on 5/13/2016 AD.
 */
@Singleton
class OauthDataSourceFactoryImpl implements OauthDataSourceFactory {
    public static final String TAG = OauthDataSourceFactoryImpl.class.getSimpleName();

    private final UsersApi usersApi;
    private final OauthApi oauthApi;
    private final OauthParams oauthParams;
    private final AccessTokenDao accessTokenDao;
    private final Encryptor encryptor;
    private final LoginCache loginCache;

    @Inject
    OauthDataSourceFactoryImpl(UsersApi usersApi,
                               OauthApi oauthApi,
                               OauthParams oauthParams,
                               AccessTokenDao accessTokenDao,
                               Encryptor encryptor,
                               LoginCache loginCache) {
        this.usersApi = usersApi;
        this.oauthApi = oauthApi;
        this.oauthParams = oauthParams;
        this.accessTokenDao = accessTokenDao;
        this.encryptor = encryptor;
        this.loginCache = loginCache;
    }

    @Override
    public OauthDataSource createLocalDataSource() {
        return new OauthLocalDataSource(accessTokenDao, loginCache);
    }

    @Override