package com.alwaysallthetime.adnlib.request;

import com.alwaysallthetime.adnlib.QueryParameters;
import com.alwaysallthetime.adnlib.data.IAppDotNetObject;
import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler;

import java.io.IOException;
import java.net.HttpURLConnection;

public class AppDotNetApiJsonRequest extends AppDotNetApiRequest {
    public AppDotNetApiJsonRequest(AppDotNetResponseHandler handler, String requestMethod, IAppDotNetObject body,
                                   QueryParameters queryParameters, String... pathComponents) {
        super(handler, requestMethod, queryParameters, pathComponents);

        if (body == null)
            throw new IllegalArgumentException("body cannot be null");

        setBody(gson.toJson(body));
    }

    public AppDotNetApiJsonRequest(AppDotNetResponseHandler handler, IAppDotNetObject body, QueryParameters queryParameters,
                                   String... pathComponents) {
        this(handler, "POST", body, queryParameters, pathComponents);
    }

    @Override
    public void writeBody(HttpURLConnection connection) throws IOException {
        connection.setRequestProperty(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON);
        writeFixedLengthBody(connection);
    }
}
@@ -282,16 +282,38 @@
 nection;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -793,24 +793,452 @@
 y));%0A    %7D%0A%0A
+    public AppDotNetApiJsonRequest(AppDotNetResponseHandler handler, String requestMethod, Map%3CString, Object%3E body, QueryParameters queryParameters,%0A                                   String... pathComponents) %7B%0A        super(handler, requestMethod, queryParameters, pathComponents);%0A%0A        if (body == null)%0A            throw new IllegalArgumentException(%22body cannot be null%22);%0A%0A        setBody(gson.toJson(body));%0A    %7D%0A%0A%0A
     public A

support a map body