Package com.gmt2001.twitch.eventsub
Class EventSubSubscriptionType
java.lang.Object
com.gmt2001.twitch.eventsub.EventSubSubscriptionType
- All Implemented Interfaces:
Flow.Subscriber<EventSubInternalEvent>
- Direct Known Subclasses:
AutomodMessage
,ChannelFollow
,ChannelModerate
,ChannelPointsCustomRewardRedemptionAdd
,ChannelUpdate
,PredictionBegin
,PredictionEnd
,PredictionLock
,PredictionProgress
,Revocation
,StreamOffline
,StreamOnline
,Test
public abstract class EventSubSubscriptionType
extends Object
implements Flow.Subscriber<EventSubInternalEvent>
Abstract base class for EventSub Subscription Types
- Author:
- gmt2001
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Flow.Subscription
protected String
protected ZonedDateTime
protected EventSubSubscription
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
EventSubSubscriptionType
(EventSubSubscription subscription, String messageId, ZonedDateTime messageTimestamp) -
Method Summary
Modifier and TypeMethodDescriptioncreate()
Creates a new EventSub subscription, using the parameters provided via other methods or the constructor.delete()
Deletes the EventSub subscription matching the parameters in this object, if it can be found in the subscription listDeletes all EventSub subscriptions matching the parameters in this object, if it can be found in the subscription listReturns the subscription id if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states, otherwise nullReturns all subscription ids if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states, otherwise an empty listReturns the existing subscription, if one already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING statesboolean
Returns true if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING statesprotected abstract boolean
isMatch
(EventSubSubscription subscription) Returns true if the provided subscription is an instance of the current subscription type and matches the current subscription conditionsGets the message id, if the object was created as part of a notificationGets the message timestamp, if the object was created as part of a notificationfinal void
final void
protected void
protected void
protected void
protected void
final void
onNext
(EventSubInternalEvent item) final void
onSubscribe
(Flow.Subscription subscription) protected abstract EventSubSubscription
Compiles the parameters of this object into anEventSubSubscription
that can be createdprotected EventSubSubscription
Actually creates the proposedEventSubSubscription
protected EventSubTransport
Creates a transport for a proposed subscriptionprotected final void
Gets the subscription information, if the object was created as part of a notificationprotected abstract void
Validates that the provided parameters are acceptable for use inproposeSubscription()
-
Field Details
-
subscription
-
messageId
-
messageTimestamp
-
flowsubscription
-
-
Constructor Details
-
EventSubSubscriptionType
protected EventSubSubscriptionType() -
EventSubSubscriptionType
protected EventSubSubscriptionType(EventSubSubscription subscription, String messageId, ZonedDateTime messageTimestamp)
-
-
Method Details
-
subscribe
protected final void subscribe() -
onSubscribe
- Specified by:
onSubscribe
in interfaceFlow.Subscriber<EventSubInternalEvent>
-
onNext
- Specified by:
onNext
in interfaceFlow.Subscriber<EventSubInternalEvent>
-
onError
- Specified by:
onError
in interfaceFlow.Subscriber<EventSubInternalEvent>
-
onComplete
public final void onComplete()- Specified by:
onComplete
in interfaceFlow.Subscriber<EventSubInternalEvent>
-
onEventSubInternalEvent
-
onEventSubInternalNotificationEvent
-
onEventSubInternalRevocationEvent
-
onEventSubInternalVerificationEvent
-
create
Creates a new EventSub subscription, using the parameters provided via other methods or the constructor. If a matching subscription already exists, it is returned instead- Returns:
-
delete
Deletes the EventSub subscription matching the parameters in this object, if it can be found in the subscription list- Returns:
-
deleteAll
Deletes all EventSub subscriptions matching the parameters in this object, if it can be found in the subscription list- Returns:
-
proposeSubscription
Compiles the parameters of this object into anEventSubSubscription
that can be created- Returns:
-
proposeSubscriptionInternal
protected EventSubSubscription proposeSubscriptionInternal(String type, String version, Map<String, String> condition) Actually creates the proposedEventSubSubscription
- Parameters:
type
- The subscription type to createversion
- The subscription type versioncondition
- The conditions which will trigger notifications for this subscription- Returns:
-
proposeTransport
Creates a transport for a proposed subscription- Returns:
-
validateParameters
Validates that the provided parameters are acceptable for use inproposeSubscription()
- Throws:
IllegalArgumentException
- One of the parameters is not acceptable
-
isAlreadySubscribed
public boolean isAlreadySubscribed()Returns true if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states- Returns:
-
getExistingSubscription
Returns the existing subscription, if one already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states- Returns:
-
findMatchingSubscriptionId
Returns the subscription id if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states, otherwise null- Returns:
-
findMatchingSubscriptionIds
Returns all subscription ids if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states, otherwise an empty list- Returns:
-
isMatch
Returns true if the provided subscription is an instance of the current subscription type and matches the current subscription conditions- Parameters:
subscription
-- Returns:
-
subscription
Gets the subscription information, if the object was created as part of a notification- Returns:
-
messageId
Gets the message id, if the object was created as part of a notification- Returns:
-
messageTimestamp
Gets the message timestamp, if the object was created as part of a notification- Returns:
-