// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/call/rest/request/GetFeedRequest.java
// public interface GetFeedRequest {
//     public final static String SEED_HIPSTER = "hipster";
// 
//     /**
//      * randomUser.me don't have page suppont, and the limit in one all is 5 users. I'm going to
//      * simulate the page system with the seed param.
//      */
//     @GET("/")
//     void getRandomUsers(@Query("results") int maxUsers,@Query("seed") int page,
//                         Callback<GetFeedResponse> callback);
// 
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/call/rest/response/GetFeedResponse.java
// public class GetFeedResponse {
//     private List<UserApiEntry> results;
// 
//     public List<UserApiEntry> getResults() {
//         return results;
//     }
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/callback/ApiResponseCallback.java
// public interface ApiResponseCallback<T> {
//     void complete(T response);
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/model/UserApiEntry.java
// public class UserApiEntry {
//     private UserApi user;
// 
//     public UserApi getUser() {
//         return user;
//     }
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/globalutils/module/LoggerProvider.java
// public class LoggerProvider {
// 
//     @Inject
//     static Logger logger;
// 
//     public LoggerProvider() {
// 
//     }
// 
//     public static Logger getLogger() {
//         return logger;
//     }
// }


import com.flipper83.protohipster.feed.datasource.api.call.rest.request.GetFeedRequest;
import com.flipper83.protohipster.feed.datasource.api.call.rest.response.GetFeedResponse;
import com.flipper83.protohipster.feed.datasource.api.callback.ApiResponseCallback;
import com.flipper83.protohipster.feed.datasource.api.model.UserApiEntry;
import com.flipper83.protohipster.globalutils.module.LoggerProvider;
import java.util.ArrayList;
import java.util.List;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
package com.flipper83.protohipster.feed.datasource.api.call.rest;




/**
 * Api Call to request
 */
public class GetFeedCall extends ApiRestCall implements Callback<GetFeedResponse> {
    private static final int MAX_USERS = 5;
    private static final String LOGTAG = "GetFeedCall";
    private List<UserApiEntry> responseBuffer = new ArrayList<UserApiEntry>();
    private GetFeedRequest request;
    private int page;

    public GetFeedCall(ApiResponseCallback<List<UserApiEntry>> apiResponseCallback) {
        super(apiResponseCallback);
    }

    @Override
    public void call(RestAdapter restAdapter) {
        page = 0;
        responseBuffer.clear();

        request = restAdapter.create(GetFeedRequest.class);
        request.getRandomUsers(MAX_USERS, page, this);
    }

    @Override
    public void success(GetFeedResponse apiUsers, Response response) {
        responseBuffer.addAll(apiUsers.getResults());
        if (responseBuffer.size() >= MAX_USERS) {
            super.responseCallback.complete(responseBuffer);
        } else {
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/call/rest/request/GetFeedRequest.java
// public interface GetFeedRequest {
//     public final static String SEED_HIPSTER = "hipster";
// 
//     /**
//      * randomUser.me don't have page suppont, and the limit in one all is 5 users. I'm going to
//      * simulate the page system with the seed param.
//      */
//     @GET("/")
//     void getRandomUsers(@Query("results") int maxUsers,@Query("seed") int page,
//                         Callback<GetFeedResponse> callback);
// 
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/call/rest/response/GetFeedResponse.java
// public class GetFeedResponse {
//     private List<UserApiEntry> results;
// 
//     public List<UserApiEntry> getResults() {
//         return results;
//     }
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/callback/ApiResponseCallback.java
// public interface ApiResponseCallback<T> {
//     void complete(T response);
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/model/UserApiEntry.java
// public class UserApiEntry {
//     private UserApi user;
// 
//     public UserApi getUser() {
//         return user;
//     }
// }
// 
// Path: protohipster/src/main/java/com/flipper83/protohipster/globalutils/module/LoggerProvider.java
// public class LoggerProvider {
// 
//     @Inject
//     static Logger logger;
// 
//     public LoggerProvider() {
// 
//     }
// 
//     public static Logger getLogger() {
//         return logger;
//     }
// }


// Path: protohipster/src/main/java/com/flipper83/protohipster/feed/datasource/api/call/rest/GetFeedCall.java
import com.flipper83.protohipster.feed.datasource.api.call.rest.request.GetFeedRequest;
import com.flipper83.protohipster.feed.datasource.api.call.rest.response.GetFeedResponse;
import com.flipper83.protohipster.feed.datasource.api.callback.ApiResponseCallback;
import com.flipper83.protohipster.feed.datasource.api.model.UserApiEntry;
import com.flipper83.protohipster.globalutils.module.LoggerProvider;
import java.util.ArrayList;
import java.util.List;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;

package com.flipper83.protohipster.feed.datasource.api.call.rest;




/**
 * Api Call to request
 */
public class GetFeedCall extends ApiRestCall implements Callback<GetFeedResponse> {
    private static final int MAX_USERS = 5;
    private static final String LOGTAG = "GetFeedCall";
    private List<UserApiEntry> responseBuffer = new ArrayList<UserApiEntry>();
    private GetFeedRequest request;
    private int page;

    public GetFeedCall(ApiResponseCallback<List<UserApiEntry>> apiResponseCallback) {
        super(apiResponseCallback);
    }

    @Override
    public void call(RestAdapter restAdapter) {
        page = 0;
        responseBuffer.clear();

        request = restAdapter.create(GetFeedRequest.class);
        request.getRandomUsers(MAX_USERS, page, this);
    }

    @Override
    public void success(GetFeedResponse apiUsers, Response response) {
        responseBuffer.addAll(apiUsers.getResults());
        if (responseBuffer.size() >= MAX_USERS) {
            super.responseCallback.complete(responseBuffer);
        } else {
            page++;