Beispiel #1
0
        public static async Task <RestClip> GetClipAsync(BaseRestClient client, string clipId)
        {
            var token = TokenHelper.GetSingleToken(client);
            var model = await client.RestClient.GetClipInternalAsync(token, clipId);

            return(RestClip.Create(client, model));
        }
Beispiel #2
0
        internal static RestClip Create(BaseTwitchClient client, Model model)
        {
            var entity = new RestClip(client, model.Id);

            entity.Update(model);
            return(entity);
        }
Beispiel #3
0
        public static async Task <IReadOnlyCollection <RestClip> > GetFollowedClipsAsync(BaseTwitchClient client, ulong id, bool istrending, PageOptions paging = null, RequestOptions options = null)
        {
            var model = await client.ApiClient.GetFollowedClipsAsync(istrending, paging, options).ConfigureAwait(false);

            if (model.Clips != null)
            {
                return(model.Clips.Select(x => RestClip.Create(client, x)).ToArray());
            }
            return(null);
        }
Beispiel #4
0
        public static async Task <RestClip> GetClipAsync(BaseTwitchClient client, string clipId, RequestOptions options = null)
        {
            var model = await client.ApiClient.GetClipAsync(clipId, options).ConfigureAwait(false);

            if (model != null)
            {
                return(RestClip.Create(client, model));
            }
            return(null);
        }
Beispiel #5
0
        public static async Task <IReadOnlyCollection <RestClip> > GetTopClipsAsync(BaseTwitchClient client, Action <TopClipsParams> parameters, RequestOptions options = null)
        {
            var filledParams = new TopClipsParams();

            parameters.Invoke(filledParams);

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

            if (model.Clips != null)
            {
                return(model.Clips.Select(x => RestClip.Create(client, x)).ToArray());
            }
            return(null);
        }
Beispiel #6
0
        public static async Task <IReadOnlyCollection <RestClip> > GetTopClipsAsync(BaseRestClient client, Action <TopClipsParams> options)
        {
            var token = TokenHelper.GetSingleToken(client);

            var properties = new TopClipsParams();

            options.Invoke(properties);

            var model = await client.RestClient.GetTopClipsInternalAsync(token, properties);

            var entity = model.Clips.Select(x => RestClip.Create(client, x));

            return(entity.ToArray());
        }
Beispiel #7
0
        public static async Task <IReadOnlyCollection <RestClip> > GetFollowedClipsAsync(BaseRestClient client, ulong userId, bool istrending, uint limit)
        {
            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.GetFollowedClipsInternalAsync(info.Token, istrending, limit);

            var entity = model.Clips.Select(x => RestClip.Create(client, x));

            return(entity.ToArray());
        }