/**
 * Status.java
 * @date Jan 2, 2011
 * @author ricky barrette
 * @author Twenty Codes, LLC
 */
package com.TwentyCodes.java.OrderProcessor;


/**
 * This enum will represent statuses that are associated with an order
 * @author ricky barrette
 */
public enum Status {
	
	/**
	 * A financial status representing that the order has been charged to the customer
	 */
	CHARGED, 
	
	/**
	 * A financial status representing that the order has been canceled by the customer
	 */
	CANCELLED, 
	
	
	/**
	 * A financial status representing that the order has been canceled by google, most likely due to an invalid credit card
	 */
	CANCELLED_BY_GOOGLE,
	
	/**
	 * A fulfillment status representing that the order has been delivered to the customer 
	 */
	DELIVERED, 
	
	/**
	 * A fulfillment status representing that the order has been canceled, and will not be delivered to the customer
	 */
	WILL_NOT_DELIVER,
	
	/**
	 * A financial status representing that the order is chargeable 
	 */
	CHARGEABLE,
	
	/**
	 * A fulfillment status representing that the order is new
	 */
	NEW,
	
	/**
	 * A financial status representing that the authorization of the customer's credit card failed. 
	 * Google has sent an email instructing the customer to update their card. 
	 * If they fail to provide a valid card within 7 days, this order will be automatically canceled by Google.
	 */
	PAYMENT_DECLINED
	;
	
	
	/**
	 * Parses a string into a Status
	 * @param s
	 * @return the Status the represents the string or null if unparseable
	 * @author ricky barrette
	 */
	public static Status parseStatus(String s){
		if(Main.DEBUG)
			System.out.println("parsing status: "+ s);
		
		if(s.equals(CHARGED.toString()))
			return CHARGED;
		
		if(s.equals(CANCELLED.toString()))
			return CANCELLED;
		
		if(s.equals(CANCELLED_BY_GOOGLE.toString()))
			return CANCELLED_BY_GOOGLE;
		
		if(s.equals(DELIVERED.toString()))
			return DELIVERED;
		
		if(s.equals(WILL_NOT_DELIVER.toString()))
			return WILL_NOT_DELIVER;
		
		if(s.equals(CHARGEABLE.toString()))
			return CHARGEABLE;
		
		if(s.equals(NEW.toString()))
			return NEW;
		
		if(s.equals(PAYMENT_DECLINED.toString()))
			return PAYMENT_DECLINED;
				
		return null;
		
	}
	
}