/// <summary> /// Update the tournament code /// </summary> /// <param name="tournamentCode">Code of the tournament</param> /// <param name="body">Tournament code parameters</param> public async void UpdateTournamentCode(string tournamentCode, TournamentCodeParameters body) { if (base.ServiceConfigured) { if (body == null) { throw new Exception("The body must not be null"); } var pathParams = new Dictionary <string, object>() { { nameof(tournamentCode), tournamentCode } }; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, ApiService.BuildUri(RiotGames.Properties.Resources.TOURNAMENT_PUT_TOURNAMENT_CODE, pathParams)) { Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json") }; var response = await base.Client.SendAsync(request); if (!response.IsSuccessStatusCode) { throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}"); } } throw new HttpServiceNotConfiguredException(base.Client); }
public async Task <List <string> > SelectCodes(int tournamentId, TournamentCodeParameters model = null, int?count = null) { var request = new RestRequest("tournament/v3/codes", Method.POST); request.AddParameter("tournamentId", tournamentId); if (model != null) { request.AddJsonBody(model); } if (count.HasValue) { request.AddParameter("count", count.Value); } return(await base.ExecuteGet <List <string> >(request)); }
public async Task CreateTournamentStubAsync() { var tsV4 = Api.TournamentStubV4(); var providerId = await tsV4.RegisterProviderDataAsync( RegionalRoute.AMERICAS, new ProviderRegistrationParameters() { Region = "NA", Url = "https://github.com/MingweiSamuel/Camille", }); Assert.IsNotNull(providerId); var tournamentId = await tsV4.RegisterTournamentAsync( RegionalRoute.AMERICAS, new TournamentRegistrationParameters() { Name = "Camille Tourney :)", ProviderId = providerId, }); Assert.IsNotNull(tournamentId); var tourneyCodeParams = new TournamentCodeParameters() { MapType = "SUMMONERS_RIFT", Metadata = "eW91IGZvdW5kIHRoZSBzZWNyZXQgbWVzc2FnZQ==", PickType = "TOURNAMENT_DRAFT", SpectatorType = "ALL", TeamSize = 5, }; var codes = await tsV4.CreateTournamentCodeAsync( RegionalRoute.AMERICAS, tourneyCodeParams, tournamentId, 1000); Assert.IsNotNull(codes); Assert.AreEqual(1000, codes.Length); Console.WriteLine(string.Join(", ", codes)); }
/// <summary> /// Create a tournament code /// </summary> /// <param name="queryParams">Tournament request parameters</param> /// <param name="body">Tournament code parameters</param> /// <returns>List of tournament codes</returns> public async Task <List <string> > CreateTournamentCode(TournamentRequestParameters queryParams, TournamentCodeParameters body) { if (base.ServiceConfigured) { if (body == null) { throw new Exception("The body must not be null"); } HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, ApiService.BuildUri(RiotGames.Properties.Resources.TOURNAMENT_STUB_CODE, queryParameters: queryParams)) { Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json") }; var response = await base.Client.SendAsync(request); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsAsync <List <string> >()); } else { throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}"); } } throw new HttpServiceNotConfiguredException(base.Client); }