package api.forum.thread;

import java.util.List;

/**
 * The Class Poll.
 * Stores information returned from the API about a
 * thread's Poll
 * 
 * @author Gwindow
 */
public class Poll {
    /** The question. */
    private String question;

	/** The possible answers */
	private List<Answer> answers;

	/**
	 * If the poll's been featured on the home page
	 */
	private String featured;

	/** The max votes. */
	private Number maxVotes;

	/** The total votes. */
	private Number totalVotes;

    /** If the poll is closed */
    private boolean closed;
	
	/** If we've voted on the poll */
	private boolean voted;

    /**
     * Get the question.
     *
     * @return the question
     */
    public String getQuestion() {
        return this.question;
    }

    /**
     * Get the possible answers
     *
     * @return the answers
     */
    public List<Answer> getAnswers() {
        return this.answers;
    }

	/**
	 * Check if the poll is featured
	 * 
	 * @return True if featured
	 */
	public boolean isFeatured() {
        return this.featured.equalsIgnoreCase("0000-00-00 00:00:00");
	}

	/**
	 * Get the max votes
	 * 
	 * @return the max votes
	 */
	public Number getMaxVotes() {
		return this.maxVotes;
	}

	/**
	 * Get the total votes
	 * 
	 * @return the total votes
	 */
	public Number getTotalVotes() {
		return this.totalVotes;
	}

    /**
     * Check if the poll is closed
     *
     * @return True if the poll is closed
     */
    public boolean isClosed() {
        return this.closed;
    }

	/**
	 * Check if we've voted on the poll
	 * 
	 * @return True if we've voted
	 */
	public boolean hasVoted() {
		return this.voted;
	}

	@Override
	public String toString() {
		return "Poll [getAnswers=" + getAnswers() + ", isClosed=" + isClosed() + ", isFeatured=" + isFeatured()
				+ ", getMaxVotes=" + getMaxVotes() + ", getQuestion=" + getQuestion() + ", getTotalVotes=" + getTotalVotes()
				+ ", hasVoted=" + hasVoted() + "]";
	}
}

@@ -20,16 +20,131 @@
 hread;%0A%0A
+import api.soup.MySoup;%0Aimport api.util.CouldNotLoadException;%0Aimport api.util.Tuple;%0A%0Aimport java.util.ArrayList;%0A
 import j
@@ -1771,16 +1771,672 @@
 ed;%0A%09%7D%0A%0A
+%09public static boolean vote(int threadid, int vote)%7B%0A%09%09try %7B%0A%09%09%09System.out.println(%22Voting on thread %22 + threadid + %22, vote %22 + vote);%0A%09%09%09String url = %22index.php%22;%0A%09%09%09List%3CTuple%3CString, String%3E%3E list = new ArrayList%3CTuple%3CString, String%3E%3E();%0A%09%09%09list.add(new Tuple%3CString, String%3E(%22action%22, %22poll%22));%0A%09%09%09list.add(new Tuple%3CString, String%3E(%22auth%22, MySoup.getAuthKey()));%0A%09%09%09list.add(new Tuple%3CString, String%3E(%22topicid%22, Integer.toString(threadid)));%0A%09%09%09list.add(new Tuple%3CString, String%3E(%22vote%22, Integer.toString(vote)));%0A%09%09%09MySoup.postMethod(url, list);%0A%09%09%7D%0A%09%09catch (CouldNotLoadException e)%7B%0A%09%09%09e.printStackTrace();%0A%09%09%09return false;%0A%09%09%7D%0A%09%09return true;%0A%09%7D%0A%0A
 %09@Overri

Add support for voting in polls