Exemplo n.º 1
0
        public static Task <ResponseWrapper <PagedResponse <ReadOnlyCollection <Video> > > > GetVideosByIdAsync(
            this ITwitchClient client,
            CancellationToken cancellationToken,
            params string[] ids
            )
        {
            // Validate parameters.
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }

            // Call the client
            return(client
                   .GetVideosByIdAsync(ids.AsEnumerable(), cancellationToken));
        }
Exemplo n.º 2
0
        public async Task Test_GetVideosById_Async(string videoIdsString)
        {
            // Validate parameters.
            if (string.IsNullOrWhiteSpace(videoIdsString))
            {
                throw new ArgumentNullException(nameof(videoIdsString));
            }

            // Parse the string into ids.
            IReadOnlyCollection <string> videoIds = videoIdsString.Split(',');

            // Create the client.
            ITwitchClient client = CreateTwitchClient();

            // Make the call.
            var response = await client
                           .GetVideosByIdAsync(videoIds, CancellationToken.None)
                           .ConfigureAwait(false);

            // Assert the length.
            Assert.Equal(videoIds.Count, response.Response.Data.Count);
        }
Exemplo n.º 3
0
        public static async Task <Video?> GetVideoByIdAsync(
            this ITwitchClient client,
            string id,
            CancellationToken cancellationToken
            )
        {
            // Validate parameters.
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            // Call the client, get the response.
            ResponseWrapper <PagedResponse <ReadOnlyCollection <Video> > > response = await client
                                                                                      .GetVideosByIdAsync(cancellationToken, id)
                                                                                      .ConfigureAwait(false);

            // Return the single item or default.
            return(response.Response.Data.SingleOrDefault());
        }