package org.telegram.telegrambots.meta.api.methods.forum; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.NonNull; import lombok.Setter; import lombok.ToString; import lombok.experimental.Tolerate; import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; /** * @author Ruben Bermudez * @version 6.4 * Use this method to edit the name of the 'General' topic in a forum supergroup chat. * The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. * * Returns True on success. */ @EqualsAndHashCode(callSuper = false) @Getter @Setter @ToString @NoArgsConstructor(force = true) @AllArgsConstructor @Builder public class EditGeneralForumTopic extends BotApiMethodBoolean { public static final String PATH = "editGeneralForumTopic"; private static final String CHATID_FIELD = "chat_id"; private static final String NAME_FIELD = "name"; /** * Unique identifier for the target chat or username * of the target supergroup (in the format @supergroupusername) */ @JsonProperty(CHATID_FIELD) @NonNull private String chatId; /** * Optional. * New topic name, 1-128 characters */ @JsonProperty(NAME_FIELD) @NonNull private String name; @Tolerate public void setChatId(@NonNull Long chatId) { this.chatId = chatId.toString(); } @Override public void validate() throws TelegramApiValidationException { if (chatId.isEmpty()) { throw new TelegramApiValidationException("ChatId can't be empty", this); } if (name.isEmpty() || name.length() > 128) { throw new TelegramApiValidationException("Name must be between 1 and 128 characters", this); } } @Override public String getMethod() { return PATH; } public static class EditGeneralForumTopicBuilder { @Tolerate public EditGeneralForumTopicBuilder chatId(@NonNull Long chatId) { this.chatId = chatId.toString(); return this; } } }