RiotSharp.RateLimitedRequester.CreatePutRequestAsync C# (CSharp) Method

CreatePutRequestAsync() public method

public CreatePutRequestAsync ( string relativeUrl, Region region, string body, List addedArguments = null, bool useHttps = true ) : Task
relativeUrl string
region Region
body string
addedArguments List
useHttps bool
return Task
        public async Task<bool> CreatePutRequestAsync(string relativeUrl, Region region, string body,
            List<string> addedArguments = null, bool useHttps = true)
        {
            rootDomain = region + ".api.pvp.net";
            var request = PrepareRequest(relativeUrl, addedArguments, useHttps, HttpMethod.Put);
            request.Content = new StringContent(body, Encoding.UTF8, "application/json");

            await semaphore.WaitAsync();
            {
                HandleRateLimit(region);
            }
            semaphore.Release();

            var response = await PutAsync(request);
            return (int)response.StatusCode >= 200 && (int)response.StatusCode < 300;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        ///     Update the pick type, map, spectator type, or allowed summoners for a code.
        /// </summary>
        /// <param name="tournamentCode">The tournament code to update</param>
        /// <param name="allowedSummonerIds">List of summoner id's.</param>
        /// <param name="spectatorType">The spectator type.</param>
        /// <param name="pickType">The pick type.</param>
        /// <param name="mapType">The map type.</param>
        /// /// <returns>Success value.</returns>
        public async Task <bool> UpdateTournamentCodeAsync(string tournamentCode, List <long> allowedSummonerIds,
                                                           TournamentSpectatorType?spectatorType, TournamentPickType?pickType, TournamentMapType?mapType)
        {
            var body = BuildTournamentUpdateBody(allowedSummonerIds, spectatorType, pickType, mapType);

            return(await requester.CreatePutRequestAsync(TournamentRootUrl + string.Format(PutCodeUrl, tournamentCode),
                                                         Region.global, JsonConvert.SerializeObject(body)));
        }