internal new static RestUserSubscription Create(BaseRestClient client, Model model)
        {
            var entity = new RestUserSubscription(client);

            entity.Update(model);
            return(entity);
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        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());
        }