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: add eventsub fields from may 2022 update #574

Merged
merged 1 commit into from May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Expand Up @@ -24,7 +24,7 @@ allprojects {
this as StandardJavadocDocletOptions
links(
"https://javadoc.io/doc/org.jetbrains/annotations/latest",
"https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/2.9.2",
"https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine/2.9.3",
"https://commons.apache.org/proper/commons-configuration/javadocs/v1.10/apidocs",
"https://javadoc.io/doc/com.github.vladimir-bukhtoyarov/bucket4j-core/7.5.0/",
"https://square.github.io/okhttp/4.x/okhttp/",
Expand Down
Expand Up @@ -24,6 +24,11 @@ public class ChannelBanEvent extends EventSubModerationEvent {
*/
private String reason;

/**
* The UTC date and time (in RFC3339 format) of when the user was banned or put in a timeout.
*/
private Instant bannedAt;

/**
* Will be null if permanent ban. If it is a timeout, this field shows when the timeout will end.
*/
Expand Down
Expand Up @@ -16,11 +16,6 @@
@EqualsAndHashCode(callSuper = true)
public class HypeTrainEndEvent extends HypeTrainEvent {

/**
* Current level of hype train event.
*/
private Integer level;

/**
* The timestamp at which the hype train ended.
*/
Expand Down
Expand Up @@ -28,6 +28,11 @@ public abstract class HypeTrainEvent extends EventSubChannelEvent {
*/
private List<Contribution> topContributions;

/**
* Current level of hype train event.
*/
private Integer level;

/**
* The timestamp at which the hype train started.
*/
Expand Down
Expand Up @@ -17,11 +17,6 @@
@EqualsAndHashCode(callSuper = true)
public class HypeTrainProgressEvent extends HypeTrainEvent {

/**
* Current level of hype train event.
*/
private Integer level;

/**
* The number of points contributed to the hype train at the current level.
*/
Expand Down
@@ -1,11 +1,13 @@
package com.github.twitch4j.eventsub.events;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

@Data
@Setter(AccessLevel.PRIVATE)
Expand All @@ -20,6 +22,16 @@ public class UserUpdateEvent extends EventSubUserEvent {
*/
private String email;

/**
* A Boolean value that determines whether Twitch has verified the user’s email address.
* Is true if Twitch has verified the email address; otherwise, false.
* <p>
* Note from Twitch: Ignore this field if the email field contains an empty string.
*/
@Accessors(fluent = true)
@JsonProperty("email_verified")
private Boolean isEmailVerified;

/**
* The user’s description.
*/
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class EventSubEventTest {
public void deserializeModerationEvent() {
ChannelBanEvent event = jsonToObject(
"{\"user_id\":\"1234\",\"user_login\":\"cool_user\",\"user_name\":\"Cool_User\",\"broadcaster_user_id\":\"1337\",\"broadcaster_user_login\":\"cooler_user\",\"broadcaster_user_name\":\"Cooler_User\",\"moderator_user_id\":\"1339\"," +
"\"moderator_user_login\":\"mod_user\",\"moderator_user_name\":\"Mod_User\",\"reason\":\"Offensive language\",\"ends_at\":\"2020-07-15T18:16:11.17106713Z\",\"is_permanent\":false}",
"\"moderator_user_login\":\"mod_user\",\"moderator_user_name\":\"Mod_User\",\"reason\":\"Offensive language\",\"banned_at\":\"2020-07-15T18:15:11.17106713Z\",\"ends_at\":\"2020-07-15T18:16:11.17106713Z\",\"is_permanent\":false}",
ChannelBanEvent.class
);

Expand All @@ -46,6 +46,7 @@ public void deserializeModerationEvent() {
assertEquals("Mod_User", event.getModeratorUserName());

assertEquals("Offensive language", event.getReason());
assertEquals(Instant.parse("2020-07-15T18:15:11.17106713Z"), event.getBannedAt());
assertEquals(Instant.parse("2020-07-15T18:16:11.17106713Z"), event.getEndsAt());
assertFalse(event.isPermanent());
}
Expand Down Expand Up @@ -377,13 +378,14 @@ public void deserializeComplexHypeTrainEvent() {
@DisplayName("Deserialize UserUpdateEvent")
public void deserializeComplexUserEvent() {
UserUpdateEvent event = jsonToObject(
"{\"user_id\":\"1337\",\"user_name\":\"cool_user\",\"email\":\"user@email.com\",\"description\":\"cool description\"}",
"{\"user_id\":\"1337\",\"user_name\":\"cool_user\",\"email\":\"user@email.com\",\"email_verified\":true,\"description\":\"cool description\"}",
UserUpdateEvent.class
);

assertEquals("1337", event.getUserId());
assertEquals("cool_user", event.getUserName());
assertEquals("user@email.com", event.getEmail());
assertTrue(event.isEmailVerified());
assertEquals("cool description", event.getDescription());
}

Expand Down