// Path: src/main/java/com/lookfirst/wepay/api/Token.java
// @Data
// public class Token implements Serializable {
// 	private static final long serialVersionUID = 1L;
// 
// 	/** The unique user ID of the user */
// 	private String userId;
// 	/** The access token that you can use to make calls on behalf of the user */
// 	private String accessToken;
// 	/** The token type - for now only "BEARER" is supported */
// 	private String tokenType;
// 	/** How much time till the access_token expires. If NULL or not present, the access token will be valid until the user revokes the access_token */
// 	private String expiresIn;
// }
// 
// Path: src/main/java/com/lookfirst/wepay/api/req/TokenRequest.java
// @Data
// @EqualsAndHashCode(callSuper=false)
// public class TokenRequest extends WePayRequest<Token> {
// 
// 	public static final String ENDPOINT = "/oauth2/token";
// 
// 	/** Yes	The client ID issued to the app by WePay - see your client ID on your app screen */
// 	private Long clientId;
// 	/** Yes	The uri the user will be redirected to after authorization. Must be the same as passed in /v2/oauth2/authorize */
// 	private String redirectUri;
// 	/** Yes	The client secret issued to the app by WePay - see your client secret on your app screen */
// 	private String clientSecret;
// 	/** Yes	The code returned by /v2/oauth2/authorize */
// 	private String code;
// 
// 	/** */
// 	@Override
// 	public String getEndpoint() {
// 		return "/oauth2/token";
// 	}
// 
// }
// 
// Path: src/main/java/com/lookfirst/wepay/api/req/WePayRequest.java
// public abstract class WePayRequest<T> {
// 	@JsonIgnore
// 	public abstract String getEndpoint();
// }
// 
// Path: src/main/java/com/lookfirst/wepay/util/DataProvider.java
// public interface DataProvider {
// 	InputStream getData(String uri, String postJson, String token) throws IOException;
// }


import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.lookfirst.wepay.api.Token;
import com.lookfirst.wepay.api.req.TokenRequest;
import com.lookfirst.wepay.api.req.WePayRequest;
import com.lookfirst.wepay.util.DataProvider;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.ParameterizedType;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;

	/**
	 * Sets up the headers and writes the post data.
	 */
	private HttpURLConnection getConnectionOnce(String uri, String postJson, String token) throws IOException {

		URL url = new URL(uri);
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();

		if (timeout > 0) {
			conn.setReadTimeout(timeout);
			conn.setConnectTimeout(timeout);
		}

		if (postJson != null && postJson.equals("{}"))
			postJson = null;

		if (postJson != null) {
			conn.setDoOutput(true); // Triggers POST.
		}
		conn.setRequestProperty("Content-Type", "application/json; charset=" + UTF8.name());
		conn.setRequestProperty("User-Agent", "WePay Java SDK");

		if (token != null) {
			conn.setRequestProperty("Authorization", "Bearer " + token);
		}

		if (postJson != null) {
			OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), UTF8);
			writer.write(postJson);
// Path: src/main/java/com/lookfirst/wepay/api/Token.java
// @Data
// public class Token implements Serializable {
// 	private static final long serialVersionUID = 1L;
// 
// 	/** The unique user ID of the user */
// 	private String userId;
// 	/** The access token that you can use to make calls on behalf of the user */
// 	private String accessToken;
// 	/** The token type - for now only "BEARER" is supported */
// 	private String tokenType;
// 	/** How much time till the access_token expires. If NULL or not present, the access token will be valid until the user revokes the access_token */
// 	private String expiresIn;
// }
// 
// Path: src/main/java/com/lookfirst/wepay/api/req/TokenRequest.java
// @Data
// @EqualsAndHashCode(callSuper=false)
// public class TokenRequest extends WePayRequest<Token> {
// 
// 	public static final String ENDPOINT = "/oauth2/token";
// 
// 	/** Yes	The client ID issued to the app by WePay - see your client ID on your app screen */
// 	private Long clientId;
// 	/** Yes	The uri the user will be redirected to after authorization. Must be the same as passed in /v2/oauth2/authorize */
// 	private String redirectUri;
// 	/** Yes	The client secret issued to the app by WePay - see your client secret on your app screen */
// 	private String clientSecret;
// 	/** Yes	The code returned by /v2/oauth2/authorize */
// 	private String code;
// 
// 	/** */
// 	@Override
// 	public String getEndpoint() {
// 		return "/oauth2/token";
// 	}
// 
// }
// 
// Path: src/main/java/com/lookfirst/wepay/api/req/WePayRequest.java
// public abstract class WePayRequest<T> {
// 	@JsonIgnore
// 	public abstract String getEndpoint();
// }
// 
// Path: src/main/java/com/lookfirst/wepay/util/DataProvider.java
// public interface DataProvider {
// 	InputStream getData(String uri, String postJson, String token) throws IOException;
// }


// Path: src/main/java/com/lookfirst/wepay/WePayApi.java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.lookfirst.wepay.api.Token;
import com.lookfirst.wepay.api.req.TokenRequest;
import com.lookfirst.wepay.api.req.WePayRequest;
import com.lookfirst.wepay.util.DataProvider;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.ParameterizedType;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;


	/**
	 * Sets up the headers and writes the post data.
	 */
	private HttpURLConnection getConnectionOnce(String uri, String postJson, String token) throws IOException {

		URL url = new URL(uri);
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();

		if (timeout > 0) {
			conn.setReadTimeout(timeout);
			conn.setConnectTimeout(timeout);
		}

		if (postJson != null && postJson.equals("{}"))
			postJson = null;

		if (postJson != null) {
			conn.setDoOutput(true); // Triggers POST.
		}
		conn.setRequestProperty("Content-Type", "application/json; charset=" + UTF8.name());
		conn.setRequestProperty("User-Agent", "WePay Java SDK");

		if (token != null) {
			conn.setRequestProperty("Authorization", "Bearer " + token);
		}

		if (postJson != null) {
			OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), UTF8);
			writer.write(postJson);
			writer.close();