// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java
// public abstract class AppDotNetRequest {
//     public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
//     public static final String CONTENT_TYPE_JSON = "application/json";
// 
//     protected static final String HEADER_CONTENT_TYPE = "Content-Type";
//     protected static final Gson gson = AppDotNetGson.getInstance();
// 
//     private static final String TAG = "AppDotNetRequest";
// 
//     protected URL url;
//     protected AppDotNetResponseHandler handler;
//     protected boolean authenticated;
//     protected String method;
//     protected boolean hasBody = false; // if true, writeBody will be called
// 
//     private String fixedLengthBody; // may be unused even if hasBody is true, e.g. image upload
// 
//     protected AppDotNetRequest(AppDotNetResponseHandler handler, boolean authenticated, String requestMethod, QueryParameters queryParameters,
//                                Uri baseUri, String... pathComponents) {
//         this.handler = handler;
//         this.authenticated = authenticated;
//         method = requestMethod;
//         url = buildUrl(baseUri, queryParameters, pathComponents);
//     }
// 
//     public URL getUrl() {
//         return url;
//     }
// 
//     public AppDotNetResponseHandler getHandler() {
//         return handler;
//     }
// 
//     public boolean isAuthenticated() {
//         return authenticated;
//     }
// 
//     public String getMethod() {
//         return method;
//     }
// 
//     public boolean hasBody() {
//         return hasBody;
//     }
// 
//     protected URL buildUrl(Uri baseUri, QueryParameters queryParameters, String... pathComponents) {
//         final Uri.Builder builder = baseUri.buildUpon();
// 
//         // concatenate path components together
//         for (String pathComponent : pathComponents) {
//             builder.appendEncodedPath(pathComponent);
//         }
// 
//         if (queryParameters != null) {
//             // add all specified parameters to query string
//             for (Map.Entry<String, String> entry : queryParameters.entrySet()) {
//                 builder.appendQueryParameter(entry.getKey(), entry.getValue());
//             }
//         }
// 
//         try {
//             return new URL(builder.toString());
//         } catch (MalformedURLException e) {
//             Log.e(TAG, "Failed to construct URL", e);
//             handler.onError(e);
//             return null;
//         }
//     }
// 
//     protected void setBody(String body) {
//         fixedLengthBody = body;
//         hasBody = true;
//     }
// 
//     public abstract void writeBody(HttpURLConnection connection) throws IOException;
// 
//     protected void writeFixedLengthBody(HttpURLConnection connection) throws IOException {
//         final byte[] bodyBytes = fixedLengthBody.getBytes("UTF-8");
//         connection.setFixedLengthStreamingMode(bodyBytes.length);
// 
//         final OutputStream outputStream = connection.getOutputStream();
//         outputStream.write(bodyBytes);
//         outputStream.close();
//     }
// }
// 
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java
// public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> {
//     private static final String TAG = "AppDotNetResponseHandler";
// 
//     private final Gson gson;
//     private final Type responseType;
// 
//     // subclasses must call this constructor and initialize responseType since there is no default constructor
//     protected AppDotNetResponseHandler(TypeToken typeToken) {
//         gson = AppDotNetGson.getInstance();
//         responseType = typeToken.getType();
//     }
// 
//     protected <T> T parseResponse(Reader reader) {
//         return gson.fromJson(reader, responseType);
//     }
// 
//     public abstract void handleResponse(Reader reader);
// 
//     public abstract void onSuccess(T responseData);
// 
//     public void onError(Exception error) {
//         Log.e(TAG, error.getMessage(), error);
//     }
// }


import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.util.Log;
import com.alwaysallthetime.adnlib.request.AppDotNetRequest;
import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
package com.alwaysallthetime.adnlib;





class AppDotNetClientTask extends AsyncTask<AppDotNetRequest, Void, Integer> {
    private static final String TAG = "AppDotNetClientTask";

    private final String authorizationHeader;
    private final String languageHeader;
    private final SSLSocketFactory sslSocketFactory;
    private final Context context;

    public AppDotNetClientTask(Context context, String authorizationHeader, String languageHeader, SSLSocketFactory sslSocketFactory) {
        this.context = context;
        this.authorizationHeader = authorizationHeader;
        this.languageHeader = languageHeader;
        this.sslSocketFactory = sslSocketFactory;
    }

    public AppDotNetClientTask(Context context, String authorizationHeader, SSLSocketFactory sslSocketFactory) {
        this(context, authorizationHeader, null, sslSocketFactory);
    }

    public AppDotNetClientTask(Context context, String authorizationHeader) {
        this(context, authorizationHeader, null);
    }

