com.github.twitch4j.helix.webhooks.topics.FollowsTopic Maven / Gradle / Ivy
The newest version!
package com.github.twitch4j.helix.webhooks.topics;
import com.github.twitch4j.helix.domain.FollowList;
import lombok.Getter;
import org.jetbrains.annotations.ApiStatus;
import java.util.Optional;
import java.util.TreeMap;
/**
* Notifies when a follows event occurs.
*
* @deprecated Twitch decommissioned this API; please migrate to EventSub
*/
@Getter
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.0.0")
public class FollowsTopic extends TwitchWebhookTopic {
public static final String PATH = "/users/follows";
private static TreeMap mapParameters(String fromId, String toId) {
TreeMap parameterMap = new TreeMap<>();
parameterMap.put("first", 1);
parameterMap.put("from_id", fromId);
parameterMap.put("to_id", toId);
return parameterMap;
}
/**
* @return The user who starts following someone.
*/
private Optional fromId;
/**
* @return The user who has a new follower.
*/
private Optional toId;
/**
* Notifies when a follows event occurs.
* At least one of fromId and toId is required.
*
* @param fromId Optional. Specifies the user who starts following someone.
* @param toId Optional. Specifies the user who has a new follower.
* @deprecated Will be decommissioned after 2021-09-16 in favor of EventSub
*/
@Deprecated
public FollowsTopic(String fromId, String toId) {
super(
PATH,
FollowList.class,
mapParameters(fromId, toId)
);
if(fromId == null && toId == null) throw new NullPointerException("At least one of fromId and toId is required.");
this.fromId = Optional.ofNullable(fromId);
this.toId = Optional.ofNullable(toId);
}
}