Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support channel subscription gift eventsub beta #366

Merged
merged 2 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,12 @@
package com.github.twitch4j.eventsub.condition;

import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Jacksonized
public class ChannelSubscriptionGiftCondition extends ChannelEventSubCondition {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.github.twitch4j.eventsub.events;

import com.github.twitch4j.common.enums.SubscriptionPlan;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.jetbrains.annotations.Nullable;

@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class ChannelSubscriptionGiftEvent extends EventSubUserChannelEvent {

/**
* The tier of subscriptions in the subscription gift.
*/
private SubscriptionPlan tier;

/**
* The number of subscriptions in the subscription gift.
*/
private Integer total;

/**
* The number of subscriptions gifted by this user in the channel.
* This value is null for anonymous gifts or if the gifter has opted out of sharing this information.
*/
@Nullable
private Integer cumulativeTotal;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.github.twitch4j.eventsub.subscriptions;

import com.github.twitch4j.common.annotation.Unofficial;
import com.github.twitch4j.eventsub.condition.ChannelSubscriptionGiftCondition;
import com.github.twitch4j.eventsub.events.ChannelSubscriptionGiftEvent;

/**
* The channel.subscription.gift subscription type sends a notification when a user gives one or more gifted subscriptions in a channel.
* <p>
* Must have channel:read:subscriptions scope.
* <p>
* Unless otherwise noted, EventSub subscriptions that were released as a public beta will be available for 30 days after their v1 version is released.
* Subscriptions should be updated to v1 during this timeframe. Any active beta subscriptions beyond 30 days will be automatically deleted.
*/
@Unofficial
public class BetaChannelSubscriptionGiftType implements SubscriptionType<ChannelSubscriptionGiftCondition, ChannelSubscriptionGiftCondition.ChannelSubscriptionGiftConditionBuilder<?, ?>, ChannelSubscriptionGiftEvent> {

@Override
public String getName() {
return "channel.subscription.gift";
}

@Override
public String getVersion() {
return "beta";
}

@Override
public ChannelSubscriptionGiftCondition.ChannelSubscriptionGiftConditionBuilder<?, ?> getConditionBuilder() {
return ChannelSubscriptionGiftCondition.builder();
}

@Override
public Class<ChannelSubscriptionGiftEvent> getEventClass() {
return ChannelSubscriptionGiftEvent.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class SubscriptionTypes {
public final ChannelRaidType CHANNEL_RAID;
public final ChannelSubscribeType CHANNEL_SUBSCRIBE;
@Unofficial public final BetaChannelUnsubscribeType BETA_CHANNEL_UNSUBSCRIBE;
@Unofficial public final BetaChannelSubscriptionGiftType BETA_CHANNEL_SUBSCRIPTION_GIFT;
public final ChannelUnbanType CHANNEL_UNBAN;
public final ChannelUpdateType CHANNEL_UPDATE;
public final HypeTrainBeginType HYPE_TRAIN_BEGIN;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class SubscriptionTypes {
CHANNEL_RAID = new ChannelRaidType(),
CHANNEL_SUBSCRIBE = new ChannelSubscribeType(),
BETA_CHANNEL_UNSUBSCRIBE = new BetaChannelUnsubscribeType(),
BETA_CHANNEL_SUBSCRIPTION_GIFT = new BetaChannelSubscriptionGiftType(),
CHANNEL_UNBAN = new ChannelUnbanType(),
CHANNEL_UPDATE = new ChannelUpdateType(),
HYPE_TRAIN_BEGIN = new HypeTrainBeginType(),
Expand Down