    @Override
    protected Integer doInBackground(AppDotNetRequest... requests) {
        //the number of requests is always 1
        AppDotNetRequest request = requests[0];

// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java
// public abstract class AppDotNetRequest {
//     public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
//     public static final String CONTENT_TYPE_JSON = "application/json";
// 
//     protected static final String HEADER_CONTENT_TYPE = "Content-Type";
//     protected static final Gson gson = AppDotNetGson.getInstance();
// 
//     private static final String TAG = "AppDotNetRequest";
// 
//     protected URL url;
//     protected AppDotNetResponseHandler handler;
//     protected boolean authenticated;
//     protected String method;
//     protected boolean hasBody = false; // if true, writeBody will be called
// 
//     private String fixedLengthBody; // may be unused even if hasBody is true, e.g. image upload
// 
//     protected AppDotNetRequest(AppDotNetResponseHandler handler, boolean authenticated, String requestMethod, QueryParameters queryParameters,
//                                Uri baseUri, String... pathComponents) {
//         this.handler = handler;
//         this.authenticated = authenticated;
//         method = requestMethod;
//         url = buildUrl(baseUri, queryParameters, pathComponents);
//     }
// 
//     public URL getUrl() {
//         return url;
//     }
// 
//     public AppDotNetResponseHandler getHandler() {
//         return handler;
//     }
// 
//     public boolean isAuthenticated() {
//         return authenticated;
//     }
// 
//     public String getMethod() {
//         return method;
//     }
// 
//     public boolean hasBody() {
//         return hasBody;
//     }
// 
//     protected URL buildUrl(Uri baseUri, QueryParameters queryParameters, String... pathComponents) {
//         final Uri.Builder builder = baseUri.buildUpon();
// 
//         // concatenate path components together
//         for (String pathComponent : pathComponents) {
//             builder.appendEncodedPath(pathComponent);
//         }
// 
//         if (queryParameters != null) {
//             // add all specified parameters to query string
//             for (Map.Entry<String, String> entry : queryParameters.entrySet()) {
//                 builder.appendQueryParameter(entry.getKey(), entry.getValue());
//             }
//         }
// 
//         try {
//             return new URL(builder.toString());
//         } catch (MalformedURLException e) {
//             Log.e(TAG, "Failed to construct URL", e);
//             handler.onError(e);
//             return null;
//         }
//     }
// 
//     protected void setBody(String body) {
//         fixedLengthBody = body;
//         hasBody = true;
//     }
// 
//     public abstract void writeBody(HttpURLConnection connection) throws IOException;
// 
//     protected void writeFixedLengthBody(HttpURLConnection connection) throws IOException {
//         final byte[] bodyBytes = fixedLengthBody.getBytes("UTF-8");
//         connection.setFixedLengthStreamingMode(bodyBytes.length);
// 
//         final OutputStream outputStream = connection.getOutputStream();
//         outputStream.write(bodyBytes);
//         outputStream.close();
//     }
// }
// 
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java
// public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> {
//     private static final String TAG = "AppDotNetResponseHandler";
// 
//     private final Gson gson;
//     private final Type responseType;
// 
//     // subclasses must call this constructor and initialize responseType since there is no default constructor
//     protected AppDotNetResponseHandler(TypeToken typeToken) {
//         gson = AppDotNetGson.getInstance();
//         responseType = typeToken.getType();
//     }
// 
//     protected <T> T parseResponse(Reader reader) {
//         return gson.fromJson(reader, responseType);
//     }
// 
//     public abstract void handleResponse(Reader reader);
// 
//     public abstract void onSuccess(T responseData);
// 
//     public void onError(Exception error) {
//         Log.e(TAG, error.getMessage(), error);
//     }
// }


// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetClientTask.java
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.util.Log;
import com.alwaysallthetime.adnlib.request.AppDotNetRequest;
import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;

package com.alwaysallthetime.adnlib;





class AppDotNetClientTask extends AsyncTask<AppDotNetRequest, Void, Integer> {
    private static final String TAG = "AppDotNetClientTask";

    private final String authorizationHeader;
    private final String languageHeader;
    private final SSLSocketFactory sslSocketFactory;
    private final Context context;

    public AppDotNetClientTask(Context context, String authorizationHeader, String languageHeader, SSLSocketFactory sslSocketFactory) {
        this.context = context;
        this.authorizationHeader = authorizationHeader;
        this.languageHeader = languageHeader;
        this.sslSocketFactory = sslSocketFactory;
    }

    public AppDotNetClientTask(Context context, String authorizationHeader, SSLSocketFactory sslSocketFactory) {
        this(context, authorizationHeader, null, sslSocketFactory);
    }

    public AppDotNetClientTask(Context context, String authorizationHeader) {
        this(context, authorizationHeader, null);
    }

    @Override
    protected Integer doInBackground(AppDotNetRequest... requests) {
        //the number of requests is always 1
        AppDotNetRequest request = requests[0];

        final AppDotNetResponseHandler handler = request.getHandler();