Example #1
0
        internal new static RestSelfUser Create(BaseRestClient client, Model model)
        {
            var entity = new RestSelfUser(client, model.Id);

            entity.Update(model);
            return(entity);
        }
Example #2
0
        // Users
        public static async Task <RestSelfUser> GetCurrentUserAsync(BaseTwitchClient client, RequestOptions options = null)
        {
            var model = await client.ApiClient.GetMyUserAsync(options).ConfigureAwait(false);

            if (model != null)
            {
                return(RestSelfUser.Create(client, model));
            }
            return(null);
        }
Example #3
0
        public static async Task <RestSelfUser> GetSelfUserAsync(BaseRestClient client, ulong userId)
        {
            if (TokenHelper.TryGetToken(client, userId, out RestTokenInfo info))
            {
                throw new MissingScopeException("user_read");
            }
            if (!info.Authorization.Scopes.Contains("user_read"))
            {
                throw new MissingScopeException("user_read");
            }

            var model = await client.RestClient.GetSelfUserInternalAsync(info.Token);

            var entity = new RestSelfUser(client, model.Id);

            entity.Update(model);
            return(entity);
        }