internal new static RestUser Create(BaseRestClient client, Model model) { var entity = new RestUser(client, model.Id); entity.Update(model); return(entity); }
public static async Task <RestUser> GetUserAsync(BaseRestClient client, ulong id) { var token = TokenHelper.GetSingleToken(client); var model = await client.RestClient.GetUserInternalAsync(token, id); if (model == null) { return(null); } var entity = new RestUser(client, model.Id); entity.Update(model); return(entity); }
public static async Task <IReadOnlyCollection <RestUser> > GetUsersAsync(BaseRestClient client, string[] usernames) { var token = TokenHelper.GetSingleToken(client); var model = await client.RestClient.GetUsersInternalAsync(token, usernames); if (model == null) { return(new List <RestUser>()); } var entity = model.Users.Select(x => { var user = new RestUser(client, x.Id); user.Update(x); return(user); }); return(entity.ToArray()); }
internal static async Task <IReadOnlyCollection <RestUser> > GetEditorsAsync(BaseRestClient client, ulong channelId) { if (!TokenHelper.TryGetToken(client, channelId, out RestTokenInfo info)) { throw new MissingScopeException("channel_read"); } if (!info.Authorization.Scopes.Contains("channel_read")) { throw new MissingScopeException("channel_read"); } var model = await client.RestClient.GetChannelEditorsAsync(info.Token, channelId); var entity = model.Users.Select(x => { var user = new RestUser(client, x.Id); user.Update(x); return(user); }); return(entity.ToArray()); }
public static async Task <IReadOnlyCollection <RestUser> > GetModeratorsAsync(RestSimpleCommunity community, ulong userId) { if (!TokenHelper.TryGetToken(community.Client, userId, out RestTokenInfo info)) { throw new MissingScopeException("communities_edit"); } if (!info.Authorization.Scopes.Contains("communities_edit")) { throw new MissingScopeException("communities_edit"); } var model = await community.Client.RestClient.GetCommunityModeratorsInternalAsync(info.Token, community.Id); var entity = model.Moderators.Select(x => { var user = new RestUser(community.Client, x.Id); user.Update(x); return(user); }); return(entity.ToArray()); }
internal override void Update(Model model) { User = new RestUser(Client, model.User.Id); User.Update(model.User); base.Update(model); }