// Path: src/main/java/org/votesmart/data/Elections.java
// @XmlRootElement(name="elections")
// public class Elections extends GeneralInfoBase {
// 	
// 	public ArrayList<ElectionStage> election;
// 	
// 	@XmlType(name="election", namespace="elections")
// 	public static class ElectionStage extends Election {
// 		public ArrayList<Stage> stage;
// 
// 		@XmlType(name="stage", namespace="elections.election")
// 		public static class Stage {
// 			public String stageId;
// 			public String name;
// 			public String stateId;
// 			public String electionDate;
// 			public String filingDeadline;
// 			public String npatMailed;
// 		}
// 	}
// }
// 
// Path: src/main/java/org/votesmart/data/ElectionByZip.java
// @XmlRootElement(name="elections")
// public class ElectionByZip extends GeneralInfoBase {
// 	public ArrayList<Election> election;
// }
// 
// Path: src/main/java/org/votesmart/data/StageCandidates.java
// @XmlRootElement(name="stagecandidates")
// public class StageCandidates extends GeneralInfoBase {
// 
// 	public ArrayList<Election> election;	
// 	public ArrayList<Candidate> candidate;
// 	
// 	@XmlType(name="election", namespace="stagecandidates")
// 	public static class Election {
// 		public String electionId;
// 		public String name;
// 		public String stage;
// 		public String stateId;
// 	}
// 	
// 	@XmlType(name="candidate", namespace="stagecandidates")
// 	public static class Candidate {
// 		public String candidateId;
// 		public String officeId;
// 		public String district;
// 		public String firstName;
// 		public String middleName;
// 		public String lastName;
// 		public String suffix;
// 		public String party;
// 		public String status;
// 		public String voteCount;
// 		public String votePercent;
// 	}
// }


import org.votesmart.api.*;
import org.votesmart.data.Elections;
import org.votesmart.data.ElectionByZip;
import org.votesmart.data.StageCandidates;

package org.votesmart.classes;


/**
 * <pre>
 * Election Class
 * 
 * * - Required
 * * - Multiple rows
 * 
 * Election.getElection
 * This method grabs district basic election data according to electionId
 * Input: electionId*
 * Output: {@link Elections}
 * 
 * Election.getElectionByYearState
 * This method grabs district basic election data according to year and stateid.
 * Input: year*, stateId(default: 'NA')
 * Output: {@link Elections}
 * 
 * Election.getElectionByZip
 * This method grabs district basic election data according to zip code.
 * Input: zip5*, zip4(default: NULL), year(default: &gr;=current year
 * Output: {@link ElectionByZip}
 * 
 * Election.getStageCandidates
 * This method grabs district basic election data according to electionId and stageId. Per state lists of a Presidential election are available by specifying the stateId.
 * Input: electionId*, stageId*, party (Default: ALL(NULL)), districtId (Default: All(NULL)), stateId (Default: election.stateId)
 * Output: {@link StageCandidates}
 * 
 * ============ EXAMPLE USAGE ==============
 * 
 * ElectionClass electionClass = new ElectionClass();
 * 
 * // look up 2012 elections
 * Elections elections = electionClass.getElectionByYearState("2012", state.stateId);
 * Elections.ElectionStage election = elections.election.get(0);
 * Elections.ElectionStage.Stage stage = elections.election.get(0).stage.get(0);
 * 
 * // a specific election 
 * elections = electionClass.getElection(election.electionId);
 * election = elections.election.get(0);
 * </pre>
 *
 */
public class ElectionClass extends ClassesBase {

	/**
	 * Constructor for testing purposes. 
	 * 
	 * @param api
	 */
	public ElectionClass(VoteSmartAPI api) {
		super(api);
	}
	
	/**
	 * Default Constructor
	 */
	public ElectionClass() throws VoteSmartException {
		super();
	}

