// Path: jue/src/nl/q42/jue/HttpClient.java
// public static class Result {
// 	private String body;
// 	private int responseCode;
// 		
// 	public Result(String body, int responseCode) {
// 		this.body = body;
// 		this.responseCode = responseCode;
// 	}
// 		
// 	public String getBody() {
// 		return body;
// 	}
// 		
// 	public int getResponseCode() {
// 		return responseCode;
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/ApiException.java
// @SuppressWarnings("serial")
// public class ApiException extends Exception {
// 	public ApiException() {}
// 	
// 	public ApiException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/DeviceOffException.java
// @SuppressWarnings("serial")
// public class DeviceOffException extends ApiException {
// 	public DeviceOffException() {}
// 	
// 	public DeviceOffException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/EntityNotAvailableException.java
// @SuppressWarnings("serial")
// public class EntityNotAvailableException extends ApiException {
// 	public EntityNotAvailableException() {}
// 	
// 	public EntityNotAvailableException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/GroupTableFullException.java
// @SuppressWarnings("serial")
// public class GroupTableFullException extends ApiException {
// 	public GroupTableFullException() {}
// 	
// 	public GroupTableFullException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/InvalidCommandException.java
// @SuppressWarnings("serial")
// public class InvalidCommandException extends ApiException {
// 	public InvalidCommandException() {}
// 	
// 	public InvalidCommandException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/LinkButtonException.java
// @SuppressWarnings("serial")
// public class LinkButtonException extends ApiException {
// 	public LinkButtonException() {}
// 	
// 	public LinkButtonException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/UnauthorizedException.java
// @SuppressWarnings("serial")
// public class UnauthorizedException extends ApiException {
// 	public UnauthorizedException() {}
// 	
// 	public UnauthorizedException(String message) {
// 		super(message);
// 	}
// }


import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import nl.q42.jue.HttpClient.Result;
import nl.q42.jue.exceptions.ApiException;
import nl.q42.jue.exceptions.DeviceOffException;
import nl.q42.jue.exceptions.EntityNotAvailableException;
import nl.q42.jue.exceptions.GroupTableFullException;
import nl.q42.jue.exceptions.InvalidCommandException;
import nl.q42.jue.exceptions.LinkButtonException;
import nl.q42.jue.exceptions.UnauthorizedException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
	 * @param username username to authenticate
	 * @throws UnauthorizedException thrown if authentication failed
	 */
	public void authenticate(String username) throws IOException, ApiException {
		try {
			this.username = username;
			getLights();
		} catch (Exception e) {
			this.username = null;
			throw new UnauthorizedException(e.toString());
		}
	}
	
	/**
	 * Link with bridge using the specified username and device type.
	 * @param username username for new user [10..40]
	 * @param devicetype identifier of application [0..40]
	 * @throws LinkButtonException thrown if the bridge button has not been pressed
	 */
	public void link(String username, String devicetype) throws IOException, ApiException {
		this.username = link(new CreateUserRequest(username, devicetype));
	}
	
	/**
	 * Link with bridge using the specified device type. A random valid username will be generated by the bridge and returned.
	 * @return new random username generated by bridge
	 * @param devicetype identifier of application [0..40]
	 * @throws LinkButtonException thrown if the bridge button has not been pressed
	 */
	public String link(String devicetype) throws IOException, ApiException {
// Path: jue/src/nl/q42/jue/HttpClient.java
// public static class Result {
// 	private String body;
// 	private int responseCode;
// 		
// 	public Result(String body, int responseCode) {
// 		this.body = body;
// 		this.responseCode = responseCode;
// 	}
// 		
// 	public String getBody() {
// 		return body;
// 	}
// 		
// 	public int getResponseCode() {
// 		return responseCode;
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/ApiException.java
// @SuppressWarnings("serial")
// public class ApiException extends Exception {
// 	public ApiException() {}
// 	
// 	public ApiException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/DeviceOffException.java
// @SuppressWarnings("serial")
// public class DeviceOffException extends ApiException {
// 	public DeviceOffException() {}
// 	
// 	public DeviceOffException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/EntityNotAvailableException.java
// @SuppressWarnings("serial")
// public class EntityNotAvailableException extends ApiException {
// 	public EntityNotAvailableException() {}
// 	
// 	public EntityNotAvailableException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/GroupTableFullException.java
// @SuppressWarnings("serial")
// public class GroupTableFullException extends ApiException {
// 	public GroupTableFullException() {}
// 	
// 	public GroupTableFullException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/InvalidCommandException.java
// @SuppressWarnings("serial")
// public class InvalidCommandException extends ApiException {
// 	public InvalidCommandException() {}
// 	
// 	public InvalidCommandException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/LinkButtonException.java
// @SuppressWarnings("serial")
// public class LinkButtonException extends ApiException {
// 	public LinkButtonException() {}
// 	
// 	public LinkButtonException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: jue/src/nl/q42/jue/exceptions/UnauthorizedException.java
// @SuppressWarnings("serial")
// public class UnauthorizedException extends ApiException {
// 	public UnauthorizedException() {}
// 	
// 	public UnauthorizedException(String message) {
// 		super(message);
// 	}
// }


// Path: jue/src/nl/q42/jue/HueBridge.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import nl.q42.jue.HttpClient.Result;
import nl.q42.jue.exceptions.ApiException;
import nl.q42.jue.exceptions.DeviceOffException;
import nl.q42.jue.exceptions.EntityNotAvailableException;
import nl.q42.jue.exceptions.GroupTableFullException;
import nl.q42.jue.exceptions.InvalidCommandException;
import nl.q42.jue.exceptions.LinkButtonException;
import nl.q42.jue.exceptions.UnauthorizedException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;

	 * @param username username to authenticate
	 * @throws UnauthorizedException thrown if authentication failed
	 */
	public void authenticate(String username) throws IOException, ApiException {
		try {
			this.username = username;
			getLights();
		} catch (Exception e) {
			this.username = null;
			throw new UnauthorizedException(e.toString());
		}
	}
	
	/**
	 * Link with bridge using the specified username and device type.
	 * @param username username for new user [10..40]
	 * @param devicetype identifier of application [0..40]
	 * @throws LinkButtonException thrown if the bridge button has not been pressed
	 */
	public void link(String username, String devicetype) throws IOException, ApiException {
		this.username = link(new CreateUserRequest(username, devicetype));
	}
	
	/**
	 * Link with bridge using the specified device type. A random valid username will be generated by the bridge and returned.
	 * @return new random username generated by bridge
	 * @param devicetype identifier of application [0..40]
	 * @throws LinkButtonException thrown if the bridge button has not been pressed
	 */
	public String link(String devicetype) throws IOException, ApiException {
		return (this.username = link(new CreateUserRequest(devicetype)));