private async Task <TicketPresentation.Tickets> GetTicketInfo(object EventName, object EventDate, ILambdaContext context) { Tickets tickets = new Tickets(); var uri = new Uri($"http://www.oumisprojects.com/mis3033/api/Marketplace_Table"); try { //This is the actual GET request var response = await httpClient.GetStringAsync(uri); context.Logger.LogLine($"Response from URL:\n{response}"); // TODO: (PMO) Handle bad requests //Conver the below from the JSON output into a list of player objects tickets = JsonConvert.DeserializeObject <Tickets>(response); } catch (Exception ex) { context.Logger.LogLine($"\nException: {ex.Message}"); context.Logger.LogLine($"\nStack Trace: {ex.StackTrace}"); } return(tickets); }
public async Task <SkillResponse> FunctionHandler(SkillRequest input, ILambdaContext context) { string outputText = ""; var requestType = input.GetRequestType(); if (requestType == typeof(LaunchRequest)) { return(BodyResponse("Welcome to the Student Ticket Marketplace, what would you like to do here?", false)); } if (requestType == typeof(IntentRequest)) { //outputText += "Request type is Intent"; var intent = input.Request as IntentRequest; if (intent.Intent.Name.Equals("Availability")) { var EventName = intent.Intent.Slots["EventName"].Value; var EventDate = intent.Intent.Slots["EventDate"].Value; if (EventName == null) { return(BodyResponse("I did not understand the event name of the ticket, please try again.", false)); } //else if (EventDate == null) //{ // return BodyResponse("I did not understand the event date of the ticket you wanted, please try again.", false); //} Tickets tix = await GetTicketInfo(EventName, EventDate, context); { outputText = $"No, there are {tix.Quantity} tickets for the next {tix.EventName} game"; return(BodyResponse(outputText, true)); } } else if (intent.Intent.Name.Equals("Sell_Intent")) { var EventName = intent.Intent.Slots["EventName"].Value; var EventDate = intent.Intent.Slots["EventDate"].Value; if (EventName == null) { return(BodyResponse("I did not understand the event name of the ticket, please try again.", false)); } //else if (EventDate == null) //{ // return BodyResponse("I did not understand the event date of the ticket you wanted, please try again.", false); //} else if (intent.Intent.Name.Equals("Price_Intent")) { //var EventName = intent.Intent.Slots["EventName"].Value; //var EventDate = intent.Intent.Slots["EventDate"].Value; if (EventName == null) { return(BodyResponse("I did not understand the event name of the ticket, please try again.", false)); } //else if (EventDate == null) //{ // return BodyResponse("I did not understand the event date of the ticket you wanted, please try again.", false); //} else if (intent.Intent.Name.Equals("AMAZON.StopIntent")) { return(BodyResponse("You have now exited the Student Ticket MarketPlace", true)); } else { return(BodyResponse("I did not understand this intent, please try again", true)); } } else { return(BodyResponse("I did not understand your request, please try again", true)); } } } return(BodyResponse("", true)); }