Imgur.API.Endpoints.Impl.RateLimitEndpoint.GetRateLimitAsync C# (CSharp) Method

GetRateLimitAsync() public method

Gets remaining credits for the application.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from a Mashape endpoint. Thrown when an error is found in a response from an Imgur endpoint.
public GetRateLimitAsync ( ) : Task
return Task
        public async Task<IRateLimit> GetRateLimitAsync()
        {
            IRateLimit limit;

            var url = "credits";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                limit = await SendRequestAsync<RateLimit>(request).ConfigureAwait(false);
            }

            return limit;
        }
    }

Usage Example

コード例 #1
0
        public async Task GetRateLimitAsync_Equal()
        {
            var mockUrl = "https://api.imgur.com/3/credits";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockRateLimitEndpointResponses.GetRateLimit)
            };

            var httpClient = new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse));

            var client = new ImgurClient("123", "1234");
            var endpoint = new RateLimitEndpoint(client, httpClient);

            var rateLimit = await endpoint.GetRateLimitAsync().ConfigureAwait(false);

            Assert.NotNull(rateLimit);
            Assert.Equal(10500, rateLimit.ClientLimit);
            Assert.Equal(9500, rateLimit.ClientRemaining);
        }
All Usage Examples Of Imgur.API.Endpoints.Impl.RateLimitEndpoint::GetRateLimitAsync