// Path: src/main/java/com/cardinity/Cardinity.java
// public abstract class Cardinity {
// 
//     public static final String API_BASE = "https://api.cardinity.com";
//     public static final String API_VERSION = "v1";
//     public static final String VERSION = "0.1";
//     public static final String ENCODING_CHARSET = "UTF-8";
// 
// }
// 
// Path: src/main/java/com/cardinity/exceptions/CardinityClientException.java
// public class CardinityClientException extends CardinityException {
// 
//     private static final long serialVersionUID = 5273072716090618133L;
// 
//     public CardinityClientException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/com/cardinity/model/CardinityError.java
// public class CardinityError {
// 
//     private String type;
//     private String title;
//     private Integer status;
//     private String detail;
//     private Set<ErrorItem> errors;
// 
//     public String getType() {
//         return type;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public Integer getStatus() {
//         return status;
//     }
// 
//     public String getDetail() {
//         return detail;
//     }
// 
//     public Set<ErrorItem> getErrorItems() {
//         return errors;
//     }
// 
// }
// 
// Path: src/main/java/com/cardinity/model/Response.java
// public class Response {
// 
//     private final Integer code;
//     private final String body;
// 
//     public Response(Integer code, String body) {
//         this.code = code;
//         this.body = body;
//     }
// 
//     public Integer getCode() {
//         return code;
//     }
// 
//     public String getBody() {
//         return body;
//     }
// }
// 
// Path: src/main/java/com/cardinity/model/Result.java
// public class Result<T> {
// 
//     private T item;
//     private CardinityError cardinityError;
// 
//     public Result(T item) {
//         this.item = item;
//     }
// 
//     public Result(CardinityError cardinityError) {
//         this.cardinityError = cardinityError;
//     }
// 
//     public T getItem() {
//         return item;
//     }
// 
//     public CardinityError getCardinityError() {
//         return cardinityError;
//     }
// 
//     public boolean isValid() {
//         return item != null;
//     }
// }
// 
// Path: src/main/java/com/cardinity/oauth/OAuthProvider.java
// public interface OAuthProvider {
// 
//     String buildAuthorizationHeader(RestResource.RequestMethod requestMethod, String requestUrl) throws
//             GeneralSecurityException, UnsupportedEncodingException;
// 
//     String buildAuthorizationHeader(RestResource.RequestMethod requestMethod, String requestUrl, Map<String, String>
//             params) throws
//             GeneralSecurityException, UnsupportedEncodingException;
// 
// }
// 
// Path: src/main/java/com/cardinity/rest/RestResource.java
// public enum RequestMethod {
//     GET, PATCH, POST
// }


import com.cardinity.Cardinity;
import com.cardinity.exceptions.CardinityClientException;
import com.cardinity.model.CardinityError;
import com.cardinity.model.Response;
import com.cardinity.model.Result;
import com.cardinity.oauth.OAuthProvider;
import com.cardinity.rest.RestResource.RequestMethod;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
        try {
            switch (method) {
                case GET:
                    conn = createGetConnection(url, params, oAuthProvider.buildAuthorizationHeader(method, url,
                            params));
                    break;
                case POST:
                    conn = createPostPatchConnection(url, buildRequestBody(requestObject), true, oAuthProvider
                            .buildAuthorizationHeader(method, url));
                    break;
                case PATCH:
                    conn = createPostPatchConnection(url, buildRequestBody(requestObject), false, oAuthProvider
                            .buildAuthorizationHeader(method, url));
                    break;
                default:
                    throw new CardinityClientException("Unrecognized HTTP request type.");
            }

            int responseCode = conn.getResponseCode();
            String responseBody;

            if (responseCode >= 200 && responseCode < 300) {
                responseBody = getResponseBody(conn.getInputStream());
            } else {
                responseBody = getResponseBody(conn.getErrorStream());
            }

            return new Response(responseCode, responseBody);

        } catch (UnsupportedEncodingException e) {
// Path: src/main/java/com/cardinity/Cardinity.java
// public abstract class Cardinity {
// 
//     public static final String API_BASE = "https://api.cardinity.com";
//     public static final String API_VERSION = "v1";
//     public static final String VERSION = "0.1";
//     public static final String ENCODING_CHARSET = "UTF-8";
// 
// }
// 
// Path: src/main/java/com/cardinity/exceptions/CardinityClientException.java
// public class CardinityClientException extends CardinityException {
// 
//     private static final long serialVersionUID = 5273072716090618133L;
// 
//     public CardinityClientException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/com/cardinity/model/CardinityError.java
// public class CardinityError {
// 
//     private String type;
//     private String title;
//     private Integer status;
//     private String detail;
//     private Set<ErrorItem> errors;
// 
//     public String getType() {
//         return type;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public Integer getStatus() {
//         return status;
//     }
// 
//     public String getDetail() {
//         return detail;
//     }
// 
//     public Set<ErrorItem> getErrorItems() {
//         return errors;
//     }
// 
// }
// 
// Path: src/main/java/com/cardinity/model/Response.java
// public class Response {
// 
//     private final Integer code;
//     private final String body;
// 
//     public Response(Integer code, String body) {
//         this.code = code;
//         this.body = body;
//     }
// 
//     public Integer getCode() {
//         return code;
//     }
// 
//     public String getBody() {
//         return body;
//     }
// }
// 
// Path: src/main/java/com/cardinity/model/Result.java
// public class Result<T> {
// 
//     private T item;
//     private CardinityError cardinityError;
// 
//     public Result(T item) {
//         this.item = item;
//     }
// 
//     public Result(CardinityError cardinityError) {
//         this.cardinityError = cardinityError;
//     }
// 
//     public T getItem() {
//         return item;
//     }
// 
//     public CardinityError getCardinityError() {
//         return cardinityError;
//     }
// 
//     public boolean isValid() {
//         return item != null;
//     }
// }
// 
// Path: src/main/java/com/cardinity/oauth/OAuthProvider.java
// public interface OAuthProvider {
// 
//     String buildAuthorizationHeader(RestResource.RequestMethod requestMethod, String requestUrl) throws
//             GeneralSecurityException, UnsupportedEncodingException;
// 
//     String buildAuthorizationHeader(RestResource.RequestMethod requestMethod, String requestUrl, Map<String, String>
//             params) throws
//             GeneralSecurityException, UnsupportedEncodingException;
// 
// }
// 
// Path: src/main/java/com/cardinity/rest/RestResource.java
// public enum RequestMethod {
//     GET, PATCH, POST
// }


// Path: src/main/java/com/cardinity/rest/CardinityRestClient.java
import com.cardinity.Cardinity;
import com.cardinity.exceptions.CardinityClientException;
import com.cardinity.model.CardinityError;
import com.cardinity.model.Response;
import com.cardinity.model.Result;
import com.cardinity.oauth.OAuthProvider;
import com.cardinity.rest.RestResource.RequestMethod;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

        try {
            switch (method) {
                case GET:
                    conn = createGetConnection(url, params, oAuthProvider.buildAuthorizationHeader(method, url,
                            params));
                    break;
                case POST:
                    conn = createPostPatchConnection(url, buildRequestBody(requestObject), true, oAuthProvider
                            .buildAuthorizationHeader(method, url));
                    break;
                case PATCH:
                    conn = createPostPatchConnection(url, buildRequestBody(requestObject), false, oAuthProvider
                            .buildAuthorizationHeader(method, url));
                    break;
                default:
                    throw new CardinityClientException("Unrecognized HTTP request type.");
            }

            int responseCode = conn.getResponseCode();
            String responseBody;

            if (responseCode >= 200 && responseCode < 300) {
                responseBody = getResponseBody(conn.getInputStream());
            } else {
                responseBody = getResponseBody(conn.getErrorStream());
            }

            return new Response(responseCode, responseBody);

        } catch (UnsupportedEncodingException e) {
            throw new CardinityClientException("UnsupportedEncodingException: failed to encode data in ." + Cardinity