Skip to content

Commit

Permalink
feat: get channel info for multiple channels (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
AWAS666 authored Dec 17, 2024
1 parent 1df3d8e commit 4a32d29
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions TwitchLib.Api.Helix/Channels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,29 @@ public Channels(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandle
/// <summary>
/// Gets channel information for given user.
/// </summary>
/// <param name="broadcasterId">The ID of the broadcaster whose channel you want to get.</param>
/// <param name="broadcasterIds">list of user ids whose channel to get (max 100).</param>
/// <param name="accessToken">optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="GetChannelInformationResponse"></returns>
/// <exception cref="BadParameterException"></exception>
public Task<GetChannelInformationResponse> GetChannelInformationAsync(string broadcasterId, string accessToken = null)
public Task<GetChannelInformationResponse> GetChannelInformationAsync(List<string> broadcasterIds, string accessToken = null)
{
if (string.IsNullOrEmpty(broadcasterId))
throw new BadParameterException("broadcasterId must be set");
if (broadcasterIds.Count == 0 || broadcasterIds.Count > 100)
throw new BadParameterException("boardcasterIds must contain between 1 and 100 broadcasterIds.");

var getParams = new List<KeyValuePair<string, string>>
{
new("broadcaster_id", broadcasterId)
};
var getParams = broadcasterIds.Select(broadcasterId => new KeyValuePair<string, string>("broadcaster_id", broadcasterId)).ToList();

return TwitchGetGenericAsync<GetChannelInformationResponse>("/channels", ApiVersion.Helix, getParams, accessToken);
}

/// <summary>
/// Gets channel information for given user.
/// backwards compatible, queries just one
/// </summary>
/// <param name="broadcasterId">The ID of the broadcaster whose channel you want to get.</param>
/// <param name="accessToken">optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="GetChannelInformationResponse"></returns>
/// <exception cref="BadParameterException"></exception>
public Task<GetChannelInformationResponse> GetChannelInformationAsync(string broadcasterId, string accessToken = null) => GetChannelInformationAsync([broadcasterId], accessToken);

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

) expected

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

; expected

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

Invalid token ',' in class, record, struct, or interface member declaration

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

Invalid token ')' in class, record, struct, or interface member declaration

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

) expected

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

; expected

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

Invalid token ',' in class, record, struct, or interface member declaration

Check failure on line 57 in TwitchLib.Api.Helix/Channels.cs

View workflow job for this annotation

GitHub Actions / release-preview

Invalid token ')' in class, record, struct, or interface member declaration
#endregion

#region ModifyChannelInformation
Expand Down

0 comments on commit 4a32d29

Please sign in to comment.