package com.proxerme.library.connection.info.request;

import android.support.annotation.NonNull;

import com.proxerme.library.connection.ProxerResult;
import com.proxerme.library.connection.info.InfoRequest;
import com.proxerme.library.connection.info.result.SetUserInfoResult;
import com.proxerme.library.parameters.ViewStateParameter;
import com.squareup.moshi.Moshi;

import java.io.IOException;

import okhttp3.ResponseBody;

/**
 * Request to set the user view state of an anime or manga. See the list of possible user view states.
 *
 * @author Desnoo
 */
public class SetUserInfoRequest extends InfoRequest<Void> {

    private static final String ENDPOINT = "setuserinfo";

    private String id;
    private String type;

    /**
     * The Constructor.
     *
     * @param id   The id of the anime/manga.
     * @param type The list type where the anime/manga should be add to.
     *             See {@link com.proxerme.library.parameters.ViewStateParameter.ViewState} for parameters.
     */
    public SetUserInfoRequest(@NonNull String id, @ViewStateParameter.ViewState String type) {
        this.id = id;
        this.type = type;
    }

    @Override
    protected ProxerResult<Void> parse(@NonNull Moshi moshi, @NonNull ResponseBody body) throws IOException {
        return moshi.adapter(SetUserInfoResult.class).fromJson(body.source());
    }

    @NonNull
    @Override
    protected String getApiEndpoint() {
        return ENDPOINT;
    }
}

@@ -90,16 +90,42 @@
 NonNull;
+%0Aimport android.util.Pair;
 %0A%0Aimport
@@ -418,16 +418,41 @@
 ception;
+%0Aimport java.util.Arrays;
 %0A%0Aimport
@@ -727,16 +727,127 @@
 info%22;%0A%0A
+    private static final String ID_PARAMETER = %22id%22;%0A    private static final String TYPE_PARAMETER = %22type%22;%0A%0A
     priv
@@ -1584,24 +1584,24 @@
 ndpoint() %7B%0A
-
         retu
@@ -1618,11 +1618,261 @@
 T;%0A    %7D
+%0A%0A    @NonNull%0A    @Override%0A    protected Iterable%3CPair%3CString, ?%3E%3E getQueryParameters() %7B%0A        return Arrays.%3CPair%3CString, ?%3E%3EasList(%0A                new Pair%3C%3E(ID_PARAMETER, id),%0A                new Pair%3C%3E(TYPE_PARAMETER, type)%0A        );%0A    %7D
 %0A%7D%0A

Add of request parameter of SetUserInfoRequest