internal new static RestUserSubscription Create(BaseRestClient client, Model model) { var entity = new RestUserSubscription(client); entity.Update(model); return(entity); }
internal static async Task <IReadOnlyCollection <RestUserSubscription> > GetSubscribersAsync(BaseRestClient client, ulong channelId, bool ascending, uint limit, uint offset) { if (!TokenHelper.TryGetToken(client, channelId, out RestTokenInfo info)) { throw new MissingScopeException("channel_subscriptions"); } if (info.Authorization.Scopes.Contains("channel_subscriptions")) { throw new MissingScopeException("channel_subscriptions"); } var model = await client.RestClient.GetChannelSubscribersInternalAsync(info.Token, channelId, ascending, limit, offset); var entity = model.Subscriptions.Select(x => { var sub = new RestUserSubscription(client); sub.Update(x); return(sub); }); return(entity.ToArray()); }
internal static async Task <RestUserSubscription> GetSubscriberAsync(BaseRestClient client, ulong channelId, ulong userId) { if (!TokenHelper.TryGetToken(client, channelId, out RestTokenInfo info)) { throw new MissingScopeException("channel_subscriptions"); } if (info.Authorization.Scopes.Contains("channel_subscriptions")) { throw new MissingScopeException("channel_subscriptions"); } var model = await client.RestClient.GetSubscriberInternalAsync(info.Token, channelId, userId); if (model == null) { return(null); } var entity = new RestUserSubscription(client); entity.Update(model); return(entity); }
public static async Task <RestUserSubscription> GetSubscriberAsync(BaseTwitchClient client, ulong channelId, ulong userId, RequestOptions options = null) { var model = await client.ApiClient.GetChannelSubscriberAsync(channelId, userId, options).ConfigureAwait(false); return(RestUserSubscription.Create(client, model)); }
public static async Task <IReadOnlyCollection <RestUserSubscription> > GetSubscribersAsync(BaseTwitchClient client, ulong channelId, bool ascending, PageOptions paging = null, RequestOptions options = null) { var model = await client.ApiClient.GetChannelSubscribersAsync(channelId, ascending, paging, options).ConfigureAwait(false); return(model.Subscriptions.Select(x => RestUserSubscription.Create(client, x)).ToArray()); }