// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/exception/BrightpearlHttpException.java
// public class BrightpearlHttpException extends BrightpearlClientException {
// 
//     private final ClientErrorCode clientErrorCode;
// 
//     public BrightpearlHttpException(ClientErrorCode clientErrorCode) {
//         super("Brightpearl request failed: " + clientErrorCode);
//         this.clientErrorCode = clientErrorCode;
//     }
// 
//     public BrightpearlHttpException(ClientErrorCode clientErrorCode, String message) {
//         super("Brightpearl request failed: " + clientErrorCode + " (" + message + ")");
//         this.clientErrorCode = clientErrorCode;
//     }
// 
//     public BrightpearlHttpException(ClientErrorCode clientErrorCode, Exception e) {
//         super("Brightpearl request failed: " + clientErrorCode + " (" + e.getClass().getSimpleName() + ")", e);
//         this.clientErrorCode = clientErrorCode;
//     }
// 
//     public ClientErrorCode getClientErrorCode() {
//         return clientErrorCode;
//     }
// 
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/exception/ClientErrorCode.java
// public enum ClientErrorCode {
// 
//     EMPTY_RESPONSE,
//     INVALID_RESPONSE_FORMAT,
//     INVALID_RESPONSE_TYPE,
//     NO_RESPONSE,
//     UNKNOWN_HOST,
//     CONNECTION_TIMEOUT,
//     SOCKET_ERROR,
//     SOCKET_TIMEOUT,
//     READ_TIMEOUT,
//     OTHER_TRANSPORT_ERROR
// 
// }


import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import uk.co.visalia.brightpearl.apiclient.exception.BrightpearlHttpException;
import uk.co.visalia.brightpearl.apiclient.exception.ClientErrorCode;
import uk.co.visalia.brightpearl.apiclient.http.*;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;

        return clientRequest;

    }

    private HttpRequestBase createBaseRequest(Method method, String url, String body) {
        if (method == Method.GET) {
            return new HttpGet(url);
        } else if (method == Method.POST) {
            HttpPost post = new HttpPost(url);
            addBody(post, body);
            return post;
        } else if (method == Method.PUT) {
            HttpPut put = new HttpPut(url);
            addBody(put, body);
            return put;
        } else if (method == Method.DELETE) {
            return new HttpDelete(url);
        } else if (method == Method.OPTIONS) {
            return new HttpOptions(url);
        }
        throw new IllegalArgumentException("HTTP method " + method + " is not supported by this client");
    }

    private void addBody(HttpEntityEnclosingRequestBase requestBase, String body) {
        if (body != null) {
            requestBase.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
        }
    }

// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/exception/BrightpearlHttpException.java
// public class BrightpearlHttpException extends BrightpearlClientException {
// 
//     private final ClientErrorCode clientErrorCode;
// 
//     public BrightpearlHttpException(ClientErrorCode clientErrorCode) {
//         super("Brightpearl request failed: " + clientErrorCode);
//         this.clientErrorCode = clientErrorCode;
//     }
// 
//     public BrightpearlHttpException(ClientErrorCode clientErrorCode, String message) {
//         super("Brightpearl request failed: " + clientErrorCode + " (" + message + ")");
//         this.clientErrorCode = clientErrorCode;
//     }
// 
//     public BrightpearlHttpException(ClientErrorCode clientErrorCode, Exception e) {
//         super("Brightpearl request failed: " + clientErrorCode + " (" + e.getClass().getSimpleName() + ")", e);
//         this.clientErrorCode = clientErrorCode;
//     }
// 
//     public ClientErrorCode getClientErrorCode() {
//         return clientErrorCode;
//     }
// 
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/exception/ClientErrorCode.java
// public enum ClientErrorCode {
// 
//     EMPTY_RESPONSE,
//     INVALID_RESPONSE_FORMAT,
//     INVALID_RESPONSE_TYPE,
//     NO_RESPONSE,
//     UNKNOWN_HOST,
//     CONNECTION_TIMEOUT,
//     SOCKET_ERROR,
//     SOCKET_TIMEOUT,
//     READ_TIMEOUT,
//     OTHER_TRANSPORT_ERROR
// 
// }


// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/http/httpclient4/HttpClient4Client.java
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import uk.co.visalia.brightpearl.apiclient.exception.BrightpearlHttpException;
import uk.co.visalia.brightpearl.apiclient.exception.ClientErrorCode;
import uk.co.visalia.brightpearl.apiclient.http.*;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;


        return clientRequest;

    }

    private HttpRequestBase createBaseRequest(Method method, String url, String body) {
        if (method == Method.GET) {
            return new HttpGet(url);
        } else if (method == Method.POST) {
            HttpPost post = new HttpPost(url);
            addBody(post, body);
            return post;
        } else if (method == Method.PUT) {
            HttpPut put = new HttpPut(url);
            addBody(put, body);
            return put;
        } else if (method == Method.DELETE) {
            return new HttpDelete(url);
        } else if (method == Method.OPTIONS) {
            return new HttpOptions(url);
        }
        throw new IllegalArgumentException("HTTP method " + method + " is not supported by this client");
    }

    private void addBody(HttpEntityEnclosingRequestBase requestBase, String body) {
        if (body != null) {
            requestBase.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
        }
    }

    private BrightpearlHttpException resolveException(Exception e) {