Ejemplo n.º 1
0
        internal new static RestUserSubscription Create(BaseRestClient client, Model model)
        {
            var entity = new RestUserSubscription(client);

            entity.Update(model);
            return(entity);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }