public void UpdateFromHeader(IDictionary <string, string> header)
        {
            var rateLimit = TwitterApiStatus.ParseRateLimit(header, "X-RateLimit-");

            if (rateLimit != null)
            {
                this.AccessLimit = rateLimit;
            }

            var mediaLimit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-");

            if (mediaLimit != null)
            {
                this.MediaUploadLimit = mediaLimit;
            }

            var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level");

            if (accessLevel.HasValue)
            {
                this.AccessLevel = accessLevel.Value;
            }
        }
Esempio n. 2
0
 public void ParseAccessLevelTest(IDictionary<string, string> header, TwitterApiAccessLevel? expect)
 {
     var accessLevel = TwitterApiStatus.ParseAccessLevel(header);
     Assert.That(accessLevel, Is.EqualTo(expect));
 }
Esempio n. 3
0
 private void CheckAccessLevel(TwitterApiAccessLevel accessLevelFlags)
 {
     if (!this.AccessLevel.HasFlag(accessLevelFlags))
         throw new WebApiException("Auth Err:try to re-authorization.");
 }
 public void Reset()
 {
     this.AccessLimit      = null;
     this.MediaUploadLimit = null;
     this.AccessLevel      = TwitterApiAccessLevel.Anonymous;
 }
Esempio n. 5
0
 public void ParseAccessLevelTest(IDictionary<string, string> header, TwitterApiAccessLevel? expected)
 {
     var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level");
     Assert.Equal(expected, accessLevel);
 }