/// <summary> /// Creates a Cloud Skills Challenge based on the parameter. /// </summary> /// <param name="contest">The argurments to pass to the server.</param> /// <returns>The ContestResponse from the server.</returns> public async Task <ContestResponse> CreateChallengeAsync(ContestRequest contest) { string uri = END_POINT + $"/api/contests"; string json = JsonConvert.SerializeObject(contest); HttpResponseMessage response = await httpClient.PostAsync(uri, new StringContent(json, Encoding.UTF8, "application/json")); string jsonResponse = await response.Content.ReadAsStringAsync(); ContestResponse result = JsonConvert.DeserializeObject <ContestResponse>(jsonResponse); return(result); }
/// <summary> /// Creates a challenge for each collection based on template /// </summary> /// <param name="collections">The list of collections to be used in the template.</param> /// <param name="contestTemplate">The template to be used to created the contest.</param> /// <returns>The ContestResponse.</returns> public async Task <List <ContestResponse> > CreateCollectionChallengesAsync(List <string> collections, ContestRequest contestTemplate) { contestTemplate.Type = "Collection"; var results = new List <ContestResponse>(); foreach (string s in collections) { contestTemplate.CollectionUrl = s; contestTemplate.CollectionID = s.Substring(s.LastIndexOf('/') + 1); ContestResponse result = await CreateChallengeAsync(contestTemplate); results.Add(result); } return(results); }