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

import android.support.annotation.NonNull;
import android.util.Pair;

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 java.util.Arrays;

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 static final String ID_PARAMETER = "id";
    private static final String TYPE_PARAMETER = "type";

    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;
    }

    @NonNull
    @Override
    protected Iterable<Pair<String, ?>> getQueryParameters() {
        return Arrays.<Pair<String, ?>>asList(
                new Pair<>(ID_PARAMETER, id),
                new Pair<>(TYPE_PARAMETER, type)
        );
    }
}

@@ -110,17 +110,35 @@
 oid.
-util.Pair
+support.annotation.Nullable
 ;%0A%0Ai
@@ -441,33 +441,61 @@
 on;%0A
+%0A
 import 
-java.util.Arrays;%0A
+okhttp3.FormBody;%0Aimport okhttp3.RequestBody;
 %0Aimp
@@ -1709,139 +1709,190 @@
    @
-NonNull%0A    @Override%0A    protected Iterable%3CPair%3CString, ?%3E%3E getQueryParameters() %7B%0A        return Arrays.%3CPair%3CString, ?%3E%3EasList(
+Override%0A    protected String getMethod() %7B%0A        return POST;%0A    %7D%0A%0A    @Nullable%0A    @Override%0A    protected RequestBody getRequestBody() %7B%0A        return new FormBody.Builder()
 %0A   
@@ -1904,26 +1904,20 @@
         
-new Pair%3C%3E
+.add
 (ID_PARA
@@ -1926,17 +1926,16 @@
 TER, id)
-,
 %0A       
@@ -1947,18 +1947,12 @@
     
-new Pair%3C%3E
+.add
 (TYP
@@ -1978,16 +1978,31 @@
         
+        .build(
 );%0A    %7D

Make SetUserInfoRequest a POST request