internal new static RestSelfUser Create(BaseRestClient client, Model model) { var entity = new RestSelfUser(client, model.Id); entity.Update(model); return(entity); }
// 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); }
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); }