	/**
	 * This method grabs district IDs according to the office and state.
	 * 
	 * @param electionId
	 * @return {@link Elections}: 
	 */
	public Elections getElection(String electionId) throws VoteSmartException, VoteSmartErrorException {

// Path: src/main/java/org/votesmart/data/Elections.java
// @XmlRootElement(name="elections")
// public class Elections extends GeneralInfoBase {
// 	
// 	public ArrayList<ElectionStage> election;
// 	
// 	@XmlType(name="election", namespace="elections")
// 	public static class ElectionStage extends Election {
// 		public ArrayList<Stage> stage;
// 
// 		@XmlType(name="stage", namespace="elections.election")
// 		public static class Stage {
// 			public String stageId;
// 			public String name;
// 			public String stateId;
// 			public String electionDate;
// 			public String filingDeadline;
// 			public String npatMailed;
// 		}
// 	}
// }
// 
// Path: src/main/java/org/votesmart/data/ElectionByZip.java
// @XmlRootElement(name="elections")
// public class ElectionByZip extends GeneralInfoBase {
// 	public ArrayList<Election> election;
// }
// 
// Path: src/main/java/org/votesmart/data/StageCandidates.java
// @XmlRootElement(name="stagecandidates")
// public class StageCandidates extends GeneralInfoBase {
// 
// 	public ArrayList<Election> election;	
// 	public ArrayList<Candidate> candidate;
// 	
// 	@XmlType(name="election", namespace="stagecandidates")
// 	public static class Election {
// 		public String electionId;
// 		public String name;
// 		public String stage;
// 		public String stateId;
// 	}
// 	
// 	@XmlType(name="candidate", namespace="stagecandidates")
// 	public static class Candidate {
// 		public String candidateId;
// 		public String officeId;
// 		public String district;
// 		public String firstName;
// 		public String middleName;
// 		public String lastName;
// 		public String suffix;
// 		public String party;
// 		public String status;
// 		public String voteCount;
// 		public String votePercent;
// 	}
// }


// Path: src/main/java/org/votesmart/classes/ElectionClass.java
import org.votesmart.api.*;
import org.votesmart.data.Elections;
import org.votesmart.data.ElectionByZip;
import org.votesmart.data.StageCandidates;

package org.votesmart.classes;


/**
 * <pre>
 * Election Class
 * 
 * * - Required
 * * - Multiple rows
 * 
 * Election.getElection
 * This method grabs district basic election data according to electionId
 * Input: electionId*
 * Output: {@link Elections}
 * 
 * Election.getElectionByYearState
 * This method grabs district basic election data according to year and stateid.
 * Input: year*, stateId(default: 'NA')
 * Output: {@link Elections}
 * 
 * Election.getElectionByZip
 * This method grabs district basic election data according to zip code.
 * Input: zip5*, zip4(default: NULL), year(default: &gr;=current year
 * Output: {@link ElectionByZip}
 * 
 * Election.getStageCandidates
 * This method grabs district basic election data according to electionId and stageId. Per state lists of a Presidential election are available by specifying the stateId.
 * Input: electionId*, stageId*, party (Default: ALL(NULL)), districtId (Default: All(NULL)), stateId (Default: election.stateId)
 * Output: {@link StageCandidates}
 * 
 * ============ EXAMPLE USAGE ==============
 * 
 * ElectionClass electionClass = new ElectionClass();
 * 
 * // look up 2012 elections
 * Elections elections = electionClass.getElectionByYearState("2012", state.stateId);
 * Elections.ElectionStage election = elections.election.get(0);
 * Elections.ElectionStage.Stage stage = elections.election.get(0).stage.get(0);
 * 
 * // a specific election 
 * elections = electionClass.getElection(election.electionId);
 * election = elections.election.get(0);
 * </pre>
 *
 */
public class ElectionClass extends ClassesBase {

	/**
	 * Constructor for testing purposes. 
	 * 
	 * @param api
	 */
	public ElectionClass(VoteSmartAPI api) {
		super(api);
	}
	
	/**
	 * Default Constructor
	 */
	public ElectionClass() throws VoteSmartException {
		super();
	}

	/**
	 * This method grabs district IDs according to the office and state.
	 * 
	 * @param electionId
	 * @return {@link Elections}: 
	 */
	public Elections getElection(String electionId) throws VoteSmartException, VoteSmartErrorException {

		return api.query("Election.getElection", new ArgMap("electionId", electionId), Elections.class );
