diff --git a/TwitchLib.Api.Helix.Models/EventSub/GetEventSubSubscriptionsRequest.cs b/TwitchLib.Api.Helix.Models/EventSub/GetEventSubSubscriptionsRequest.cs new file mode 100644 index 00000000..5cb0bcb1 --- /dev/null +++ b/TwitchLib.Api.Helix.Models/EventSub/GetEventSubSubscriptionsRequest.cs @@ -0,0 +1,32 @@ +#nullable enable +namespace TwitchLib.Api.Helix.Models.EventSub; + +/// +/// A class to represent the request query data for a Get EventSub Subscriptions request. +/// +public class GetEventSubSubscriptionsRequest { + /// + /// Filter subscriptions by its status. + /// + public string? Status { get; set; } + + /// + /// Filter subscriptions by subscription type (e.g., channel.update). + /// + public string? Type { get; set; } + + /// + /// Filter subscriptions by user ID. + /// + public string? UserId { get; set; } + + /// + /// Filter subscriptions to the one with the provided ID (as long as it is owned by the client making the request). + /// + public string? SubscriptionId { get; set; } + + /// + /// The cursor used to get the next page of results. + /// + public string? After { get; set; } +} \ No newline at end of file diff --git a/TwitchLib.Api.Helix/EventSub.cs b/TwitchLib.Api.Helix/EventSub.cs index bd71dd2a..c52f3487 100644 --- a/TwitchLib.Api.Helix/EventSub.cs +++ b/TwitchLib.Api.Helix/EventSub.cs @@ -117,6 +117,7 @@ public Task CreateEventSubSubscriptionAsync( /// optional Client ID to override the use of the stored one in the TwitchAPI instance /// optional access token to override the use of the stored one in the TwitchAPI instance /// Returns a list of your EventSub subscriptions. + [Obsolete("Use GetEventSubSubscriptionsAsync(GetEventSubSubscriptionsRequest, string, string) instead")] public Task GetEventSubSubscriptionsAsync(string status = null, string type = null, string userId = null, string after = null, string clientId = null, string accessToken = null) { var getParams = new List>(); @@ -136,6 +137,35 @@ public Task GetEventSubSubscriptionsAsync(stri return TwitchGetGenericAsync("/eventsub/subscriptions", ApiVersion.Helix, getParams, accessToken, clientId); } + /// + /// Gets a list of your EventSub subscriptions. The list is paginated and ordered by the oldest subscription first. + /// + /// Request parameters for the call. + /// optional Client ID to override the use of the stored one in the TwitchAPI instance + /// optional access token to override the use of the stored one in the TwitchAPI instance + /// Returns a list of your EventSub subscriptions. + public Task GetEventSubSubscriptionsAsync(GetEventSubSubscriptionsRequest request, string clientId = null, string accessToken = null) + { + var getParams = new List>(); + + if (!string.IsNullOrWhiteSpace(request.Status)) + getParams.Add(new KeyValuePair("status", request.Status)); + + if (!string.IsNullOrWhiteSpace(request.Type)) + getParams.Add(new KeyValuePair("type", request.Type)); + + if (!string.IsNullOrWhiteSpace(request.UserId)) + getParams.Add(new KeyValuePair("user_id", request.UserId)); + + if (!string.IsNullOrWhiteSpace(request.SubscriptionId)) + getParams.Add(new KeyValuePair("subscription_id", request.SubscriptionId)); + + if (!string.IsNullOrWhiteSpace(request.After)) + getParams.Add(new KeyValuePair("after", request.After)); + + return TwitchGetGenericAsync("/eventsub/subscriptions", ApiVersion.Helix, getParams, accessToken, clientId); + } + /// /// Deletes an EventSub subscription. ///