package api.requests;

import api.son.MySon;
import api.soup.MySoup;

/**
 * The Class Request.
 * For using the API related to viewing Requests
 *
 * @author Gwindow
 */
public class Request {
	/** The API response. */
	private Response response;

	/** The response status */
	private String status;

	/**
	 * Get a request from the request id
	 * 
	 * @param id
	 *      the request id
	 * @return the request
	 */
	public static Request fromId(int id) {
		String url = "ajax.php?action=request&id=" + id + "&auth=" + MySoup.getAuthKey();
		return (Request) MySon.toObject(url, Request.class);
	}

	/**
	 * Add some bounty to the request
	 * @param amount bounty to add in bytes
	 */
	public void vote(long amount){
		String url = "requests.php?action=takevote&id=" + response.getRequestId()
			+ "&auth=" + MySoup.getAuthKey() + "&amount=" + Long.toString(amount);
		MySoup.pressLink(url);
	}

	/**
	 * Get the API response
	 * 
	 * @return the response
	 */
	public Response getResponse() {
		return response;
	}

	/**
	 * Get the status of the request
	 * 
	 * @return True if success
	 */
	public boolean getStatus() {
        return status.equalsIgnoreCase("success");
	}

	@Override
	public String toString() {
		return "Request [getResponse=" + getResponse() + ", getStatus=" + getStatus() + "]";
	}
}

@@ -886,24 +886,388 @@
 k(url);%0A%09%7D%0A%0A
+%09public void addBookmark()%7B%0A%09%09String url = %22bookmarks.php?action=add&type=request&auth=%22 + MySoup.getAuthKey()%0A%09%09%09+ %22&id=%22 + response.getRequestId();%0A%09%09MySoup.pressLink(url);%0A%09%7D%0A%0A%09public void removeBookmark()%7B%0A%09%09String url = %22bookmarks.php?action=remove&type=request&auth=%22 + MySoup.getAuthKey()%0A%09%09%09+ %22&id=%22 + response.getRequestId();%0A%09%09MySoup.pressLink(url);%0A%09%7D%0A%0A
 %09/**%0A%09 * Get

Add bookmarking & unbookmarking of requests