Skip to content

Commit

Permalink
feat: add user_id and type args to getEventSubSubscriptions (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy committed Jul 6, 2022
1 parent 7b9e2e6 commit 8630876
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
Expand Up @@ -6,7 +6,9 @@
import com.github.twitch4j.eventsub.EventSubSubscription;
import com.github.twitch4j.eventsub.EventSubSubscriptionStatus;
import com.github.twitch4j.eventsub.domain.RedemptionStatus;
import com.github.twitch4j.eventsub.subscriptions.SubscriptionType;
import com.github.twitch4j.helix.domain.*;
import com.github.twitch4j.helix.interceptor.EventSubSubscriptionNameExpander;
import com.github.twitch4j.helix.webhooks.domain.WebhookRequest;
import com.netflix.hystrix.HystrixCommand;
import feign.*;
Expand Down Expand Up @@ -562,22 +564,51 @@ HystrixCommand<Void> deleteEventSubSubscription(

/**
* Get a list of your EventSub subscriptions.
* <p>
* The list is paginated and ordered by the oldest subscription first.
* <p>
* Use the status, type, and user_id query parameters to filter the list of subscriptions that are returned.
* The filters are mutually exclusive; the request fails if you specify more than one filter.
*
* @param authToken Required: App Access Token.
* @param status Optional: Include this parameter to filter subscriptions by their status.
* @param type Optional: Include this parameter to filter subscriptions by subscription type.
* @param userId Optional: Include this parameter to filter subscriptions by user ID in the condition object.
* @param after Optional: Cursor for forward pagination.
* @param limit Optional: Maximum number of objects to return. Maximum: 100. Minimum: 10.
* @return EventSubSubscriptionList
*/
@RequestLine("GET /eventsub/subscriptions?status={status}&after={after}&first={first}")
@RequestLine("GET /eventsub/subscriptions?status={status}&type={type}&user_id={user_id}&after={after}&first={first}")
@Headers("Authorization: Bearer {token}")
HystrixCommand<EventSubSubscriptionList> getEventSubSubscriptions(
@Param("token") String authToken,
@Param("status") EventSubSubscriptionStatus status,
@Param(value = "type", expander = EventSubSubscriptionNameExpander.class) SubscriptionType<?, ?, ?> type,
@Param("user_id") String userId,
@Param("after") String after,
@Param("first") Integer limit
);

/**
* Get a list of your EventSub subscriptions.
*
* @param authToken Required: App Access Token.
* @param status Optional: Include this parameter to filter subscriptions by their status.
* @param after Optional: Cursor for forward pagination.
* @param limit Optional: Maximum number of objects to return. Maximum: 100. Minimum: 10.
* @return EventSubSubscriptionList
* @deprecated in favor of {@link #getEventSubSubscriptions(String, EventSubSubscriptionStatus, SubscriptionType, String, String, Integer)}
*/
@Deprecated
default HystrixCommand<EventSubSubscriptionList> getEventSubSubscriptions(
@Param("token") String authToken,
@Param("status") EventSubSubscriptionStatus status,
@Param("after") String after,
@Param("first") Integer limit
) {
return getEventSubSubscriptions(authToken, status, null, null, after, limit);
}

/**
* Gets information about your Extensions; either the current version or a specified version.
*
Expand Down Expand Up @@ -1637,7 +1668,6 @@ HystrixCommand<PredictionsList> endPrediction(
* @return RaidRequestList
* @see com.github.twitch4j.auth.domain.TwitchScopes#HELIX_CHANNEL_RAIDS_MANAGE
*/
@Unofficial // currently in open beta
@RequestLine("POST /raids?from_broadcaster_id={from_broadcaster_id}&to_broadcaster_id={to_broadcaster_id}")
@Headers("Authorization: Bearer {token}")
HystrixCommand<RaidRequestList> startRaid(
Expand All @@ -1655,7 +1685,6 @@ HystrixCommand<RaidRequestList> startRaid(
* @param broadcasterId The ID of the broadcaster that sent the raiding party.
* @return 204 No Content upon a successful raid cancel call
*/
@Unofficial // currently in open beta
@RequestLine("DELETE /raids?broadcaster_id={broadcaster_id}")
@Headers("Authorization: Bearer {token}")
HystrixCommand<Void> cancelRaid(
Expand Down
@@ -0,0 +1,13 @@
package com.github.twitch4j.helix.interceptor;

import com.github.twitch4j.eventsub.subscriptions.SubscriptionType;
import feign.Param;

public class EventSubSubscriptionNameExpander implements Param.Expander {
@Override
public String expand(Object value) {
if (value instanceof SubscriptionType<?, ?, ?>)
return ((SubscriptionType<?, ?, ?>) value).getName();
return null;
}
}
Expand Up @@ -42,6 +42,8 @@ public void getStreams() {
System.getenv("APP_ACCESS_TOKEN"),
null,
null,
null,
null,
null
).execute();
assertTrue(subList.getTotal() > 0, "Sub list size was " + subList.getTotal());
Expand Down

0 comments on commit 8630876

Please sign in to comment.