Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#nullable enable
namespace TwitchLib.Api.Helix.Models.EventSub;

/// <summary>
/// A class to represent the request query data for a <see href="https://dev.twitch.tv/docs/api/reference/#get-eventsub-subscriptions">Get EventSub Subscriptions</see> request.
/// </summary>
public class GetEventSubSubscriptionsRequest {
/// <summary>
/// Filter subscriptions by its status.
/// </summary>
public string? Status { get; set; }

/// <summary>
/// Filter subscriptions by subscription type (e.g., channel.update).
/// </summary>
public string? Type { get; set; }

/// <summary>
/// Filter subscriptions by user ID.
/// </summary>
public string? UserId { get; set; }

/// <summary>
/// Filter subscriptions to the one with the provided ID (as long as it is owned by the client making the request).
/// </summary>
public string? SubscriptionId { get; set; }

/// <summary>
/// The cursor used to get the next page of results.
/// </summary>
public string? After { get; set; }
}
30 changes: 30 additions & 0 deletions TwitchLib.Api.Helix/EventSub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public Task<CreateEventSubSubscriptionResponse> CreateEventSubSubscriptionAsync(
/// <param name="clientId">optional Client ID to override the use of the stored one in the TwitchAPI instance</param>
/// <param name="accessToken">optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="GetEventSubSubscriptionsResponse">Returns a list of your EventSub subscriptions.</returns>
[Obsolete("Use GetEventSubSubscriptionsAsync(GetEventSubSubscriptionsRequest, string, string) instead")]
public Task<GetEventSubSubscriptionsResponse> GetEventSubSubscriptionsAsync(string status = null, string type = null, string userId = null, string after = null, string clientId = null, string accessToken = null)
{
var getParams = new List<KeyValuePair<string, string>>();
Expand All @@ -136,6 +137,35 @@ public Task<GetEventSubSubscriptionsResponse> GetEventSubSubscriptionsAsync(stri
return TwitchGetGenericAsync<GetEventSubSubscriptionsResponse>("/eventsub/subscriptions", ApiVersion.Helix, getParams, accessToken, clientId);
}

/// <summary>
/// Gets a list of your EventSub subscriptions. The list is paginated and ordered by the oldest subscription first.
/// </summary>
/// <param name="request">Request parameters for the call.</param>
/// <param name="clientId">optional Client ID to override the use of the stored one in the TwitchAPI instance</param>
/// <param name="accessToken">optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="GetEventSubSubscriptionsResponse">Returns a list of your EventSub subscriptions.</returns>
public Task<GetEventSubSubscriptionsResponse> GetEventSubSubscriptionsAsync(GetEventSubSubscriptionsRequest request, string clientId = null, string accessToken = null)
{
var getParams = new List<KeyValuePair<string, string>>();

if (!string.IsNullOrWhiteSpace(request.Status))
getParams.Add(new KeyValuePair<string, string>("status", request.Status));

if (!string.IsNullOrWhiteSpace(request.Type))
getParams.Add(new KeyValuePair<string, string>("type", request.Type));

if (!string.IsNullOrWhiteSpace(request.UserId))
getParams.Add(new KeyValuePair<string, string>("user_id", request.UserId));

if (!string.IsNullOrWhiteSpace(request.SubscriptionId))
getParams.Add(new KeyValuePair<string, string>("subscription_id", request.SubscriptionId));

if (!string.IsNullOrWhiteSpace(request.After))
getParams.Add(new KeyValuePair<string, string>("after", request.After));

return TwitchGetGenericAsync<GetEventSubSubscriptionsResponse>("/eventsub/subscriptions", ApiVersion.Helix, getParams, accessToken, clientId);
}

/// <summary>
/// Deletes an EventSub subscription.
/// </summary>
Expand Down