Exemple #1
0
        internal static RestStream Create(BaseRestClient client, Model model)
        {
            var entity = new RestStream(client, model.Id);

            entity.Update(model);
            return(entity);
        }
Exemple #2
0
        public static async Task <IReadOnlyCollection <RestStream> > FindStreamsAsync(BaseTwitchClient client, string query, bool?hls, PageOptions paging = null, RequestOptions options = null)
        {
            var model = await client.ApiClient.FindStreamsAsync(query, hls, paging, options).ConfigureAwait(false);

            if (model.Streams != null)
            {
                return(model.Streams.Select(x => RestStream.Create(client, x)).ToArray());
            }
            return(null);
        }
Exemple #3
0
        // Streams
        public static async Task <RestStream> GetStreamAsync(BaseTwitchClient client, ulong channelId, StreamType type, RequestOptions options = null)
        {
            var model = await client.ApiClient.GetStreamAsync(channelId, type, options).ConfigureAwait(false);

            if (model.Stream != null)
            {
                return(RestStream.Create(client, model.Stream));
            }
            return(null);
        }
Exemple #4
0
        public static async Task <IReadOnlyCollection <RestStream> > GetFollowedStreamsAsync(BaseTwitchClient client, StreamType type, PageOptions paging, RequestOptions options = null)
        {
            var model = await client.ApiClient.GetFollowedStreamsAsync(type, paging, options).ConfigureAwait(false);

            if (model.Streams != null)
            {
                return(model.Streams.Select(x => RestStream.Create(client, x)).ToArray());
            }
            return(null);
        }
Exemple #5
0
        internal virtual void Update(BaseTwitchClient client, Model model)
        {
            Stream = new RestStream(client, model.Stream.Id);
            Stream.Update(model.Stream);

            Image     = model.Image;
            Priority  = model.Priority;
            Scheduled = model.Scheduled;
            Sponsored = model.Sponsored;
            Text      = model.Text;
            Title     = model.Title;
        }
Exemple #6
0
        public static async Task <RestStream> GetStreamAsync(BaseRestClient client, ulong channelId, StreamType type)
        {
            var token = TokenHelper.GetSingleToken(client);
            var model = await client.RestClient.GetStreamInternalAsync(token, channelId, type);

            if (model.Stream == null)
            {
                return(null);
            }

            return(RestStream.Create(client, model.Stream));
        }
Exemple #7
0
        public static async Task <IReadOnlyCollection <RestStream> > GetStreamsAsync(BaseTwitchClient client, Action <GetStreamsParams> parameters, PageOptions paging = null, RequestOptions options = null)
        {
            var filledParams = new GetStreamsParams();

            parameters.Invoke(filledParams);

            var model = await client.ApiClient.GetStreamsAsync(filledParams, paging, options).ConfigureAwait(false);

            if (model.Streams != null)
            {
                return(model.Streams.Select(x => RestStream.Create(client, x)).ToArray());
            }
            return(null);
        }
Exemple #8
0
        internal static async Task <IReadOnlyCollection <RestStream> > SearchStreamsAsync(BaseRestClient client, string query, bool?hls, uint limit, uint offset)
        {
            var token = TokenHelper.GetSingleToken(client);
            var model = await client.RestClient.SearchStreamsInternalAsync(token, query, hls, limit, offset);

            if (model == null)
            {
                return(new List <RestStream>());
            }

            var entity = model.Streams.Select(x => RestStream.Create(client, x));

            return(entity.ToArray());
        }
Exemple #9
0
        internal static async Task <IReadOnlyCollection <RestStream> > GetStreamsAsync(BaseRestClient client, Action <GetStreamsParams> options)
        {
            var token = TokenHelper.GetSingleToken(client);

            var changes = new GetStreamsParams();

            options.Invoke(changes);

            var model = await client.RestClient.GetStreamsInternalAsync(token, changes);

            if (model == null)
            {
                return(new List <RestStream>());
            }

            var entity = model.Streams.Select(x => RestStream.Create(client, x));

            return(entity.ToArray());
        }
Exemple #10
0
        internal static async Task <IReadOnlyCollection <RestStream> > GetFollowedStreamsAsync(BaseRestClient client, ulong userId, StreamType type, uint limit, uint offset)
        {
            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.GetFollowedStreamsInternalAsync(info?.Token, type, limit, offset);

            if (model == null)
            {
                return(new List <RestStream>());
            }

            var entity = model.Streams.Select(x => RestStream.Create(client, x));

            return(entity.ToArray());
        }
Exemple #11
0
 public int GetHashCode(RestStream obj)
 => obj.GetHashCode();
Exemple #12
0
 public bool Equals(RestStream x, RestStream y)
 => x.Id == y.Id;