// Path: src/com/textrazor/AnalysisException.java
// public class AnalysisException extends Exception {
// 	private static final long serialVersionUID = 9063173251339905559L;
// 	
// 	private int responseCode;
//     private String responseBody;
// 
//     public AnalysisException(int responseCode, String responseBody) {
//         this.responseBody = responseBody;
//         this.responseCode = responseCode;
//     }
// 
//     @Override
//     public String getMessage() {
//         return String.format("TextRazor returned HTTP Code %d with response: %s", responseCode, responseBody);
//     }
// 
//     public String getResponseBody() {
//         return responseBody;
//     }
//     
//     public int getResponseCode() {
//         return responseCode;
//     }
// }
// 
// Path: src/com/textrazor/NetworkException.java
// public class NetworkException extends IOException {
//     
// 	private static final long serialVersionUID = -821976320048704953L;
// 
// 	public NetworkException(String message, Throwable cause) {
//         super(message);
//         initCause(cause);
//     }
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.textrazor.AnalysisException;
import com.textrazor.NetworkException;
package com.textrazor.net;



public class TextRazorConnection {
	
	protected enum ContentType {
		FORM, JSON, CSV
	}
	
	private String apiKey;

	private String textrazorEndpoint;
	private String secureTextrazorEndpoint;
	
	private boolean doCompression;
	private boolean doEncryption;
	
	private Proxy proxy = null;
	
	public TextRazorConnection(String apiKey) {
		if (apiKey == null) {
			throw new RuntimeException("You must provide a TextRazor API key");
		}
		
		this.apiKey = apiKey;

		this.textrazorEndpoint = "http://api.textrazor.com/";
		this.secureTextrazorEndpoint = "https://api.textrazor.com/";
		
		this.doEncryption = true;
		this.doCompression = true;
	}
	
	protected <ResponseType> ResponseType sendRequest(
			String path, 
			String requestBody,
			ContentType contentType,
			String method, 
// Path: src/com/textrazor/AnalysisException.java
// public class AnalysisException extends Exception {
// 	private static final long serialVersionUID = 9063173251339905559L;
// 	
// 	private int responseCode;
//     private String responseBody;
// 
//     public AnalysisException(int responseCode, String responseBody) {
//         this.responseBody = responseBody;
//         this.responseCode = responseCode;
//     }
// 
//     @Override
//     public String getMessage() {
//         return String.format("TextRazor returned HTTP Code %d with response: %s", responseCode, responseBody);
//     }
// 
//     public String getResponseBody() {
//         return responseBody;
//     }
//     
//     public int getResponseCode() {
//         return responseCode;
//     }
// }
// 
// Path: src/com/textrazor/NetworkException.java
// public class NetworkException extends IOException {
//     
// 	private static final long serialVersionUID = -821976320048704953L;
// 
// 	public NetworkException(String message, Throwable cause) {
//         super(message);
//         initCause(cause);
//     }
// }


// Path: src/com/textrazor/net/TextRazorConnection.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.textrazor.AnalysisException;
import com.textrazor.NetworkException;

package com.textrazor.net;



public class TextRazorConnection {
	
	protected enum ContentType {
		FORM, JSON, CSV
	}
	
	private String apiKey;

	private String textrazorEndpoint;
	private String secureTextrazorEndpoint;
	
	private boolean doCompression;
	private boolean doEncryption;
	
	private Proxy proxy = null;
	
	public TextRazorConnection(String apiKey) {
		if (apiKey == null) {
			throw new RuntimeException("You must provide a TextRazor API key");
		}
		
		this.apiKey = apiKey;

		this.textrazorEndpoint = "http://api.textrazor.com/";
		this.secureTextrazorEndpoint = "https://api.textrazor.com/";
		
		this.doEncryption = true;
		this.doCompression = true;
	}
	
	protected <ResponseType> ResponseType sendRequest(
			String path, 
			String requestBody,
			ContentType contentType,
			String method, 
			Class<ResponseType> responseClass) throws AnalysisException, NetworkException {