// Path: soundcloud-api/src/main/java/com/jlubecki/soundcloud/webapi/android/auth/models/AuthenticationResponse.java
// public class AuthenticationResponse {
// 
//     public String access_token;
// 
//     public String scope;
// 
//     public String error;
// 
//     /**
//      * Helper method to determine authentication response type.
//      *
//      * @return The type of the authentication response.
//      */
//     public ResponseType getType() {
//         if (access_token != null) {
//             return ResponseType.TOKEN;
//         }
// 
//         if (error != null) {
//             return ResponseType.ERROR;
//         }
// 
//         return ResponseType.UNKNOWN;
//     }
// 
//     public enum ResponseType {
//         TOKEN,
//         ERROR,
//         UNKNOWN
//     }
// 
//     @Override
//     public String toString() {
//         return "AuthenticationResponse{" +
//                 "access_token='" + access_token + '\'' +
//                 ", scope='" + scope + '\'' +
//                 ", error='" + error + '\'' +
//                 '}';
//     }
// }


import com.jlubecki.soundcloud.webapi.android.auth.models.AuthenticationResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.support.annotation.NonNull;
import android.util.Log;

    private AuthenticationStrategy(@NonNull Context context, @NonNull List<SoundCloudAuthenticator> authenticators) {
        this.context = context;
        this.authenticators = authenticators;
    }

    public boolean beginAuthentication(AuthenticationCallback callback) {
        if (shouldCheckNetwork && !networkIsConnected()) return false; // Not connected to the internet.

        for(SoundCloudAuthenticator authenticator : authenticators) {
            if(authenticator.prepareAuthenticationFlow(callback)) {
                this.authenticator = authenticator;
                return true; // Prepared successfully. Will execute callback.
            }
        }

        return false;
    }

    public boolean canAuthenticate(Intent intent) {
        return authenticator != null &&
                authenticator.canAuthenticate(intent);
    }

    public void getToken(Intent intent, String clientSecret, final ResponseCallback callback) {
        Map<String, String> authMap = authenticator.handleResponse(intent, clientSecret);

        if (authMap != null) {
            authenticator.getAuthService()
                    .authorize(authMap)
// Path: soundcloud-api/src/main/java/com/jlubecki/soundcloud/webapi/android/auth/models/AuthenticationResponse.java
// public class AuthenticationResponse {
// 
//     public String access_token;
// 
//     public String scope;
// 
//     public String error;
// 
//     /**
//      * Helper method to determine authentication response type.
//      *
//      * @return The type of the authentication response.
//      */
//     public ResponseType getType() {
//         if (access_token != null) {
//             return ResponseType.TOKEN;
//         }
// 
//         if (error != null) {
//             return ResponseType.ERROR;
//         }
// 
//         return ResponseType.UNKNOWN;
//     }
// 
//     public enum ResponseType {
//         TOKEN,
//         ERROR,
//         UNKNOWN
//     }
// 
//     @Override
//     public String toString() {
//         return "AuthenticationResponse{" +
//                 "access_token='" + access_token + '\'' +
//                 ", scope='" + scope + '\'' +
//                 ", error='" + error + '\'' +
//                 '}';
//     }
// }


// Path: soundcloud-api/src/main/java/com/jlubecki/soundcloud/webapi/android/auth/AuthenticationStrategy.java
import com.jlubecki.soundcloud.webapi.android.auth.models.AuthenticationResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.support.annotation.NonNull;
import android.util.Log;


    private AuthenticationStrategy(@NonNull Context context, @NonNull List<SoundCloudAuthenticator> authenticators) {
        this.context = context;
        this.authenticators = authenticators;
    }

    public boolean beginAuthentication(AuthenticationCallback callback) {
        if (shouldCheckNetwork && !networkIsConnected()) return false; // Not connected to the internet.

        for(SoundCloudAuthenticator authenticator : authenticators) {
            if(authenticator.prepareAuthenticationFlow(callback)) {
                this.authenticator = authenticator;
                return true; // Prepared successfully. Will execute callback.
            }
        }

        return false;
    }

    public boolean canAuthenticate(Intent intent) {
        return authenticator != null &&
                authenticator.canAuthenticate(intent);
    }

    public void getToken(Intent intent, String clientSecret, final ResponseCallback callback) {
        Map<String, String> authMap = authenticator.handleResponse(intent, clientSecret);

        if (authMap != null) {
            authenticator.getAuthService()
                    .authorize(authMap)
                    .enqueue(new Callback<AuthenticationResponse>() {