示例#1
0
        private async Task HandleErrors(HttpResponseMessage response)
        {
            var content = response.Content == null
                ? null
                : await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var apiError = ApiError.ParseOrDefault(content);

            if ((int)response.StatusCode == HttpStatusCodeTooManyRequests)
            {
                throw new RateLimitApiException(RateLimit.Parse(response.Headers));
            }

            throw new ErrorApiException(response.StatusCode, apiError);
        }
示例#2
0
 /// <summary>
 /// Creates a new instance of the ApiInfo class.
 /// </summary>
 /// <param name="rateLimit">The current rate limit information.</param>
 /// <param name="serverTime">The current server time</param>
 public ApiInfo(RateLimit rateLimit, DateTimeOffset?serverTime)
 {
     RateLimit  = rateLimit;
     ServerTime = serverTime;
 }
示例#3
0
 /// <summary>
 /// Creates a new instance of the ApiInfo class.
 /// </summary>
 /// <param name="rateLimit">The current rate limit information.</param>
 public ApiInfo(RateLimit rateLimit) : this(rateLimit, null)
 {
 }
示例#4
0
        public static ApiInfo Parse(HttpResponseHeaders headers)
        {
            RateLimit rateLimit = ParseRateLimit(headers);

            return(new ApiInfo(rateLimit));
        }