Пример #1
0
        /// <summary>
        /// Gets a list of users that the user has blocked. Requires user authorization.
        /// </summary>
        /// <returns>A list of users</returns>
        public async Task <List <User> > RetrieveBlockedUsers()
        {
            if (authorized && authorizedScopes.Contains(TwitchConstants.Scope.UserBlocksRead))
            {
                Uri uri;
                uri = new Uri("https://api.twitch.tv/kraken/users/" + name + "/blocks");
                string responseString = await Twixel.GetWebData(uri, accessToken);

                foreach (JObject user in JObject.Parse(responseString)["blocks"])
                {
                    User temp = twixel.LoadUser((JObject)user["user"]);
                    if (!ContainsBlockedUser(temp.name))
                    {
                        blockedUsers.Add(temp);
                    }
                }
                return(blockedUsers);
            }
            else
            {
                if (!authorized)
                {
                    twixel.CreateError(name + " is not authorized");
                }
                else if (!authorizedScopes.Contains(TwitchConstants.Scope.UserBlocksRead))
                {
                    twixel.CreateError(name + " has not given user_blocks_read permissions");
                }
                return(null);
            }
        }
Пример #2
0
 public Subscription(string id, JObject userO, string createdAt, Twixel twixel)
 {
     this.id        = id;
     this.user      = twixel.LoadUser(userO);
     this.createdAt = DateTime.Parse(createdAt);
 }