package tut;
import com.ibm.telephony.beans.media.*;
import com.ibm.telephony.wvr.*;
/**
 * Subcomponent that allows the caller to order an item from a catalog
 */
class Catalog {
	//Define the category for all the voice segments in this class.
	private static final String CATEGORY = "Tutorials";
	// Define the menu items
	private static final String ITEM1_YES = "Yes";
	private static final String ITEM2_NO  = "No";
	
	// Create an array to store the menu items
	private static final String[] MENU_ITEMS = { ITEM1_YES, ITEM2_NO };
	
	// Define the keys used to make the menu selections, and store them in an array
	private static final String[] MENU_KEYS = { "1", "2" };
	// Create a number of Voice Segment objects
	// Create the segment objects for the menu items, and store them in an array
	private static final MediaType[]  MENU_PROMPTS = {
		new VoiceSegment(CATEGORY, "ForYesPress1"),
		new VoiceSegment(CATEGORY, "ForNoPress2")
	};
	
	// Create the segment objects for taking the order
	private static final VoiceSegment VS_PRODUCT_NUMBER = new VoiceSegment(CATEGORY, "ProductNumber");
	private static final VoiceSegment VS_QUANTITY       = new VoiceSegment(CATEGORY, "Quantity");
	private static final VoiceSegment VS_YOU_ORDERED    = new VoiceSegment(CATEGORY, "YouOrdered");
	private static final VoiceSegment VS_ITEMS          = new VoiceSegment(CATEGORY, "Items");
	
	// Create the segment objects for the verifying the order menu
	private static final VoiceSegment VS_IS_THIS_OK = new VoiceSegment(CATEGORY, "IsThisOK");
	
	// Create the segment object for the result
	private static final VoiceSegment VS_SORRY = new VoiceSegment(CATEGORY, "Sorry");
	
	// Create AudioNumber objects to play the caller's order back to them
	private AudioNumber prodNumValue  = new AudioNumber();
	private AudioNumber quantityValue = new AudioNumber();
	
	// Create a media sequence of the caller's order
	private MediaType[] order = { VS_YOU_ORDERED, quantityValue, VS_ITEMS, prodNumValue };	
	
	// Create some attribute objects for getting the product number from the caller
	private PlayAttributes prodNumPlayAtts   = new PlayAttributes();
	private InputAttributes prodNumInputAtts = new InputAttributes();
	private DTMFAttributes prodNumDTMFAtts   = new DTMFAttributes();
	private RecoAttributes prodNumRecoAtts   = null;
	// Create some attribute objects for getting the quantity from the caller
	private PlayAttributes quantityPlayAtts   = new PlayAttributes();	
	private InputAttributes quantityInputAtts = new InputAttributes();
	private DTMFAttributes quantityDTMFAtts   = new DTMFAttributes();
	private RecoAttributes quantityRecoAtts   = null;
	// Create some attribute objects for the verify order menu
	private PlayAttributes menuPlayAtts  = new PlayAttributes();
	private MenuAttributes menuAtts      = new MenuAttributes(MENU_PROMPTS, MENU_ITEMS, MENU_KEYS, MENU_ITEMS); 	
	private DTMFAttributes menuDTMFAtts  = new DTMFAttributes();
	private RecoAttributes menuRecoAtts  = null;	
	
	private CardChecker cardChecker = new CardChecker();