// Path: src/main/java/com/upnext/blekit/util/L.java
// public class L {
// 
//     /**
//      * Set to true if you want to see debug messages associated with this library
//      */
//     public static final boolean DEBUG_ENABLED = false;
// 
//     private static final String APP_NAME = "BLEKIT";
// 
//     public static void d( String msg ) {
//         debug(  msg );
//     }
// 
//     public static void d( Object obj ) {
//         if( obj != null )
//             debug( obj.toString() );
//     }
// 
//     public static void e( String msg ) {
//         Log.e(APP_NAME, msg);
//     }
// 
//     public static void e( String msg, Exception e ) {
//         Log.e( APP_NAME, msg, e );
//     }
// 
//     private static void debug( String msg ) {
//         if( DEBUG_ENABLED ) {
//             StackTraceElement[] els = Thread.currentThread().getStackTrace();
//             String className = els[4].getClassName();
//             className = className.substring( className.lastIndexOf( "." )+1 );
//             Log.d( APP_NAME, "[" + className + "." + els[4].getMethodName() + "] " + msg );
//         }
//     }
// 
// }


import com.upnext.blekit.util.L;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Map;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
        }

        try {
            String payloadString = objectMapper.writeValueAsString(payload);
            return fetchResponse(clazz, path, params, "POST", payloadString, "application/json;charset=UTF-8");

        } catch (JsonProcessingException e) {
            return new Response<T>(Error.serlizerError(e));
        }
    }

    public <T> Response<T> put(Class<T> clazz, String path, Map<String, String> params) {
        return fetchResponse(clazz, path, params, "PUT");
    }

    public <T> Response<T> delete(Class<T> clazz, String path, Map<String, String> params) {
        return fetchResponse(clazz, path, params, "DELETE");
    }

    public <T> Response<T> fetchResponse(Class<T> clazz, String path, Map<String, String> params, String httpMethod) {
        return fetchResponse(clazz, path, params, httpMethod, null);
    }

    public <T> Response<T> fetchResponse(Class<T> clazz, String path, Map<String, String> params, String httpMethod, String payload) {
        return fetchResponse(clazz, path, params, httpMethod, payload, "application/x-www-form-urlencoded;charset=UTF-8");
    }

    public <T> Response<T> fetchResponse(Class<T> clazz, String path, Map<String, String> params, String httpMethod, String payload, String payloadContentType) {
        try {
            String fullUrl = urlWithParams(path != null ? url + path : url, params);
// Path: src/main/java/com/upnext/blekit/util/L.java
// public class L {
// 
//     /**
//      * Set to true if you want to see debug messages associated with this library
//      */
//     public static final boolean DEBUG_ENABLED = false;
// 
//     private static final String APP_NAME = "BLEKIT";
// 
//     public static void d( String msg ) {
//         debug(  msg );
//     }
// 
//     public static void d( Object obj ) {
//         if( obj != null )
//             debug( obj.toString() );
//     }
// 
//     public static void e( String msg ) {
//         Log.e(APP_NAME, msg);
//     }
// 
//     public static void e( String msg, Exception e ) {
//         Log.e( APP_NAME, msg, e );
//     }
// 
//     private static void debug( String msg ) {
//         if( DEBUG_ENABLED ) {
//             StackTraceElement[] els = Thread.currentThread().getStackTrace();
//             String className = els[4].getClassName();
//             className = className.substring( className.lastIndexOf( "." )+1 );
//             Log.d( APP_NAME, "[" + className + "." + els[4].getMethodName() + "] " + msg );
//         }
//     }
// 
// }


// Path: src/main/java/com/upnext/blekit/util/http/HttpClient.java
import com.upnext.blekit.util.L;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Map;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

        }

        try {
            String payloadString = objectMapper.writeValueAsString(payload);
            return fetchResponse(clazz, path, params, "POST", payloadString, "application/json;charset=UTF-8");

        } catch (JsonProcessingException e) {
            return new Response<T>(Error.serlizerError(e));
        }
    }

    public <T> Response<T> put(Class<T> clazz, String path, Map<String, String> params) {
        return fetchResponse(clazz, path, params, "PUT");
    }

    public <T> Response<T> delete(Class<T> clazz, String path, Map<String, String> params) {
        return fetchResponse(clazz, path, params, "DELETE");
    }

    public <T> Response<T> fetchResponse(Class<T> clazz, String path, Map<String, String> params, String httpMethod) {
        return fetchResponse(clazz, path, params, httpMethod, null);
    }

    public <T> Response<T> fetchResponse(Class<T> clazz, String path, Map<String, String> params, String httpMethod, String payload) {
        return fetchResponse(clazz, path, params, httpMethod, payload, "application/x-www-form-urlencoded;charset=UTF-8");
    }

    public <T> Response<T> fetchResponse(Class<T> clazz, String path, Map<String, String> params, String httpMethod, String payload, String payloadContentType) {
        try {
            String fullUrl = urlWithParams(path != null ? url + path : url, params);
            L.d("[" + httpMethod + "] " + fullUrl);