RiotSharp.RateLimitedRequester.CreatePostRequestAsync C# (CSharp) Method

CreatePostRequestAsync() public method

public CreatePostRequestAsync ( 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<string> CreatePostRequestAsync(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.Post);
            request.Content = new StringContent(body, Encoding.UTF8, "application/json");

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

            return await PostAsync(request);
        }

Usage Example

Example #1
0
        /// <summary>
        ///     Creates a tournament provider and returns its object.
        /// </summary>
        /// <param name="region">The region in which the provider will be running tournaments.</param>
        /// <param name="url">
        ///     The provider's callback URL to which tournament game results in this region should be posted. The URL
        ///     must be well-formed, use the http or https protocol, and use the default port for the protocol (http URLs must use
        ///     port 80, https URLs must use port 443).
        /// </param>
        /// <returns>The ID of the provider.</returns>
        public async Task <TournamentProvider> CreateProviderAsync(Region region, string url)
        {
            var body = new Dictionary <string, object> {
                { "url", url }, { "region", region.ToString().ToUpper() }
            };
            var json =
                await
                requester.CreatePostRequestAsync(TournamentRootUrl + CreateProviderUrl, Region.global,
                                                 JsonConvert.SerializeObject(body));

            return(new TournamentProvider {
                Id = int.Parse(json)
            });
        }