/// <summary>
        /// Create a tournament
        /// </summary>
        /// <param name="body">Tournament registration parameters</param>
        /// <returns>id of the tournament</returns>
        public async Task <int> CreateTournament(TournamentRegistrationParameters body)
        {
            if (base.ServiceConfigured)
            {
                if (body == null)
                {
                    throw new Exception("The body must not be null");
                }

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, RiotGames.Properties.Resources.TOURNAMENT_STUB_TOURNAMENT)
                {
                    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 <int>());
                }
                else
                {
                    throw new HttpRequestException($"Code: {(int)response.StatusCode}-{response.StatusCode}, Location: {GetType().FullName}, Description: {response.ReasonPhrase}");
                }
            }
            throw new HttpServiceNotConfiguredException(base.Client);
        }
Ejemplo n.º 2
0
        public async Task <int> CreateTournament(TournamentRegistrationParameters model)
        {
            var request = new RestRequest("tournament-stub/v3/tournaments", Method.POST);

            request.AddJsonBody(model);

            return(await base.ExecuteGet <int>(request));
        }