public static IActionResult Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { string userId = req.Query["userid"].ToString(); var endpoint = new MflEndpoint(); var leaguesEndpoint = new Uri($"{endpoint.Host}/{endpoint.Year}/export?TYPE=myleagues&FRANCHISE_NAMES=1&JSON=1"); string leaguesResponse = MflEndpointController.GetResponseString(leaguesEndpoint, endpoint, userId).Result;; var leagues = new Leagues(leaguesResponse); return(userId != null ? (ActionResult) new OkObjectResult(leagues.LeagueList) : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { string userId = req.Query["userid"].ToString(); string leagueId = req.Query["leagueid"].ToString(); string franchiseId = req.Query["franchiseid"].ToString(); var endpoint = new MflEndpoint(); var rosterEndpoint = new Uri($"{endpoint.Host}/{endpoint.Year}/export?TYPE=rosters&L={leagueId}&FRANCHISE={franchiseId}&JSON=1"); string rosterResponse = await MflEndpointController.GetResponseString(rosterEndpoint, endpoint, userId); var roster = new Roster(rosterResponse); return(userId != null ? (ActionResult) new OkObjectResult(roster.PlayerList) : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log ) { var userId = req.Query["userId"].ToString(); var since = req.Query["since"].ToString(); var endpoint = new MflEndpoint(); string arguments = "export?TYPE=players&DETAILS=1&JSON=1"; if (!string.IsNullOrEmpty(since)) { arguments += $"&since={since}"; } var playerEndpoint = new Uri($"{endpoint.Host}/{endpoint.Year}/{arguments}"); string playerResponse = await MflEndpointController.GetResponseString(playerEndpoint, endpoint, userId); var players = new Players(playerResponse); return(userId != null ? (ActionResult) new OkObjectResult(players.PlayerList) : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }