package com.cloudmine.api.rest;

import android.os.Handler;
import com.android.volley.NetworkResponse;
import com.android.volley.Response;
import com.cloudmine.api.CMSessionToken;
import com.cloudmine.api.rest.options.CMServerFunction;
import com.cloudmine.api.rest.response.CMObjectResponse;
import me.cloudmine.annotations.Expand;
import me.cloudmine.annotations.Optional;
import me.cloudmine.annotations.Single;

import java.util.Collection;

/**
 * <br>
 * Copyright CloudMine LLC. All rights reserved<br>
 * See LICENSE file included with SDK for details.
 */
public class BaseObjectLoadRequest extends CloudMineRequest<CMObjectResponse> {

    public static final int REQUEST_TYPE = 402;
    static final String BASE_ENDPOINT = "/text";
    static final CMURLBuilder BASE_URL = new CMURLBuilder(BASE_ENDPOINT, true);

    @Expand
    public BaseObjectLoadRequest(@Single @Optional Collection<String> objectIds, @Optional CMSessionToken sessionToken, @Optional CMServerFunction serverFunction, Response.Listener<CMObjectResponse> successListener, @Optional Response.ErrorListener errorListener) {
        this(BASE_URL.copy().objectIds(objectIds), sessionToken, serverFunction, successListener, errorListener);
    }

    @Expand
    public BaseObjectLoadRequest(@Single @Optional Collection<String> objectIds, @Optional CMSessionToken sessionToken, @Optional CMServerFunction serverFunction, Handler handler) {
        this(BASE_URL.copy().objectIds(objectIds), sessionToken, serverFunction, null, null);
        setHandler(handler);
    }

    BaseObjectLoadRequest(CMURLBuilder url, CMSessionToken sessionToken, CMServerFunction serverFunction, Response.Listener<CMObjectResponse> successListener, Response.ErrorListener errorListener) {
        super(Method.GET, url.user(sessionToken), sessionToken, serverFunction, successListener, errorListener);
    }

    @Override
    protected Response<CMObjectResponse> parseNetworkResponse(NetworkResponse networkResponse) {
        return Response.success(new CMObjectResponse(new String(networkResponse.data), networkResponse.statusCode), getCacheEntry(networkResponse));
    }

    @Override
    public int getRequestType() {
        return REQUEST_TYPE;
    }
}

@@ -30,35 +30,8 @@
 t;%0A%0A
-import android.os.Handler;%0A
 impo
@@ -416,16 +416,59 @@
 n;%0A%0A/**%0A
+ * A Request for loading CloudMine objects%0A
  * %3Cbr%3E%0A
@@ -833,16 +833,398 @@
 true);%0A%0A
+    /**%0A     * Create a new BaseObjectLoadRequest that loads the objects specified by the ids%0A     * @param objectIds The objectIds to load. If null, all objects will be loaded%0A     * @param sessionToken an optional sessionToken. If present, the objects will be loaded at the user level%0A     * @param serverFunction%0A     * @param successListener%0A     * @param errorListener%0A     */%0A
     @Exp
@@ -1618,332 +1618,8 @@
  %7D%0A%0A
-    @Expand%0A    public BaseObjectLoadRequest(@Single @Optional Collection%3CString%3E objectIds, @Optional CMSessionToken sessionToken, @Optional CMServerFunction serverFunction, Handler handler) %7B%0A        this(BASE_URL.copy().objectIds(objectIds), sessionToken, serverFunction, null, null);%0A        setHandler(handler);%0A    %7D%0A%0A
     

Comment ObjectLoadRequest