diff --git a/pom.xml b/pom.xml index 00cce776a..fae2185ad 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,7 @@ telegrambots-longpolling telegrambots-webhook telegrambots-client + telegrambots-client-jetty-adapter telegrambots-springboot-longpolling-starter telegrambots-springboot-webhook-starter telegrambots-extensions diff --git a/telegrambots-abilities/src/main/java/org/telegram/telegrambots/abilitybots/api/bot/DefaultAbilities.java b/telegrambots-abilities/src/main/java/org/telegram/telegrambots/abilitybots/api/bot/DefaultAbilities.java index bc2bfec47..9cba6e6d3 100644 --- a/telegrambots-abilities/src/main/java/org/telegram/telegrambots/abilitybots/api/bot/DefaultAbilities.java +++ b/telegrambots-abilities/src/main/java/org/telegram/telegrambots/abilitybots/api/bot/DefaultAbilities.java @@ -454,13 +454,12 @@ private long getUserIdSendError(String username, MessageContext ctx) { } } - private Optional send(String message, MessageContext ctx, String... args) { - return bot.silent.send(getLocalizedMessage(message, ctx.user().getLanguageCode(), args), ctx.chatId()); + return bot.silent.send(getLocalizedMessage(message, ctx.user().getLanguageCode(), (Object[]) args), ctx.chatId()); } private Optional sendMd(String message, MessageContext ctx, String... args) { - return bot.silent.sendMd(getLocalizedMessage(message, ctx.user().getLanguageCode(), args), ctx.chatId()); + return bot.silent.sendMd(getLocalizedMessage(message, ctx.user().getLanguageCode(), (Object[]) args), ctx.chatId()); } private Optional send(String message, Update upd) { @@ -468,7 +467,7 @@ private Optional send(String message, Update upd) { return bot.silent.send(getLocalizedMessage(message, AbilityUtils.getUser(upd).getLanguageCode()), chatId); } - protected File downloadFileWithId(String fileId) throws TelegramApiException { + private File downloadFileWithId(String fileId) throws TelegramApiException { return bot.telegramClient.downloadFile(bot.telegramClient.execute(GetFile.builder().fileId(fileId).build())); } } diff --git a/telegrambots-client-jetty-adapter/pom.xml b/telegrambots-client-jetty-adapter/pom.xml new file mode 100644 index 000000000..48fabdc66 --- /dev/null +++ b/telegrambots-client-jetty-adapter/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + + org.telegram + Bots + 7.11.0 + + + Telegram Bots Client Jetty HttpClient adapter + https://github.com/rubenlagus/TelegramBots + Use Jetty HttpClient instead of OkHttp to perform API calls + + telegrambots-client-jetty-adapter + jar + + + 17 + ${java.version} + ${java.version} + + UTF-8 + UTF-8 + + 12.0.12 + + + + + + org.eclipse.jetty + jetty-client + ${jetty.version} + + + + + + + org.telegram + telegrambots-meta + ${project.parent.version} + + + org.eclipse.jetty + jetty-client + + + commons-io + commons-io + + + org.projectlombok + lombok + provided + + + + com.squareup.okhttp3 + mockwebserver + test + + + + + ${project.basedir}/target + ${project.build.directory}/classes + ${project.artifactId}-${project.version} + ${project.build.directory}/test-classes + ${project.basedir}/src/main/java + + + maven-clean-plugin + + + maven-assembly-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-dependency-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + diff --git a/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java new file mode 100644 index 000000000..6180d76ae --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java @@ -0,0 +1,236 @@ +package org.telegram.telegrambots.client; + +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; +import org.telegram.telegrambots.meta.api.methods.groupadministration.SetChatPhoto; +import org.telegram.telegrambots.meta.api.methods.send.SendAnimation; +import org.telegram.telegrambots.meta.api.methods.send.SendAudio; +import org.telegram.telegrambots.meta.api.methods.send.SendDocument; +import org.telegram.telegrambots.meta.api.methods.send.SendMediaGroup; +import org.telegram.telegrambots.meta.api.methods.send.SendPaidMedia; +import org.telegram.telegrambots.meta.api.methods.send.SendPhoto; +import org.telegram.telegrambots.meta.api.methods.send.SendSticker; +import org.telegram.telegrambots.meta.api.methods.send.SendVideo; +import org.telegram.telegrambots.meta.api.methods.send.SendVideoNote; +import org.telegram.telegrambots.meta.api.methods.send.SendVoice; +import org.telegram.telegrambots.meta.api.methods.stickers.AddStickerToSet; +import org.telegram.telegrambots.meta.api.methods.stickers.CreateNewStickerSet; +import org.telegram.telegrambots.meta.api.methods.stickers.ReplaceStickerInSet; +import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumbnail; +import org.telegram.telegrambots.meta.api.methods.stickers.UploadStickerFile; +import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook; +import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageMedia; +import org.telegram.telegrambots.meta.api.objects.File; +import org.telegram.telegrambots.meta.api.objects.message.Message; +import org.telegram.telegrambots.meta.exceptions.TelegramApiException; +import org.telegram.telegrambots.meta.generics.TelegramClient; + +import java.io.InputStream; +import java.io.Serializable; +import java.util.List; +import java.util.concurrent.ExecutionException; + +/** + * Abstract client implementation which delegates all synchronous methods to the async methods. Preferable for implementations + */ +public abstract class AbstractTelegramClient implements TelegramClient { + @Override + public > T execute(Method method) throws TelegramApiException { + try { + return executeAsync(method).get(); + } catch (Exception e) { + throw mapException(e, method.getMethod()); + } + } + + @Override + public Message execute(SendDocument sendDocument) throws TelegramApiException { + try { + return executeAsync(sendDocument).get(); + } catch (Exception e) { + throw mapException(e, sendDocument.getMethod()); + } + } + + @Override + public Message execute(SendPhoto sendPhoto) throws TelegramApiException { + try { + return executeAsync(sendPhoto).get(); + } catch (Exception e) { + throw mapException(e, sendPhoto.getMethod()); + } + } + + @Override + public Boolean execute(SetWebhook setWebhook) throws TelegramApiException { + try { + return executeAsync(setWebhook).get(); + } catch (Exception e) { + throw mapException(e, setWebhook.getMethod()); + } + } + + @Override + public Message execute(SendVideo sendVideo) throws TelegramApiException { + try { + return executeAsync(sendVideo).get(); + } catch (Exception e) { + throw mapException(e, sendVideo.getMethod()); + } + } + + @Override + public Message execute(SendVideoNote sendVideoNote) throws TelegramApiException { + try { + return executeAsync(sendVideoNote).get(); + } catch (Exception e) { + throw mapException(e, sendVideoNote.getMethod()); + } + } + + @Override + public Message execute(SendSticker sendSticker) throws TelegramApiException { + try { + return executeAsync(sendSticker).get(); + } catch (Exception e) { + throw mapException(e, sendSticker.getMethod()); + } + } + + @Override + public Message execute(SendAudio sendAudio) throws TelegramApiException { + try { + return executeAsync(sendAudio).get(); + } catch (Exception e) { + throw mapException(e, sendAudio.getMethod()); + } + } + + @Override + public Message execute(SendVoice sendVoice) throws TelegramApiException { + try { + return executeAsync(sendVoice).get(); + } catch (Exception e) { + throw mapException(e, sendVoice.getMethod()); + } + } + + @Override + public List execute(SendMediaGroup sendMediaGroup) throws TelegramApiException { + try { + return executeAsync(sendMediaGroup).get(); + } catch (Exception e) { + throw mapException(e, sendMediaGroup.getMethod()); + } + } + + @Override + public List execute(SendPaidMedia sendPaidMedia) throws TelegramApiException { + try { + return executeAsync(sendPaidMedia).get(); + } catch (Exception e) { + throw mapException(e, sendPaidMedia.getMethod()); + } + } + + @Override + public Boolean execute(SetChatPhoto setChatPhoto) throws TelegramApiException { + try { + return executeAsync(setChatPhoto).get(); + } catch (Exception e) { + throw mapException(e, setChatPhoto.getMethod()); + } + } + + @Override + public Boolean execute(AddStickerToSet addStickerToSet) throws TelegramApiException { + try { + return executeAsync(addStickerToSet).get(); + } catch (Exception e) { + throw mapException(e, addStickerToSet.getMethod()); + } + } + + @Override + public Boolean execute(ReplaceStickerInSet replaceStickerInSet) throws TelegramApiException { + try { + return executeAsync(replaceStickerInSet).get(); + } catch (Exception e) { + throw mapException(e, replaceStickerInSet.getMethod()); + } + } + + @Override + public Boolean execute(SetStickerSetThumbnail setStickerSetThumbnail) throws TelegramApiException { + try { + return executeAsync(setStickerSetThumbnail).get(); + } catch (Exception e) { + throw mapException(e, setStickerSetThumbnail.getMethod()); + } + } + + @Override + public Boolean execute(CreateNewStickerSet createNewStickerSet) throws TelegramApiException { + try { + return executeAsync(createNewStickerSet).get(); + } catch (Exception e) { + throw mapException(e, createNewStickerSet.getMethod()); + } + } + + @Override + public File execute(UploadStickerFile uploadStickerFile) throws TelegramApiException { + try { + return executeAsync(uploadStickerFile).get(); + } catch (Exception e) { + throw mapException(e, uploadStickerFile.getMethod()); + } + } + + @Override + public Serializable execute(EditMessageMedia editMessageMedia) throws TelegramApiException { + try { + return executeAsync(editMessageMedia).get(); + } catch (Exception e) { + throw mapException(e, editMessageMedia.getMethod()); + } + } + + @Override + public Message execute(SendAnimation sendAnimation) throws TelegramApiException { + try { + return executeAsync(sendAnimation).get(); + } catch (Exception e) { + throw mapException(e, sendAnimation.getMethod()); + } + } + + @Override + public java.io.File downloadFile(File file) throws TelegramApiException { + try { + return downloadFileAsync(file).get(); + } catch (Exception e) { + throw mapException(e, " download file "); + } + } + + @Override + public InputStream downloadFileAsStream(File file) throws TelegramApiException { + try { + return downloadFileAsStreamAsync(file).get(); + } catch (Exception e) { + throw mapException(e, " download file "); + } + } + + private TelegramApiException mapException(Exception e, String method) { + if (e instanceof ExecutionException) { + if (e.getCause() instanceof TelegramApiException) { + return (TelegramApiException) e.getCause(); + } else { + return new TelegramApiException("Unable to execute " + method + " method", e.getCause()); + } + } else { + return new TelegramApiException("Unable to execute " + method + " method", e); + } + } +} diff --git a/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/ThrowingConsumer.java b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/ThrowingConsumer.java new file mode 100644 index 000000000..6a3684b2f --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/ThrowingConsumer.java @@ -0,0 +1,9 @@ +package org.telegram.telegrambots.client; + +/** + * Special type of Consumer that may throw a checked exception defined by parameter E + */ +@FunctionalInterface +public interface ThrowingConsumer { + void accept(T t) throws E; +} diff --git a/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/jetty/JettyMultipartBuilder.java b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/jetty/JettyMultipartBuilder.java new file mode 100644 index 000000000..903be8567 --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/jetty/JettyMultipartBuilder.java @@ -0,0 +1,149 @@ +package org.telegram.telegrambots.client.jetty; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.jetty.client.InputStreamRequestContent; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.client.PathRequestContent; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.StringRequestContent; +import org.eclipse.jetty.http.HttpFields; +import org.eclipse.jetty.http.MultiPart; +import org.telegram.telegrambots.meta.api.objects.InputFile; +import org.telegram.telegrambots.meta.api.objects.media.InputMedia; +import org.telegram.telegrambots.meta.api.objects.media.paid.InputPaidMedia; +import org.telegram.telegrambots.meta.api.objects.stickers.InputSticker; + +import java.io.IOException; +import java.util.List; + +/** + * @author Valeriy Kucherenko + * @since 05.09.2024 + */ +public class JettyMultipartBuilder { + private final MultiPartRequestContent multiPart = new MultiPartRequestContent(); + private final ObjectMapper mapper; + + public JettyMultipartBuilder(ObjectMapper mapper) { + this.mapper = mapper; + } + + public MultiPartRequestContent build() { + multiPart.close(); + return multiPart; + } + + /** + * Add field to the builder if value is not null + * @param fieldName the field name to add to the multipart + * @param value the nullable value to add + * @return the builder + */ + public JettyMultipartBuilder addPart(String fieldName, String value) { + if (value != null) { + multiPart.addPart(new MultiPart.ContentSourcePart(fieldName, null, HttpFields.EMPTY, new StringRequestContent(value))); + } + return this; + } + + /** + * Add field to the builder if value is not null. The value is converted using toString() + * @param fieldName the field name to add to the multipart + * @param value the nullable value to add + * @return the builder + */ + public JettyMultipartBuilder addPart(String fieldName, Object value) { + if (value != null) { + this.addPart(fieldName, value.toString()); + } + return this; + } + + /** + * Add field to the builder if value is not null. The value is converted using ObjectMapper.writeValueAsString() + * @param fieldName the field name to add to the multipart + * @param value the nullable value to add + * @return the builder + */ + public JettyMultipartBuilder addJsonPart(String fieldName, Object value) throws JsonProcessingException { + if (value != null) { + this.addPart(fieldName, mapper.writeValueAsString(value)); + } + return this; + } + + public JettyMultipartBuilder addInputFile(String fileField, InputFile file, boolean addField) throws IOException { + if (file == null) { + return this; + } + + if (file.isNew()) { + Request.Content body = null; + if (file.getNewMediaFile() != null) { + body = new PathRequestContent("application/octet-stream", file.getNewMediaFile().toPath()); + } else if (file.getNewMediaStream() != null) { + body = new InputStreamRequestContent("application/octet-stream", file.getNewMediaStream()); + } + if (body != null) { + multiPart.addPart(new MultiPart.ContentSourcePart(file.getMediaName(), file.getMediaName(), HttpFields.EMPTY, body)); + } + } + + if (addField) { + this.addPart(fileField, file.getAttachName()); + } + + return this; + } + + public JettyMultipartBuilder addMedia(InputMedia media) throws IOException { + if (media == null) { + return this; + } + + if (media.isNewMedia()) { + Request.Content body = null; + if (media.getNewMediaFile() != null) { + body = new PathRequestContent("application/octet-stream", media.getNewMediaFile().toPath()); + } else if (media.getNewMediaStream() != null) { + body = new InputStreamRequestContent("application/octet-stream", media.getNewMediaStream()); + } + if (body != null) { + multiPart.addPart(new MultiPart.ContentSourcePart(media.getMediaName(), media.getMediaName(), HttpFields.EMPTY, body)); + } + } + + return this; + } + + public JettyMultipartBuilder addMedia(InputPaidMedia media) throws IOException { + if (media == null) { + return this; + } + + if (media.isNewMedia()) { + Request.Content body = null; + if (media.getNewMediaFile() != null) { + body = new PathRequestContent("application/octet-stream", media.getNewMediaFile().toPath()); + } else if (media.getNewMediaStream() != null) { + body = new InputStreamRequestContent("application/octet-stream", media.getNewMediaStream()); + } + if (body != null) { + multiPart.addPart(new MultiPart.ContentSourcePart(media.getMediaName(), media.getMediaName(), HttpFields.EMPTY, body)); + } + } + + return this; + } + + public JettyMultipartBuilder addInputStickers(String stickersField, List stickers) throws IOException { + for (InputSticker sticker : stickers) { + addInputFile(null, sticker.getSticker(), false); + } + + addJsonPart(stickersField, stickers); + + return this; + } +} diff --git a/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/jetty/JettyTelegramClient.java b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/jetty/JettyTelegramClient.java new file mode 100644 index 000000000..9095f6135 --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/main/java/org/telegram/telegrambots/client/jetty/JettyTelegramClient.java @@ -0,0 +1,708 @@ +package org.telegram.telegrambots.client.jetty; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.NonNull; +import lombok.SneakyThrows; +import org.apache.commons.io.FileUtils; +import org.eclipse.jetty.client.CompletableResponseListener; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.InputStreamResponseListener; +import org.eclipse.jetty.client.Request; +import org.eclipse.jetty.client.StringRequestContent; +import org.telegram.telegrambots.client.AbstractTelegramClient; +import org.telegram.telegrambots.client.ThrowingConsumer; +import org.telegram.telegrambots.meta.TelegramUrl; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; +import org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod; +import org.telegram.telegrambots.meta.api.methods.groupadministration.SetChatPhoto; +import org.telegram.telegrambots.meta.api.methods.send.SendAnimation; +import org.telegram.telegrambots.meta.api.methods.send.SendAudio; +import org.telegram.telegrambots.meta.api.methods.send.SendDocument; +import org.telegram.telegrambots.meta.api.methods.send.SendMediaBotMethod; +import org.telegram.telegrambots.meta.api.methods.send.SendMediaGroup; +import org.telegram.telegrambots.meta.api.methods.send.SendPaidMedia; +import org.telegram.telegrambots.meta.api.methods.send.SendPhoto; +import org.telegram.telegrambots.meta.api.methods.send.SendSticker; +import org.telegram.telegrambots.meta.api.methods.send.SendVideo; +import org.telegram.telegrambots.meta.api.methods.send.SendVideoNote; +import org.telegram.telegrambots.meta.api.methods.send.SendVoice; +import org.telegram.telegrambots.meta.api.methods.stickers.AddStickerToSet; +import org.telegram.telegrambots.meta.api.methods.stickers.CreateNewStickerSet; +import org.telegram.telegrambots.meta.api.methods.stickers.ReplaceStickerInSet; +import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumbnail; +import org.telegram.telegrambots.meta.api.methods.stickers.UploadStickerFile; +import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook; +import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageMedia; +import org.telegram.telegrambots.meta.api.objects.File; +import org.telegram.telegrambots.meta.api.objects.media.InputMedia; +import org.telegram.telegrambots.meta.api.objects.media.InputMediaAnimation; +import org.telegram.telegrambots.meta.api.objects.media.InputMediaAudio; +import org.telegram.telegrambots.meta.api.objects.media.InputMediaDocument; +import org.telegram.telegrambots.meta.api.objects.media.InputMediaVideo; +import org.telegram.telegrambots.meta.api.objects.media.paid.InputPaidMedia; +import org.telegram.telegrambots.meta.api.objects.media.paid.InputPaidMediaVideo; +import org.telegram.telegrambots.meta.api.objects.message.Message; +import org.telegram.telegrambots.meta.exceptions.TelegramApiException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; + +/** + * @author Valeriy Kucherenko + * @since 05.09.2024 + */ +public class JettyTelegramClient extends AbstractTelegramClient { + private final HttpClient client; + private final String botToken; + private final TelegramUrl telegramUrl; + private final ObjectMapper objectMapper; + + public JettyTelegramClient(@NonNull ObjectMapper objectMapper, @NonNull HttpClient client, + @NonNull String botToken, @NonNull TelegramUrl telegramUrl) { + this.objectMapper = objectMapper; + this.client = client; + this.botToken = botToken; + this.telegramUrl = telegramUrl; + } + + public JettyTelegramClient(HttpClient client, String botToken, TelegramUrl telegramUrl) { + this(new ObjectMapper(), client, botToken, telegramUrl); + } + + public JettyTelegramClient(HttpClient client, String botToken) { + this(client, botToken, TelegramUrl.DEFAULT_URL); + } + + public JettyTelegramClient(String botToken, TelegramUrl telegramUrl) { + this(createHttpClient(), botToken, telegramUrl); + } + + public JettyTelegramClient(String botToken) { + this(createHttpClient(), botToken); + } + + @Override + public > CompletableFuture executeAsync(Method method) throws TelegramApiException { + if (method == null) { + throw new TelegramApiException("Parameter method can not be null"); + } + method.validate(); + + try { + URI url = buildUrl(method.getMethod()); + String body = objectMapper.writeValueAsString(method); + + Request request = client.POST(url) + .headers(httpFields -> { + httpFields.add("charset", StandardCharsets.UTF_8.name()); + httpFields.add("content-type", "application/json"); + }) + .body(new StringRequestContent("application/json", body)); + + return sendRequest(method, request); + } catch (IOException e) { + throw new TelegramApiException("Unable to execute " + method.getMethod() + " method", e); + } + } + + @Override + public CompletableFuture executeAsync(SendDocument sendDocument) { + return executeMediaMethod(sendDocument, builder -> { + builder.addPart(SendDocument.CAPTION_FIELD, sendDocument.getCaption()) + .addPart(SendDocument.PARSEMODE_FIELD, sendDocument.getParseMode()) + .addPart(SendDocument.DISABLECONTENTTYPEDETECTION_FIELD, sendDocument.getDisableContentTypeDetection()) + .addPart(SendDocument.BUSINESS_CONNECTION_ID_FIELD, sendDocument.getBusinessConnectionId()) + .addJsonPart(SendDocument.CAPTION_ENTITIES_FIELD, sendDocument.getCaptionEntities()); + + if (sendDocument.getThumbnail() != null) { + builder.addInputFile(SendDocument.THUMBNAIL_FIELD, sendDocument.getThumbnail(), false); + builder.addPart(SendDocument.THUMBNAIL_FIELD, sendDocument.getThumbnail().getAttachName()); + } + }); + } + + @Override + public CompletableFuture executeAsync(SendPhoto sendPhoto) { + return executeMediaMethod(sendPhoto, builder -> builder + .addPart(SendPhoto.CAPTION_FIELD, sendPhoto.getCaption()) + .addPart(SendPhoto.PARSE_MODE_FIELD, sendPhoto.getParseMode()) + .addPart(SendPhoto.HAS_SPOILER_FIELD, sendPhoto.getHasSpoiler()) + .addPart(SendPhoto.BUSINESS_CONNECTION_ID_FIELD, sendPhoto.getBusinessConnectionId()) + .addPart(SendPhoto.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendPhoto.getShowCaptionAboveMedia()) + .addJsonPart(SendPhoto.CAPTION_ENTITIES_FIELD, sendPhoto.getCaptionEntities())); + } + + @Override + public CompletableFuture executeAsync(SetWebhook setWebhook) { + try { + assertParamNotNull(setWebhook, "method"); + + setWebhook.validate(); + + URI url = buildUrl(setWebhook.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(SetWebhook.URL_FIELD, setWebhook.getUrl()) + .addPart(SetWebhook.MAX_CONNECTIONS_FIELD, setWebhook.getMaxConnections()) + .addJsonPart(SetWebhook.ALLOWED_UPDATES_FIELD, setWebhook.getAllowedUpdates()) + .addPart(SetWebhook.IP_ADDRESS_FIELD, setWebhook.getIpAddress()) + .addPart(SetWebhook.DROP_PENDING_UPDATES_FIELD, setWebhook.getDropPendingUpdates()) + .addPart(SetWebhook.SECRET_TOKEN_FIELD, setWebhook.getSecretToken()); + + builder.addInputFile(SetWebhook.CERTIFICATE_FIELD, setWebhook.getCertificate(), true); + + Request httpPost = client.POST(url).body(builder.build()); + + return sendRequest(setWebhook, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + setWebhook.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(SendVideo sendVideo) { + return executeMediaMethod(sendVideo, builder -> { + builder + .addPart(SendVideo.CAPTION_FIELD, sendVideo.getCaption()) + .addPart(SendVideo.PARSE_MODE_FIELD, sendVideo.getParseMode()) + .addPart(SendVideo.SUPPORTS_STREAMING_FIELD, sendVideo.getSupportsStreaming()) + .addPart(SendVideo.DURATION_FIELD, sendVideo.getDuration()) + .addPart(SendVideo.WIDTH_FIELD, sendVideo.getWidth()) + .addPart(SendVideo.HEIGHT_FIELD, sendVideo.getHeight()) + .addPart(SendVideo.HAS_SPOILER_FIELD, sendVideo.getHasSpoiler()) + .addPart(SendVideo.BUSINESS_CONNECTION_ID_FIELD, sendVideo.getBusinessConnectionId()) + .addPart(SendVideo.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendVideo.getShowCaptionAboveMedia()) + .addJsonPart(SendVideo.CAPTION_ENTITIES_FIELD, sendVideo.getCaptionEntities()); + + if (sendVideo.getThumbnail() != null) { + builder.addInputFile(SendVideo.THUMBNAIL_FIELD, sendVideo.getThumbnail(), false); + builder.addPart(SendVideo.THUMBNAIL_FIELD, sendVideo.getThumbnail().getAttachName()); + } + }); + } + + @Override + public CompletableFuture executeAsync(SendVideoNote sendVideoNote) { + return executeMediaMethod(sendVideoNote, builder -> { + builder + .addPart(SendVideoNote.DURATION_FIELD, sendVideoNote.getDuration()) + .addPart(SendVideoNote.LENGTH_FIELD, sendVideoNote.getLength()) + .addPart(SendVideoNote.BUSINESS_CONNECTION_ID_FIELD, sendVideoNote.getBusinessConnectionId()); + + if (sendVideoNote.getThumbnail() != null) { + builder.addInputFile(SendVideoNote.THUMBNAIL_FIELD, sendVideoNote.getThumbnail(), false); + builder.addPart(SendVideoNote.THUMBNAIL_FIELD, sendVideoNote.getThumbnail().getAttachName()); + } + }); + } + + @Override + public CompletableFuture executeAsync(SendSticker sendSticker) { + return executeMediaMethod( + sendSticker, + builder -> builder + .addPart(SendSticker.EMOJI_FIELD, sendSticker.getEmoji()) + .addPart(SendSticker.BUSINESS_CONNECTION_ID_FIELD, sendSticker.getBusinessConnectionId()) + ); + } + + @Override + public CompletableFuture executeAsync(SendAudio sendAudio) { + return executeMediaMethod(sendAudio, builder -> { + builder + .addPart(SendAudio.PERFORMER_FIELD, sendAudio.getPerformer()) + .addPart(SendAudio.TITLE_FIELD, sendAudio.getTitle()) + .addPart(SendAudio.DURATION_FIELD, sendAudio.getDuration()) + .addPart(SendAudio.CAPTION_FIELD, sendAudio.getCaption()) + .addPart(SendAudio.PARSE_MODE_FIELD, sendAudio.getParseMode()) + .addPart(SendAudio.BUSINESS_CONNECTION_ID_FIELD, sendAudio.getBusinessConnectionId()) + .addJsonPart(SendAudio.CAPTION_ENTITIES_FIELD, sendAudio.getCaptionEntities()); + + if (sendAudio.getThumbnail() != null) { + builder.addInputFile(SendAudio.THUMBNAIL_FIELD, sendAudio.getThumbnail(), false); + builder.addPart(SendAudio.THUMBNAIL_FIELD, sendAudio.getThumbnail().getAttachName()); + } + }); + } + + @Override + public CompletableFuture executeAsync(SendVoice sendVoice) { + return executeMediaMethod(sendVoice, builder -> builder + .addPart(SendVoice.DURATION_FIELD, sendVoice.getDuration()) + .addPart(SendVoice.CAPTION_FIELD, sendVoice.getCaption()) + .addPart(SendVoice.PARSE_MODE_FIELD, sendVoice.getParseMode()) + .addPart(SendVoice.BUSINESS_CONNECTION_ID_FIELD, sendVoice.getBusinessConnectionId()) + .addPart(SendVoice.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendVoice.getShowCaptionAboveMedia()) + .addJsonPart(SendVoice.CAPTION_ENTITIES_FIELD, sendVoice.getCaptionEntities())); + } + + @Override + public CompletableFuture> executeAsync(SendPaidMedia sendPaidMedia) { + try { + assertParamNotNull(sendPaidMedia, "sendPaidMedia"); + sendPaidMedia.validate(); + + URI url = buildUrl(sendPaidMedia.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + addPaidInputData(builder, SendPaidMedia.MEDIA_FIELD, sendPaidMedia.getMedia()); + + builder.addPart(SendPaidMedia.CHAT_ID_FIELD, sendPaidMedia.getChatId()) + .addPart(SendPaidMedia.STAR_COUNT_FIELD, sendPaidMedia.getStarCount()) + .addPart(SendPaidMedia.CAPTION_FIELD, sendPaidMedia.getCaption()) + .addPart(SendPaidMedia.PARSE_MODE_FIELD, sendPaidMedia.getParseMode()) + .addPart(SendPaidMedia.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendPaidMedia.getShowCaptionAboveMedia()) + .addPart(SendPaidMedia.DISABLE_NOTIFICATION_FIELD, sendPaidMedia.getDisableNotification()) + .addPart(SendPaidMedia.PROTECT_CONTENT_FIELD, sendPaidMedia.getProtectContent()) + .addPart(SendPaidMedia.BUSINESS_CONNECTION_ID_FIELD, sendPaidMedia.getBusinessConnectionId()) + .addPart(SendPaidMedia.PAYLOAD_FIELD, sendPaidMedia.getPayload()) + .addPart(SendPaidMedia.ALLOW_PAID_BROADCAST_FIELD, sendPaidMedia.getAllowPaidBroadcast()) + .addJsonPart(SendPaidMedia.CAPTION_ENTITIES_FIELD, sendPaidMedia.getCaptionEntities()) + .addJsonPart(SendPaidMedia.REPLY_MARKUP_FIELD, sendPaidMedia.getReplyMarkup()) + .addJsonPart(SendPaidMedia.REPLY_PARAMETERS_FIELD, sendPaidMedia.getReplyParameters()); + + + Request httpPost = client.POST(url).body(builder.build()); + + //For some reason java is having problem with casting ArrayList to List here + return sendRequest(sendPaidMedia, httpPost).thenApply(list -> list); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + sendPaidMedia.getMethod(), e)); + } + } + + @Override + public CompletableFuture> executeAsync(SendMediaGroup sendMediaGroup) { + try { + assertParamNotNull(sendMediaGroup, "sendMediaGroup"); + sendMediaGroup.validate(); + + URI url = buildUrl(sendMediaGroup.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + addInputData(builder, SendMediaGroup.MEDIA_FIELD, sendMediaGroup.getMedias()); + + builder.addPart(SendMediaGroup.CHAT_ID_FIELD, sendMediaGroup.getChatId()) + .addPart(SendMediaGroup.DISABLE_NOTIFICATION_FIELD, sendMediaGroup.getDisableNotification()) + .addPart(SendMediaGroup.REPLY_TO_MESSAGE_ID_FIELD, sendMediaGroup.getReplyToMessageId()) + .addPart(SendMediaGroup.MESSAGE_THREAD_ID_FIELD, sendMediaGroup.getMessageThreadId()) + .addPart(SendMediaGroup.ALLOW_SENDING_WITHOUT_REPLY_FIELD, sendMediaGroup.getAllowSendingWithoutReply()) + .addPart(SendMediaGroup.PROTECT_CONTENT_FIELD, sendMediaGroup.getProtectContent()) + .addPart(SendMediaGroup.BUSINESS_CONNECTION_ID_FIELD, sendMediaGroup.getBusinessConnectionId()) + .addPart(SendMediaGroup.MESSAGE_EFFECT_ID_FIELD, sendMediaGroup.getMessageEffectId()) + .addPart(SendMediaGroup.ALLOW_PAID_BROADCAST_FIELD, sendMediaGroup.getAllowSendingWithoutReply()) + .addJsonPart(SendMediaGroup.REPLY_MARKUP_FIELD, sendMediaGroup.getReplyMarkup()) + .addJsonPart(SendMediaGroup.REPLY_PARAMETERS_FIELD, sendMediaGroup.getReplyParameters()); + + + Request httpPost = client.POST(url).body(builder.build()); + + //For some reason java is having problem with casting ArrayList to List here + return sendRequest(sendMediaGroup, httpPost).thenApply(list -> list); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + sendMediaGroup.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(SendAnimation sendAnimation) { + return executeMediaMethod(sendAnimation, builder -> { + builder.addPart(SendAnimation.DURATION_FIELD, sendAnimation.getDuration()) + .addPart(SendAnimation.WIDTH_FIELD, sendAnimation.getWidth()) + .addPart(SendAnimation.HEIGHT_FIELD, sendAnimation.getHeight()) + .addPart(SendAnimation.CAPTION_FIELD, sendAnimation.getCaption()) + .addJsonPart(SendAnimation.CAPTION_ENTITIES_FIELD, sendAnimation.getCaptionEntities()) + .addPart(SendAnimation.PARSE_MODE_FIELD, sendAnimation.getParseMode()) + .addPart(SendAnimation.HAS_SPOILER_FIELD, sendAnimation.getHasSpoiler()) + .addPart(SendAnimation.BUSINESS_CONNECTION_ID_FIELD, sendAnimation.getBusinessConnectionId()) + .addPart(SendAnimation.SHOW_CAPTION_ABOVE_MEDIA_FIELD, sendAnimation.getShowCaptionAboveMedia()) + .addJsonPart(SendAnimation.REPLY_MARKUP_FIELD, sendAnimation.getReplyMarkup()); + + if (sendAnimation.getThumbnail() != null) { + builder.addInputFile(SendAnimation.THUMBNAIL_FIELD, sendAnimation.getThumbnail(), false); + builder.addPart(SendAnimation.THUMBNAIL_FIELD, sendAnimation.getThumbnail().getAttachName()); + } + } + + ); + } + + @Override + public CompletableFuture executeAsync(SetChatPhoto setChatPhoto) { + try { + assertParamNotNull(setChatPhoto, "setChatPhoto"); + setChatPhoto.validate(); + + URI url = buildUrl(setChatPhoto.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(SetChatPhoto.CHATID_FIELD, setChatPhoto.getChatId()); + + builder.addInputFile(SetChatPhoto.PHOTO_FIELD, setChatPhoto.getPhoto(), false); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(setChatPhoto, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + setChatPhoto.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(AddStickerToSet addStickerToSet) { + try { + assertParamNotNull(addStickerToSet, "addStickerToSet"); + addStickerToSet.validate(); + + URI url = buildUrl(addStickerToSet.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(AddStickerToSet.USERID_FIELD, addStickerToSet.getUserId()) + .addPart(AddStickerToSet.NAME_FIELD, addStickerToSet.getName()); + + builder.addInputStickers(AddStickerToSet.STICKER_FIELD, Collections.singletonList(addStickerToSet.getSticker())); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(addStickerToSet, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + addStickerToSet.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(ReplaceStickerInSet replaceStickerInSet) { + try { + assertParamNotNull(replaceStickerInSet, "replaceStickerInSet"); + replaceStickerInSet.validate(); + + URI url = buildUrl(replaceStickerInSet.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(ReplaceStickerInSet.USERID_FIELD, replaceStickerInSet.getUserId()) + .addPart(ReplaceStickerInSet.OLD_STICKER_FIELD, replaceStickerInSet.getOldSticker()) + .addPart(ReplaceStickerInSet.NAME_FIELD, replaceStickerInSet.getName()); + + builder.addInputStickers(ReplaceStickerInSet.STICKER_FIELD, Collections.singletonList(replaceStickerInSet.getSticker())); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(replaceStickerInSet, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + replaceStickerInSet.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(SetStickerSetThumbnail setStickerSetThumbnail) { + try { + assertParamNotNull(setStickerSetThumbnail, "setStickerSetThumbail"); + setStickerSetThumbnail.validate(); + + URI url = buildUrl(setStickerSetThumbnail.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(SetStickerSetThumbnail.USER_ID_FIELD, setStickerSetThumbnail.getUserId()) + .addPart(SetStickerSetThumbnail.NAME_FIELD, setStickerSetThumbnail.getName()) + .addPart(SetStickerSetThumbnail.FORMAT_FIELD, setStickerSetThumbnail.getFormat()) + .addPart(SetStickerSetThumbnail.THUMBNAIL_FIELD, setStickerSetThumbnail.getThumbnail()); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(setStickerSetThumbnail, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + @Override + public CompletableFuture executeAsync(CreateNewStickerSet createNewStickerSet) { + try { + assertParamNotNull(createNewStickerSet, "createNewStickerSet"); + createNewStickerSet.validate(); + + URI url = buildUrl(createNewStickerSet.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(CreateNewStickerSet.USER_ID_FIELD, createNewStickerSet.getUserId()) + .addPart(CreateNewStickerSet.NAME_FIELD, createNewStickerSet.getName()) + .addPart(CreateNewStickerSet.TITLE_FIELD, createNewStickerSet.getTitle()) + .addPart(CreateNewStickerSet.STICKER_TYPE_FIELD, createNewStickerSet.getStickerType()) + .addPart(CreateNewStickerSet.NEEDS_REPAINTING_FIELD, createNewStickerSet.getNeedsRepainting()) + .addInputStickers(CreateNewStickerSet.STICKERS_FIELD, createNewStickerSet.getStickers()); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(createNewStickerSet, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + createNewStickerSet.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(UploadStickerFile uploadStickerFile) { + try { + assertParamNotNull(uploadStickerFile, "uploadStickerFile"); + uploadStickerFile.validate(); + + URI url = buildUrl(uploadStickerFile.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder + .addPart(UploadStickerFile.USERID_FIELD, uploadStickerFile.getUserId()) + .addPart(UploadStickerFile.STICKER_FORMAT_FIELD, uploadStickerFile.getStickerFormat()) + .addInputFile(UploadStickerFile.STICKER_FIELD, uploadStickerFile.getSticker(), true); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(uploadStickerFile, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + uploadStickerFile.getMethod(), e)); + } + } + + @Override + public CompletableFuture executeAsync(EditMessageMedia editMessageMedia) { + try { + assertParamNotNull(editMessageMedia, "editMessageMedia"); + editMessageMedia.validate(); + + URI url = buildUrl(editMessageMedia.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addPart(EditMessageMedia.CHAT_ID_FIELD, editMessageMedia.getChatId()) + .addPart(EditMessageMedia.MESSAGE_ID_FIELD, editMessageMedia.getMessageId()) + .addPart(EditMessageMedia.INLINE_MESSAGE_ID_FIELD, editMessageMedia.getInlineMessageId()) + .addPart(EditMessageMedia.BUSINESS_CONNECTION_ID_FIELD, editMessageMedia.getBusinessConnectionId()) + .addJsonPart(EditMessageMedia.REPLY_MARKUP_FIELD, editMessageMedia.getReplyMarkup()); + + addInputData(builder, EditMessageMedia.MEDIA_FIELD, editMessageMedia.getMedia(), true); + + Request httpPost = client.POST(url).body(builder.build()); + return sendRequest(editMessageMedia, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + editMessageMedia.getMethod(), e)); + } + } + + @Override + public CompletableFuture downloadFileAsync(File file) { + return downloadFileAsStreamAsync(file).thenApply(stream -> { + try { + java.io.File outputFile = getTempFile(); + FileUtils.copyInputStreamToFile(stream, outputFile); + return outputFile; + } catch (IOException e) { + throw new RuntimeException("Unable to write file to disk", e); + } catch (TelegramApiException e) { + throw new RuntimeException(e); + } + }); + } + + @Override + public CompletableFuture downloadFileAsStreamAsync(File file) { + try { + if (file == null) { + throw new TelegramApiException("Parameter file can not be null"); + } + + InputStreamResponseListener listener = new InputStreamResponseListener(); + client.newRequest(file.getFileUrl(botToken)).send(listener); + return CompletableFuture.completedFuture(listener.getInputStream()); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private > CompletableFuture sendRequest( + Method method, Request request + ) { + var future = new CompletableResponseListener(request).send(); + return future.thenApply(response -> { + try { + return method.deserializeResponse(response.getContentAsString()); + } catch (TelegramApiRequestException e) { + throw new CompletionException(e); + } + }); + } + + /** + * execute a SendMediaBotMethod and adds the following fields: + *
    + *
  • chat_id
  • + *
  • chat_id
  • + *
  • message_thread_id
  • + *
  • reply_to_message_id
  • + *
  • disable_notification
  • + *
  • protect_content
  • + *
  • allow_sending_without_reply
  • + *
+ * + * @param method the method so execute + * @param setup a lambda to add additional fields to the multipart request + */ + private > CompletableFuture executeMediaMethod( + Method method, + ThrowingConsumer setup + ) { + try { + assertParamNotNull(method, "method"); + assertParamNotNull(setup, "setup"); + + method.validate(); + + URI url = buildUrl(method.getMethod()); + + JettyMultipartBuilder builder = new JettyMultipartBuilder(objectMapper); + + builder.addInputFile(method.getFileField(), method.getFile(), true); + + builder.addPart(SendMediaBotMethod.CHAT_ID_FIELD, method.getChatId()) + .addPart(SendMediaBotMethod.MESSAGE_THREAD_ID_FIELD, method.getMessageThreadId()) + .addPart(SendMediaBotMethod.REPLY_TO_MESSAGE_ID_FIELD, method.getReplyToMessageId()) + .addPart(SendMediaBotMethod.DISABLE_NOTIFICATION_FIELD, method.getDisableNotification()) + .addPart(SendMediaBotMethod.PROTECT_CONTENT_FIELD, method.getProtectContent()) + .addPart(SendMediaBotMethod.ALLOW_SENDING_WITHOUT_REPLY_FIELD, method.getAllowSendingWithoutReply()) + .addPart(SendMediaBotMethod.MESSAGE_EFFECT_ID_FIELD, method.getMessageEffectId()) + .addJsonPart(SendMediaBotMethod.REPLY_PARAMETERS_FIELD, method.getReplyParameters()) + .addJsonPart(SendMediaBotMethod.REPLY_MARKUP_FIELD, method.getReplyMarkup()); + + setup.accept(builder); + + Request httpPost = client.POST(url).body(builder.build()); + + return sendRequest(method, httpPost); + } catch (TelegramApiException e) { + return CompletableFuture.failedFuture(e); + } catch (IOException e) { + return CompletableFuture.failedFuture(new TelegramApiException("Unable to execute " + method.getMethod(), e)); + } + } + + @SneakyThrows(URISyntaxException.class) + private URI buildUrl(String methodPath) { + String path = "/bot" + botToken; + if (telegramUrl.isTestServer()) { + path += "/test"; + } + path += "/" + methodPath; + + URI uri = new URI(telegramUrl.getSchema(), null, telegramUrl.getHost(), telegramUrl.getPort(), + path, null, null); + return uri; + } + + private void addInputData(JettyMultipartBuilder builder, String mediaField, InputMedia media, boolean addField) throws IOException { + if (media.isNewMedia()) { + builder.addMedia(media); + } + + if (media instanceof InputMediaAudio audio) { + if (audio.getThumbnail() != null) { + builder.addInputFile(InputMediaAudio.THUMBNAIL_FIELD, audio.getThumbnail(), false); + } + } else if (media instanceof InputMediaDocument document) { + if (document.getThumbnail() != null) { + builder.addInputFile(InputMediaDocument.THUMBNAIL_FIELD, document.getThumbnail(), false); + } + } else if (media instanceof InputMediaVideo video) { + if (video.getThumbnail() != null) { + builder.addInputFile(InputMediaVideo.THUMBNAIL_FIELD, video.getThumbnail(), false); + } + } else if (media instanceof InputMediaAnimation animation) { + if (animation.getThumbnail() != null) { + builder.addInputFile(InputMediaAnimation.THUMBNAIL_FIELD, animation.getThumbnail(), false); + } + } + + if (addField) { + builder.addJsonPart(mediaField, media); + } + } + + private void addInputData(JettyMultipartBuilder builder, String mediaField, InputPaidMedia media, boolean addField) throws IOException { + if (media.isNewMedia()) { + builder.addMedia(media); + } + + if (media instanceof InputPaidMediaVideo document) { + if (document.getThumbnail() != null) { + builder.addInputFile(InputMediaDocument.THUMBNAIL_FIELD, document.getThumbnail(), false); + } + } + + if (addField) { + builder.addJsonPart(mediaField, media); + } + } + + private void addPaidInputData(JettyMultipartBuilder builder, String mediaField, List media) throws IOException { + for (InputPaidMedia inputMedia : media) { + addInputData(builder, null, inputMedia, false); + } + + builder.addJsonPart(mediaField, media); + } + + private void addInputData(JettyMultipartBuilder builder, String mediaField, List media) throws IOException { + for (InputMedia inputMedia : media) { + addInputData(builder, null, inputMedia, false); + } + + builder.addJsonPart(mediaField, media); + } + + private void assertParamNotNull(Object param, String paramName) throws TelegramApiException { + if (param == null) { + throw new TelegramApiException("Parameter " + paramName + " can not be null"); + } + } + + private java.io.File getTempFile() throws TelegramApiException { + try { + return java.io.File.createTempFile(Long.toString(System.currentTimeMillis()), ".tmp"); + } catch (IOException e) { + throw new TelegramApiException("Error downloading file", e); + } + } + + @SneakyThrows + private static HttpClient createHttpClient() { + HttpClient httpClient = new HttpClient(); + httpClient.start(); + return httpClient; + } +} diff --git a/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/ApiResponseTestBuilder.java b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/ApiResponseTestBuilder.java new file mode 100644 index 000000000..16430d363 --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/ApiResponseTestBuilder.java @@ -0,0 +1,72 @@ +package org.telegram.telegrambots.client; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.telegram.telegrambots.meta.api.objects.ApiResponse; + +import java.lang.reflect.Field; + +public class ApiResponseTestBuilder { + private static ObjectMapper mapper = new ObjectMapper(); + private ApiResponse response = new ApiResponse<>(); + + private final Field resultField; + private final Field okField; + private final Field errorCodeField; + private final Field errorDescriptionField; + private final Field parametersField; + + public ApiResponseTestBuilder() { + try { + resultField = ApiResponse.class.getDeclaredField("result"); + resultField.setAccessible(true); + + okField = ApiResponse.class.getDeclaredField("ok"); + okField.setAccessible(true); + + errorCodeField = ApiResponse.class.getDeclaredField("errorCode"); + errorCodeField.setAccessible(true); + + errorDescriptionField = ApiResponse.class.getDeclaredField("errorDescription"); + errorDescriptionField.setAccessible(true); + + parametersField = ApiResponse.class.getDeclaredField("parameters"); + parametersField.setAccessible(true); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + + public String buildJson() { + try { + return mapper.writeValueAsString(response); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + + public ApiResponseTestBuilder setResult(T result) { + return setField(resultField, result); + } + + public ApiResponseTestBuilder setOk(boolean ok) { + return setField(okField, ok); + } + + public ApiResponseTestBuilder setErrorCode(int errorCode) { + return setField(errorCodeField, errorCode); + } + + public ApiResponseTestBuilder setErrorDescription(String errorDescription) { + return setField(errorDescriptionField, errorDescription); + } + + private ApiResponseTestBuilder setField(Field field, Object value) { + try { + field.set(response, value); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + return this; + } +} \ No newline at end of file diff --git a/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestData.java b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestData.java new file mode 100644 index 000000000..ae5db4548 --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestData.java @@ -0,0 +1,62 @@ +package org.telegram.telegrambots.client; + +import org.telegram.telegrambots.meta.api.objects.User; +import org.telegram.telegrambots.meta.api.objects.chat.Chat; +import org.telegram.telegrambots.meta.api.objects.chat.ChatFullInfo; + +public class TestData { + public static final Chat GROUP_FULL_CHAT = ChatFullInfo + .builder() + .id(10L) + .type("group") + .title("My Group Chat") + .description("Awesome description") + .build(); + + public static final Chat GROUP_CHAT = Chat + .builder() + .id(10L) + .type("group") + .title("My Group Chat") + .build(); + + public static final User TEST_USER = new User( + 1000L, + "Test", + false, + "User", + "testUser", + "en", + null, + null, + null, + false, + null, + null, + false + ); + public static final Chat PRIVATE_CHAT = ChatFullInfo + .builder() + .id(TEST_USER.getId()) + .type("private") + .firstName(TEST_USER.getFirstName()) + .lastName(TEST_USER.getLastName()) + .userName(TEST_USER.getUserName()) + .build(); + + public static final User BOT_USER = new User( + 5000L, + "My Bot", + true, + null, + "myBot", + null, + true, + true, + false, + null, + false, + null, + false + ); +} diff --git a/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestTelegramClientIntegration.java b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestTelegramClientIntegration.java new file mode 100644 index 000000000..aeb2988ed --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestTelegramClientIntegration.java @@ -0,0 +1,304 @@ +package org.telegram.telegrambots.client; + +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.Dispatcher; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.MockitoAnnotations; +import org.telegram.telegrambots.client.jetty.JettyTelegramClient; +import org.telegram.telegrambots.meta.TelegramUrl; +import org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod; +import org.telegram.telegrambots.meta.api.methods.send.*; +import org.telegram.telegrambots.meta.api.objects.InputFile; +import org.telegram.telegrambots.meta.api.objects.message.Message; +import org.telegram.telegrambots.meta.exceptions.TelegramApiException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; + +import java.io.File; +import java.io.InputStream; +import java.io.Serializable; +import java.nio.charset.StandardCharsets; + +import static org.junit.jupiter.api.Assertions.*; + +public class TestTelegramClientIntegration { + private MockWebServer webServer; + + private static final String TOKEN = "testToken"; + + private AutoCloseable mockitoCloseable; + + JettyTelegramClient client; + + @BeforeEach + void setUp() { + mockitoCloseable = MockitoAnnotations.openMocks(this); + webServer = new MockWebServer(); + HttpUrl mockUrl = webServer.url(""); + TelegramUrl telegramUrl = TelegramUrl.builder().schema(mockUrl.scheme()).host(mockUrl.host()).port(mockUrl.port()).build(); + client = new JettyTelegramClient(TOKEN, telegramUrl); + } + + @AfterEach + void tearDown() throws Exception { + mockitoCloseable.close(); + } + + @Test + void testSendMessage() throws TelegramApiException { + SendMessage method = new SendMessage("someChatId", "someText"); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendPhoto() throws TelegramApiException { + SendPhoto method = new SendPhoto("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendVideo() throws TelegramApiException { + SendVideo method = new SendVideo("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendVideoNote() throws TelegramApiException { + SendVideoNote method = new SendVideoNote("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendSticker() throws TelegramApiException { + SendSticker method = new SendSticker("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendAudio() throws TelegramApiException { + SendAudio method = new SendAudio("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendVoice() throws TelegramApiException { + SendVoice method = new SendVoice("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testSendAnimation() throws TelegramApiException { + SendAnimation method = new SendAnimation("someChatId", new InputFile(getTestFile())); + Message responseMessage = new Message(); + responseMessage.setChat(TestData.GROUP_CHAT); + responseMessage.setFrom(TestData.TEST_USER); + responseMessage.setText("someText"); + + mockMethod(method, responseMessage); + + Message parsedMessage = client.execute(method); + assertEquals(responseMessage, parsedMessage); + } + + @Test + void testDownloadFileAsStream() throws Exception { + try (InputStream is = client.downloadFileAsStream("someFile")) { + String text = new String(is.readAllBytes(), StandardCharsets.UTF_8); + assertNotNull(text); + assertFalse(text.isEmpty()); + } + } + + @Test + void testSendMessageException() { + SendMessage method = new SendMessage("someChatId", "someText"); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendDocumentException() { + SendDocument method = new SendDocument("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendPhotoException() { + SendPhoto method = new SendPhoto("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendVideoException() { + SendVideo method = new SendVideo("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendVideoNoteException() { + SendVideoNote method = new SendVideoNote("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendStickerException() { + SendSticker method = new SendSticker("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendAudioException() { + SendAudio method = new SendAudio("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendVoiceException() { + SendVoice method = new SendVoice("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @Test + void testSendAnimationException() { + SendAnimation method = new SendAnimation("someChatId", new InputFile(getTestFile())); + + mockErrorMethod(method); + + TelegramApiRequestException exception = Assertions.assertThrows(TelegramApiRequestException.class, () -> client.execute(method)); + assertEquals(404, exception.getErrorCode()); + } + + @NotNull + private File getTestFile() { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + return file; + } + + > void mockMethod(Method method, T result) { + webServer.setDispatcher(getDispatcher(method, true, result)); + } + + private > Dispatcher getDispatcher(Method method, boolean success, T result) { + return new Dispatcher() { + @Override + public MockResponse dispatch(RecordedRequest request) { + try { + String path = request.getPath(); + if (path.endsWith(method.getMethod())) { + String response; + if (success) { + response = new ApiResponseTestBuilder().setOk(true).setResult(result).buildJson(); + } else { + response = new ApiResponseTestBuilder<>().setOk(false).setErrorCode(404).setErrorDescription("Method not found").buildJson(); + } + return new MockResponse() + .addHeader("Content-Type", "application/json; charset=utf-8") + .addHeader("Cache-Control", "no-cache") + .setBody(response); + } + } catch (Exception e) { + return new MockResponse().setResponseCode(404).setBody(new ApiResponseTestBuilder<>().setOk(false).setErrorCode(404).setErrorDescription("Method not found").buildJson()); + } + return new MockResponse().setResponseCode(404).setBody(new ApiResponseTestBuilder<>().setOk(false).setErrorCode(404).setErrorDescription("Method not found").buildJson()); + } + }; + } + + private > void mockErrorMethod(Method method) { + webServer.setDispatcher(getDispatcher(method, false, null)); + } +} diff --git a/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestTelegramMultipartBuilder.java b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestTelegramMultipartBuilder.java new file mode 100644 index 000000000..3bec5dae6 --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/test/java/org/telegram/telegrambots/client/TestTelegramMultipartBuilder.java @@ -0,0 +1,165 @@ +package org.telegram.telegrambots.client; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.jetty.client.MultiPartRequestContent; +import org.eclipse.jetty.http.MultiPart; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.telegram.telegrambots.client.jetty.JettyMultipartBuilder; +import org.telegram.telegrambots.meta.api.objects.InputFile; +import org.telegram.telegrambots.meta.api.objects.Location; +import org.telegram.telegrambots.meta.api.objects.media.InputMediaDocument; +import org.telegram.telegrambots.meta.api.objects.stickers.InputSticker; + +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.util.ArrayDeque; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +public class TestTelegramMultipartBuilder { + private JettyMultipartBuilder multipartBuilder; + private static final Field partsField; + + static { + try { + partsField = MultiPart.AbstractContentSource.class.getDeclaredField("parts"); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + partsField.setAccessible(true); + } + + static int getPartsCount(MultiPartRequestContent multiPartRequestContent) { + try { + return ((ArrayDeque) partsField.get(multiPartRequestContent)).size(); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + @BeforeEach + public void setUp() { + multipartBuilder = new JettyMultipartBuilder(new ObjectMapper()); + } + + @Test + public void testAddStringPart() { + MultiPartRequestContent result = multipartBuilder.addPart("TestPart", "TestValue").build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } + + @Test + public void testAddObjectPart() { + MultiPartRequestContent result = multipartBuilder.addPart("TestPart", 10000).build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } + + @Test + public void testAddJsonPart() { + try { + Location location = new Location(1000d, 1000d); + MultiPartRequestContent result = multipartBuilder.addJsonPart("TestPart", location).build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } + + @Test + public void testAddInputFileWithoutField() { + try { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + InputFile inputFile = new InputFile(file, "test_file.txt"); + MultiPartRequestContent result = multipartBuilder.addInputFile("testField", inputFile, false).build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } + + @Test + public void testAddInputFileAsStreamWithoutField() { + try { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + InputStream fileStream = Files.newInputStream(file.toPath()); + InputFile inputFile = new InputFile(fileStream, "test_file.txt"); + MultiPartRequestContent result = multipartBuilder.addInputFile("testField", inputFile, false).build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } + + @Test + public void testAddInputFileWithField() { + try { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + InputFile inputFile = new InputFile(file, "test_file.txt"); + MultiPartRequestContent result = multipartBuilder.addInputFile("testField", inputFile, true).build(); + assertNotNull(result); + assertEquals(2, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } + + @Test + public void testAddInputMedia() { + try { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + InputMediaDocument inputMedia = new InputMediaDocument(file, "test_file.txt"); + MultiPartRequestContent result = multipartBuilder.addMedia(inputMedia).build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } + + @Test + public void testAddInputMediaAsStream() { + try { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + InputStream fileStream = Files.newInputStream(file.toPath()); + InputMediaDocument inputMedia = new InputMediaDocument(fileStream, "test_file.txt"); + MultiPartRequestContent result = multipartBuilder.addMedia(inputMedia).build(); + assertNotNull(result); + assertEquals(1, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } + + @Test + public void testAddStickerSet() { + try { + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("test_file.txt").getFile()); + InputFile inputFile = new InputFile(file, "test_file.txt"); + InputSticker inputSticker = InputSticker.builder() + .sticker(inputFile) + .emoji("A") + .format("static") + .build(); + MultiPartRequestContent result = multipartBuilder.addInputStickers("testField", List.of(inputSticker)).build(); + assertNotNull(result); + assertEquals(2, getPartsCount(result)); + } catch (Exception e) { + fail(e); + } + } +} diff --git a/telegrambots-client-jetty-adapter/src/test/resources/test_file.txt b/telegrambots-client-jetty-adapter/src/test/resources/test_file.txt new file mode 100644 index 000000000..9944a9f24 --- /dev/null +++ b/telegrambots-client-jetty-adapter/src/test/resources/test_file.txt @@ -0,0 +1 @@ +This is a test file \ No newline at end of file diff --git a/telegrambots-client/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java b/telegrambots-client/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java index 853680faf..c7eced835 100644 --- a/telegrambots-client/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java +++ b/telegrambots-client/src/main/java/org/telegram/telegrambots/client/AbstractTelegramClient.java @@ -2,21 +2,8 @@ import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; import org.telegram.telegrambots.meta.api.methods.groupadministration.SetChatPhoto; -import org.telegram.telegrambots.meta.api.methods.send.SendAnimation; -import org.telegram.telegrambots.meta.api.methods.send.SendAudio; -import org.telegram.telegrambots.meta.api.methods.send.SendDocument; -import org.telegram.telegrambots.meta.api.methods.send.SendMediaGroup; -import org.telegram.telegrambots.meta.api.methods.send.SendPaidMedia; -import org.telegram.telegrambots.meta.api.methods.send.SendPhoto; -import org.telegram.telegrambots.meta.api.methods.send.SendSticker; -import org.telegram.telegrambots.meta.api.methods.send.SendVideo; -import org.telegram.telegrambots.meta.api.methods.send.SendVideoNote; -import org.telegram.telegrambots.meta.api.methods.send.SendVoice; -import org.telegram.telegrambots.meta.api.methods.stickers.AddStickerToSet; -import org.telegram.telegrambots.meta.api.methods.stickers.CreateNewStickerSet; -import org.telegram.telegrambots.meta.api.methods.stickers.ReplaceStickerInSet; -import org.telegram.telegrambots.meta.api.methods.stickers.SetStickerSetThumbnail; -import org.telegram.telegrambots.meta.api.methods.stickers.UploadStickerFile; +import org.telegram.telegrambots.meta.api.methods.send.*; +import org.telegram.telegrambots.meta.api.methods.stickers.*; import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook; import org.telegram.telegrambots.meta.api.methods.updatingmessages.EditMessageMedia; import org.telegram.telegrambots.meta.api.objects.File; @@ -227,10 +214,10 @@ private TelegramApiException mapException(Exception e, String method) { if (e.getCause() instanceof TelegramApiException) { return (TelegramApiException) e.getCause(); } else { - return new TelegramApiException("Unable to execute" + method + "method", e.getCause()); + return new TelegramApiException("Unable to execute " + method + " method", e.getCause()); } } else { - return new TelegramApiException("Unable to execute" + method + "method", e.getCause()); + return new TelegramApiException("Unable to execute " + method + " method", e); } } } diff --git a/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java b/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java index 27b069601..61a65643d 100644 --- a/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java +++ b/telegrambots-client/src/main/java/org/telegram/telegrambots/client/okhttp/OkHttpTelegramClient.java @@ -1,6 +1,7 @@ package org.telegram.telegrambots.client.okhttp; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.NonNull; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.MediaType; @@ -50,7 +51,6 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.concurrent.CompletableFuture; public class OkHttpTelegramClient extends AbstractTelegramClient { @@ -59,11 +59,11 @@ public class OkHttpTelegramClient extends AbstractTelegramClient { private final TelegramUrl telegramUrl; private final ObjectMapper objectMapper; - public OkHttpTelegramClient(ObjectMapper objectMapper, OkHttpClient client, String botToken, TelegramUrl telegramUrl) { - this.objectMapper = Objects.requireNonNull(objectMapper); - this.client = Objects.requireNonNull(client); - this.botToken = Objects.requireNonNull(botToken); - this.telegramUrl = Objects.requireNonNull(telegramUrl); + public OkHttpTelegramClient(@NonNull ObjectMapper objectMapper, @NonNull OkHttpClient client, @NonNull String botToken, @NonNull TelegramUrl telegramUrl) { + this.objectMapper = objectMapper; + this.client = client; + this.botToken = botToken; + this.telegramUrl = telegramUrl; } public OkHttpTelegramClient(OkHttpClient client, String botToken, TelegramUrl telegramUrl) { diff --git a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java index 7dfac713c..1c5f9ed6b 100644 --- a/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java +++ b/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/helpCommand/HelpCommand.java @@ -1,5 +1,6 @@ package org.telegram.telegrambots.extensions.bots.commandbot.commands.helpCommand; +import lombok.extern.slf4j.Slf4j; import org.telegram.telegrambots.extensions.bots.commandbot.commands.IBotCommand; import org.telegram.telegrambots.extensions.bots.commandbot.commands.ICommandRegistry; import org.telegram.telegrambots.meta.api.methods.send.SendMessage; @@ -17,6 +18,7 @@ * @version 1.0.0 * */ +@Slf4j public class HelpCommand extends ManCommand { private static final String COMMAND_IDENTIFIER = "help"; @@ -100,14 +102,14 @@ public void execute(TelegramClient telegramClient, User user, Chat chat, String[ try { telegramClient.execute(SendMessage.builder().chatId(chat.getId()).text(reply).parseMode("HTML").build()); } catch (TelegramApiException e) { - e.printStackTrace(); + log.error(e.getLocalizedMessage(), e); } } else { String reply = getHelpText(registry); try { telegramClient.execute(SendMessage.builder().chatId(chat.getId()).text(reply).parseMode("HTML").build()); } catch (TelegramApiException e) { - e.printStackTrace(); + log.error(e.getLocalizedMessage(), e); } } } diff --git a/telegrambots-longpolling/pom.xml b/telegrambots-longpolling/pom.xml index cfa768c73..d7628139c 100644 --- a/telegrambots-longpolling/pom.xml +++ b/telegrambots-longpolling/pom.xml @@ -51,8 +51,9 @@ - 17 - 17 + 17 + ${java.version} + ${java.version} UTF-8 UTF-8 diff --git a/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/BotSession.java b/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/BotSession.java index 6edb5d975..e5af4c8e5 100644 --- a/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/BotSession.java +++ b/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/BotSession.java @@ -152,7 +152,7 @@ private List getUpdatesFromTelegram() throws TelegramApiRequestException throw new TelegramApiErrorResponseException(response.code(), response.message()); } } - } catch (Exception e) { + } catch (IOException e) { throw new TelegramApiErrorResponseException(e); } diff --git a/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/util/TelegramOkHttpClientFactory.java b/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/util/TelegramOkHttpClientFactory.java index 38468e350..ec6747e20 100644 --- a/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/util/TelegramOkHttpClientFactory.java +++ b/telegrambots-longpolling/src/main/java/org/telegram/telegrambots/longpolling/util/TelegramOkHttpClientFactory.java @@ -75,14 +75,4 @@ public OkHttpClient get() { return okHttpClientBuilder.build(); } } - - /** - * @deprecated Use {@link HttpProxyOkHttpClientCreator} instead - */ - @Deprecated - public static class ProxyOkHttpClientCreator extends HttpProxyOkHttpClientCreator { - public ProxyOkHttpClientCreator(Supplier proxySupplier, Supplier authenticatorSupplier) { - super(proxySupplier, authenticatorSupplier); - } - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/annotations/BotApiMethodJsonAnnotated.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/annotations/BotApiJsonAnnotated.java similarity index 93% rename from telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/annotations/BotApiMethodJsonAnnotated.java rename to telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/annotations/BotApiJsonAnnotated.java index ec20ee034..a55cb4b09 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/annotations/BotApiMethodJsonAnnotated.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/annotations/BotApiJsonAnnotated.java @@ -18,5 +18,5 @@ @JacksonAnnotationsInside @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) -public @interface BotApiMethodJsonAnnotated { +public @interface BotApiJsonAnnotated { } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/interfaces/BotApiObject.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/interfaces/BotApiObject.java index 640e5fc0a..e2b17ec61 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/interfaces/BotApiObject.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/interfaces/BotApiObject.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.interfaces; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; +import org.telegram.telegrambots.meta.annotations.BotApiJsonAnnotated; import java.io.Serializable; @@ -10,7 +9,6 @@ * @version 1.0 * An object from the Bots API received from Telegram Servers */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) +@BotApiJsonAnnotated public interface BotApiObject extends Serializable { } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java index a263f77b9..8eaa93a0c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerCallbackQuery.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class AnswerCallbackQuery extends BotApiMethodBoolean { public static final String PATH = "answercallbackquery"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java index 3b9029003..6632530e2 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerInlineQuery.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class AnswerInlineQuery extends BotApiMethodBoolean { public static final String PATH = "answerInlineQuery"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java index 7a0718f2c..4a5da3f92 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerPreCheckoutQuery.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class AnswerPreCheckoutQuery extends BotApiMethodBoolean { public static final String PATH = "answerPreCheckoutQuery"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java index ab5b4d731..71d7dbc32 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/AnswerShippingQuery.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -35,7 +34,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class AnswerShippingQuery extends BotApiMethodBoolean { public static final String PATH = "answerShippingQuery"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java index dd1e8324d..134b7dc2d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessage.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -41,7 +40,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CopyMessage extends BotApiMethod { public static final String PATH = "copyMessage"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessages.java index 3d08814e8..349dbd68c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/CopyMessages.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -43,7 +42,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CopyMessages extends BotApiMethod> { public static final String PATH = "copyMessages"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java index 5df6371a4..89c01f01c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessage.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -19,7 +18,6 @@ * @author Ruben Bermudez * @version 1.0 * Use this method to forward messages of any kind. - * * Service messages and messages with protected content can't be forwarded. * * On success, the Message sent is returned. @@ -32,7 +30,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ForwardMessage extends BotApiMethodMessage { public static final String PATH = "forwardmessage"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessages.java index 137d818a2..64a54ddd9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/ForwardMessages.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -39,7 +38,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ForwardMessages extends BotApiMethod> { public static final String PATH = "forwardMessages"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java index 63160770e..af7268a91 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetFile.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -32,7 +31,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetFile extends BotApiMethod { public static final String PATH = "getFile"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java index 118724115..3aa96013e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/GetUserProfilePhotos.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -28,7 +27,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetUserProfilePhotos extends BotApiMethod { public static final String PATH = "getuserprofilephotos"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java index 2eab90b15..cdd4ab141 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetPassportDataErrors.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -31,7 +30,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetPassportDataErrors extends BotApiMethodBoolean { public static final String PATH = "setPassportDataErrors"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetUserEmojiStatus.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetUserEmojiStatus.java new file mode 100644 index 000000000..9e7714542 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/SetUserEmojiStatus.java @@ -0,0 +1,72 @@ +package org.telegram.telegrambots.meta.api.methods; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 8.0 + * Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the + * Mini App method requestEmojiStatusAccess. + * + * Returns True on success. + */ +@SuppressWarnings("unused") +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@AllArgsConstructor +@SuperBuilder +@Jacksonized +public class SetUserEmojiStatus extends BotApiMethodBoolean { + public static final String PATH = "setUserEmojiStatus"; + + private static final String USER_ID_FIELD = "user_id"; + private static final String EMOJI_STATUS_CUSTOM_EMOJI_ID_FIELD = "emoji_status_custom_emoji_id"; + private static final String EMOJI_STATUS_EXPIRATION_DATE_FIELD = "emoji_status_expiration_date"; + + + /** + * Unique identifier of the target user + */ + @JsonProperty(USER_ID_FIELD) + @NonNull + private Integer userId; + /** + * Optional + * Custom emoji identifier of the emoji status to set. + * Pass an empty string to remove the status. + */ + @JsonProperty(EMOJI_STATUS_CUSTOM_EMOJI_ID_FIELD) + private String emojiStatusCustomEmojiId; + /** + * Optional + * Expiration date of the emoji status, if any + */ + @JsonProperty(EMOJI_STATUS_EXPIRATION_DATE_FIELD) + private Integer emojiStatusExpirationDate; + + @Override + public String getMethod() { + return PATH; + } + + @Override + public void validate() throws TelegramApiValidationException { + if (userId == 0) { + throw new TelegramApiValidationException("UserId parameter can't be empty", this); + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodBoolean.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodBoolean.java index 14d5f7218..b84d3a57f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodBoolean.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodBoolean.java @@ -1,7 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.botapimethods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -13,8 +11,6 @@ * * A method of Telegram Bots Api that is fully supported in json format */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) @NoArgsConstructor(access = AccessLevel.PROTECTED) @SuperBuilder public abstract class BotApiMethodBoolean extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodMessage.java index 4a95db336..723ad298e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodMessage.java @@ -1,7 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.botapimethods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -14,8 +12,6 @@ * * A method of Telegram Bots Api that is fully supported in json format */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) @NoArgsConstructor(access = AccessLevel.PROTECTED) @SuperBuilder public abstract class BotApiMethodMessage extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodSerializable.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodSerializable.java index 75655ee90..f5138184d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodSerializable.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/BotApiMethodSerializable.java @@ -1,7 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.botapimethods; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -19,8 +17,6 @@ * * A method of Telegram Bots Api that is fully supported in json format */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) @NoArgsConstructor(access = AccessLevel.PROTECTED) @SuperBuilder public abstract class BotApiMethodSerializable extends BotApiMethod { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/PartialBotApiMethod.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/PartialBotApiMethod.java index e607ec307..231a14bd7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/PartialBotApiMethod.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/botapimethods/PartialBotApiMethod.java @@ -8,7 +8,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; -import org.telegram.telegrambots.meta.annotations.BotApiMethodJsonAnnotated; +import org.telegram.telegrambots.meta.annotations.BotApiJsonAnnotated; import org.telegram.telegrambots.meta.api.interfaces.Validable; import org.telegram.telegrambots.meta.api.objects.ApiResponse; import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; @@ -24,7 +24,7 @@ */ @NoArgsConstructor(access = AccessLevel.PROTECTED) @SuperBuilder -@BotApiMethodJsonAnnotated +@BotApiJsonAnnotated public abstract class PartialBotApiMethod implements Validable { @JsonIgnore protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @@ -72,6 +72,7 @@ private T deserializeResponseInternal(String answer, JavaType type) throws Teleg @JsonProperty(BotApiMethod.METHOD_FIELD) public abstract String getMethod(); + @BotApiJsonAnnotated public static abstract class PartialBotApiMethodBuilder, B extends PartialBotApiMethodBuilder> { } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java index d39e15047..0b03c0397 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/commands/SetMyCommands.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.commands; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -34,7 +33,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetMyCommands extends BotApiMethodBoolean { public static final String PATH = "setMyCommands"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java index 94a414755..e904851bb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CloseForumTopic extends BotApiMethodBoolean { public static final String PATH = "closeForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java index a7fea0ba3..48b481dd9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CloseGeneralForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CloseGeneralForumTopic extends BotApiMethodBoolean { public static final String PATH = "closeGeneralForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java index 88263cba0..8ea33d4e1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/CreateForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CreateForumTopic extends BotApiMethod { public static final String PATH = "createForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java index 550192193..a26b2236c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/DeleteForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -30,7 +29,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteForumTopic extends BotApiMethodBoolean { public static final String PATH = "deleteForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java index dc2d6c90e..eefc4e9d1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditForumTopic extends BotApiMethodBoolean { public static final String PATH = "editForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java index 17181eead..e6ba2833e 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/EditGeneralForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditGeneralForumTopic extends BotApiMethodBoolean { public static final String PATH = "editGeneralForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java index 17b96c134..8bf994ad9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/HideGeneralForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class HideGeneralForumTopic extends BotApiMethodBoolean { public static final String PATH = "hideGeneralForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java index 61494906c..93cec53b7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -31,7 +30,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ReopenForumTopic extends BotApiMethodBoolean { public static final String PATH = "reopenForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java index f92a65c1e..f3c8a1a2c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/ReopenGeneralForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ReopenGeneralForumTopic extends BotApiMethodBoolean { public static final String PATH = "reopenGeneralForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java index c76720feb..93d6e2217 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnhideGeneralForumTopic.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnhideGeneralForumTopic extends BotApiMethodBoolean { public static final String PATH = "unhideGeneralForumTopic"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java index a383c2f6b..9fe8c7176 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllForumTopicMessages.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnpinAllForumTopicMessages extends BotApiMethodBoolean { public static final String PATH = "unpinAllForumTopicMessages"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java index 1e11a696d..05c3d4243 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/forum/UnpinAllGeneralForumTopicMessages.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.forum; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnpinAllGeneralForumTopicMessages extends BotApiMethodBoolean { public static final String PATH = "unpinAllGeneralForumTopicMessages"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java index 16a19fef6..e84e477a0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/GetGameHighScores.java @@ -16,7 +16,6 @@ */ package org.telegram.telegrambots.meta.api.methods.games; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -56,7 +55,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetGameHighScores extends BotApiMethod> { public static final String PATH = "getGameHighScores"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java index 7ae9c2e0d..bce0c7d90 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/games/SetGameScore.java @@ -17,7 +17,6 @@ package org.telegram.telegrambots.meta.api.methods.games; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -53,7 +52,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetGameScore extends BotApiMethodSerializable { public static final String PATH = "setGameScore"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/gifts/GetAvailableGifts.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/gifts/GetAvailableGifts.java new file mode 100644 index 000000000..1b4ec0e7a --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/gifts/GetAvailableGifts.java @@ -0,0 +1,39 @@ +package org.telegram.telegrambots.meta.api.methods.gifts; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.gifts.Gifts; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; + +/** + * @author Ruben Bermudez + * @version 8.0 + * Returns the list of gifts that can be sent by the bot to users. + * Requires no parameters. + * + * Returns a Gifts object. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +@Builder +public class GetAvailableGifts extends BotApiMethod { + public static final String PATH = "getAvailableGifts"; + + @Override + public String getMethod() { + return PATH; + } + + @Override + public Gifts deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, Gifts.class); + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/gifts/SendGift.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/gifts/SendGift.java new file mode 100644 index 000000000..74ed04bc7 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/gifts/SendGift.java @@ -0,0 +1,99 @@ +package org.telegram.telegrambots.meta.api.methods.gifts; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.Singular; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.api.objects.MessageEntity; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +import java.util.List; + +/** + * @author Ruben Bermudez + * @version 8.0 + * + * Sends a gift to the given user. + * The gift can't be converted to Telegram Stars by the user. + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@AllArgsConstructor +@SuperBuilder +@Jacksonized +public class SendGift extends BotApiMethodBoolean { + public static final String PATH = "sendGift"; + + private static final String USER_ID_FIELD = "user_id"; + private static final String GIFT_ID_FIELD = "gift_id"; + private static final String TEXT_FIELD = "text"; + private static final String TEXT_PARSE_MODE_FIELD = "text_parse_mode"; + private static final String TEXT_ENTITIES_FIELD = "text_entities"; + + /** + * Unique identifier of the target user that will receive the gift + */ + @JsonProperty(USER_ID_FIELD) + @NonNull + private Integer userId; + /** + * Identifier of the gift + */ + @JsonProperty(GIFT_ID_FIELD) + @NonNull + private String giftId; + /** + * Optional + * Text that will be shown along with the gift; 0-255 characters + */ + @JsonProperty(TEXT_FIELD) + private String text; + /** + * Optional + * Mode for parsing entities in the text. + * See formatting options for more details. + * + * @apiNote Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. + */ + @JsonProperty(TEXT_PARSE_MODE_FIELD) + private String textParseMode; + /** + * Optional + * A JSON-serialized list of special entities that appear in the gift text. + * It can be specified instead of text_parse_mode. + * @apiNote Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. + */ + @JsonProperty(TEXT_ENTITIES_FIELD) + @Singular + private List textEntities; + + @Override + public void validate() throws TelegramApiValidationException { + if (userId == 0) { + throw new TelegramApiValidationException("UserId can't be empty", this); + } + if (giftId.isEmpty()) { + throw new TelegramApiValidationException("GiftId can't be empty", this); + } + if (text != null && (text.isEmpty() || text.length() > 255)) { + throw new TelegramApiValidationException("Text must be between 0 and 255 characters", this); + } + } + + @Override + public String getMethod() { + return PATH; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java index 91e77993c..8189a8213 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ApproveChatJoinRequest.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ApproveChatJoinRequest extends BotApiMethodBoolean { public static final String PATH = "approveChatJoinRequest"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java index f12a47674..37a8ecd17 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatMember.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -39,7 +38,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class BanChatMember extends BotApiMethodBoolean { public static final String PATH = "banChatMember"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java index fa742d0c9..11f820bf3 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/BanChatSenderChat.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -37,7 +36,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class BanChatSenderChat extends BotApiMethodBoolean { public static final String PATH = "banChatSenderChat"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java index e6edf5912..f7f8c9404 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatInviteLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -34,7 +33,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CreateChatInviteLink extends BotApiMethod { public static final String PATH = "createChatInviteLink"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java index 54be02c7b..a71322667 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/CreateChatSubscriptionInviteLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -36,7 +35,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CreateChatSubscriptionInviteLink extends BotApiMethod { public static final String PATH = "createChatSubscriptionInviteLink"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java index 2077ed34a..bf25d562d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeclineChatJoinRequest.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeclineChatJoinRequest extends BotApiMethodBoolean { public static final String PATH = "declineChatJoinRequest"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java index 383eccca7..5e5babf35 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatPhoto.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteChatPhoto extends BotApiMethodBoolean { public static final String PATH = "deleteChatPhoto"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java index ea3a33f42..b388f33a7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/DeleteChatStickerSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteChatStickerSet extends BotApiMethodBoolean { public static final String PATH = "deleteChatStickerSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java index 61250e865..d6b2ccb3f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatInviteLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -36,7 +35,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditChatInviteLink extends BotApiMethod { public static final String PATH = "editChatInviteLink"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java index 3f62d27d1..1f9cb098b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/EditChatSubscriptionInviteLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -34,7 +33,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditChatSubscriptionInviteLink extends BotApiMethod { public static final String PATH = "editChatSubscriptionInviteLink"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java index d3f240091..517ab17d1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/ExportChatInviteLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -34,7 +33,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ExportChatInviteLink extends BotApiMethod { public static final String PATH = "exportChatInviteLink"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java index 1387ced41..b2c997b56 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChat.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetChat extends BotApiMethod { public static final String PATH = "getChat"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java index a8945003d..7a66f10bb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatAdministrators.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -34,7 +33,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetChatAdministrators extends BotApiMethod> { public static final String PATH = "getChatAdministrators"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java index 57dab97bf..c19710a1d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMember.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetChatMember extends BotApiMethod { public static final String PATH = "getChatMember"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java index f232b15fc..6cca3fd50 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/GetChatMemberCount.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -27,7 +26,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetChatMemberCount extends BotApiMethod { public static final String PATH = "getChatMemberCount"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java index e5096e3cc..d3303aee4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/LeaveChat.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class LeaveChat extends BotApiMethodBoolean { public static final String PATH = "leaveChat"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java index 9db3c4403..a237f9662 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/PromoteChatMember.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -31,7 +30,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class PromoteChatMember extends BotApiMethodBoolean { public static final String PATH = "promoteChatMember"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java index 4fd5af8f3..2d6f90989 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RestrictChatMember.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -38,7 +37,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class RestrictChatMember extends BotApiMethodBoolean { public static final String PATH = "restrictchatmember"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java index 1dba2a331..69d145b08 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/RevokeChatInviteLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -36,7 +35,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class RevokeChatInviteLink extends BotApiMethod { public static final String PATH = "revokeChatInviteLink"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java index 064d2fe89..f456fa343 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatAdministratorCustomTitle.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -27,7 +26,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatAdministratorCustomTitle extends BotApiMethodBoolean { public static final String PATH = "setChatAdministratorCustomTitle"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java index a58e03559..d4a8f8891 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatDescription.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -30,7 +29,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatDescription extends BotApiMethodBoolean { public static final String PATH = "setChatDescription"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java index f3109a170..9ce64db16 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPermissions.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -31,7 +30,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatPermissions extends BotApiMethodBoolean { public static final String PATH = "setChatPermissions"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java index c56877f10..715ca40b7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatPhoto.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -31,7 +30,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatPhoto extends PartialBotApiMethod { public static final String PATH = "setChatPhoto"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java index 4f8ce0572..4fdea7273 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatStickerSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatStickerSet extends BotApiMethodBoolean { public static final String PATH = "setChatStickerSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java index 555f331e5..d2fc12253 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/SetChatTitle.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatTitle extends BotApiMethodBoolean { public static final String PATH = "setChatTitle"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java index 90dbcb04c..d2ceb20cb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatMember.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -35,7 +34,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnbanChatMember extends BotApiMethodBoolean { public static final String PATH = "unbanchatmember"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java index c86c8f31d..7a6ea3eaf 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/groupadministration/UnbanChatSenderChat.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.groupadministration; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnbanChatSenderChat extends BotApiMethodBoolean { public static final String PATH = "unbanChatSenderChat"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java index 39a3c92f3..705451dc1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/CreateInvoiceLink.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.invoices; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -34,7 +33,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CreateInvoiceLink extends BotApiMethod { public static final String PATH = "createInvoiceLink"; @@ -58,6 +56,8 @@ public class CreateInvoiceLink extends BotApiMethod { public static final String SEND_PHONE_NUMBER_TO_PROVIDER_FIELD = "send_phone_number_to_provider"; public static final String SEND_EMAIL_TO_PROVIDER_FIELD = "send_email_to_provider"; public static final String IS_FLEXIBLE_FIELD = "is_flexible"; + public static final String BUSINESS_CONNECTION_ID_FIELD = "business_connection_id"; + public static final String SUBSCRIPTION_PERIOD_FIELD = "subscription_period"; /** * Product name, 1-32 characters @@ -201,6 +201,21 @@ public class CreateInvoiceLink extends BotApiMethod { @JsonProperty(SUGGESTED_TIP_AMOUNTS_FIELD) @Singular private List suggestedTipAmounts; + /** + * Optional + * Unique identifier of the business connection on behalf of which the invoice will be created + */ + @JsonProperty(BUSINESS_CONNECTION_ID_FIELD) + private String businessConnectionId; + /** + * Optional + * The number of seconds the subscription will be active for before the next payment. + * The currency must be set to “XTR” (Telegram Stars) if the parameter is used. + * + * Currently, it must always be 2592000 (30 days) if specified. + */ + @JsonProperty(SUBSCRIPTION_PERIOD_FIELD) + private Integer subscriptionPeriod; @Override public String getMethod() { diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java index eea81cc9a..99c6f9cc4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/invoices/SendInvoice.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.invoices; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -35,7 +34,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendInvoice extends BotApiMethodMessage { public static final String PATH = "sendinvoice"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java index 5462bfef6..9b4a33572 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/menubutton/SetChatMenuButton.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.menubutton; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetChatMenuButton extends BotApiMethodBoolean { public static final String PATH = "setChatMenuButton"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/message/SavePreparedInlineMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/message/SavePreparedInlineMessage.java new file mode 100644 index 000000000..1d2e3a4df --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/message/SavePreparedInlineMessage.java @@ -0,0 +1,96 @@ +package org.telegram.telegrambots.meta.api.methods.message; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; +import org.telegram.telegrambots.meta.api.objects.inlinequery.result.InlineQueryResult; +import org.telegram.telegrambots.meta.api.objects.message.PreparedInlineMessage; +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 8.0 + * Stores a message that can be sent by a user of a Mini App. + * Returns a PreparedInlineMessage object. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@AllArgsConstructor +@SuperBuilder +@Jacksonized +public class SavePreparedInlineMessage extends BotApiMethod { + public static final String PATH = "savePreparedInlineMessage"; + + private static final String USER_ID_FIELD = "user_id"; + private static final String RESULT_FIELD = "result"; + private static final String ALLOW_USER_CHATS_FIELD = "allow_user_chats"; + private static final String ALLOW_BOT_CHATS_FIELD = "allow_bot_chats"; + private static final String ALLOW_GROUP_CHATS_FIELD = "allow_group_chats"; + private static final String ALLOW_CHANNEL_CHATS_FIELD = "allow_channel_chats"; + + /** + * Unique identifier of the target user that can use the prepared message + */ + @JsonProperty(USER_ID_FIELD) + @NonNull + private Integer userId; + /** + * A JSON-serialized object describing the message to be sent + */ + @JsonProperty(RESULT_FIELD) + @NonNull + private InlineQueryResult result; + /** + * Pass True if the message can be sent to private chats with users + */ + @JsonProperty(ALLOW_USER_CHATS_FIELD) + private Boolean allowUserChats; + /** + * Pass True if the message can be sent to private chats with bots + */ + @JsonProperty(ALLOW_BOT_CHATS_FIELD) + private Integer allowBotChats; + /** + * Pass True if the message can be sent to group and supergroup chats + */ + @JsonProperty(ALLOW_GROUP_CHATS_FIELD) + @NonNull + private Boolean allowGroupChats; + /** + * Pass True if the message can be sent to channel chats + */ + @JsonProperty(ALLOW_CHANNEL_CHATS_FIELD) + @NonNull + private Boolean allowChannelChats; + + @Override + public PreparedInlineMessage deserializeResponse(String answer) throws TelegramApiRequestException { + return deserializeResponse(answer, PreparedInlineMessage.class); + } + + + @Override + public void validate() throws TelegramApiValidationException { + if (userId == 0) { + throw new TelegramApiValidationException("UserId can't be empty", this); + } + result.validate(); + } + + @Override + public String getMethod() { + return PATH; + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/RefundStarPayment.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/RefundStarPayment.java index 866b102c5..ec9e2e932 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/RefundStarPayment.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/RefundStarPayment.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.payments; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class RefundStarPayment extends BotApiMethodBoolean { public static final String PATH = "refundStarPayment"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/EditUserStarSubscription.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/EditUserStarSubscription.java new file mode 100644 index 000000000..c25ba2f9e --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/EditUserStarSubscription.java @@ -0,0 +1,73 @@ +package org.telegram.telegrambots.meta.api.methods.payments.star; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodBoolean; +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; + +/** + * @author Ruben Bermudez + * @version 8.0 + * + * Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. + * Returns True on success. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +@SuperBuilder +@Jacksonized +@JsonIgnoreProperties(ignoreUnknown = true) +public class EditUserStarSubscription extends BotApiMethodBoolean { + public static final String PATH = "editUserStarSubscription"; + + private static final String USER_ID_FIELD = "user_id"; + private static final String TELEGRAM_PAYMENT_CHARGE_ID_FIELD = "telegram_payment_charge_id"; + private static final String IS_CANCELED_FIELD = "is_canceled"; + + /** + * Identifier of the user whose subscription will be edited + */ + @JsonProperty(USER_ID_FIELD) + @NonNull + private Integer userId; + /** + * Telegram payment identifier for the subscription + */ + @JsonProperty(TELEGRAM_PAYMENT_CHARGE_ID_FIELD) + @NonNull + private String telegramPaymentChargeId; + /** + * Pass True to cancel extension of the user subscription; + * the subscription must be active up to the end of the current subscription period. + * Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + */ + @JsonProperty(IS_CANCELED_FIELD) + @NonNull + private Boolean isCanceled; + + @Override + public String getMethod() { + return PATH; + } + + @Override + public void validate() throws TelegramApiValidationException { + if (userId == 0) { + throw new TelegramApiValidationException("UserId parameters must not be 0", this); + } + if (telegramPaymentChargeId.isEmpty()) { + throw new TelegramApiValidationException("TelegramPaymentChargeId can´t be empty", this); + } + } +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/GetStarTransactions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/GetStarTransactions.java index 777e6c850..96a875f5b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/GetStarTransactions.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/payments/star/GetStarTransactions.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.payments.star; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetStarTransactions extends BotApiMethod { public static final String PATH = "getStarTransactions"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java index fff19f5f5..fd6ce8f1a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/PinChatMessage.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class PinChatMessage extends BotApiMethodBoolean { public static final String PATH = "pinChatMessage"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java index 7f3c69e9b..d2b1fa86d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinAllChatMessages.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -31,7 +30,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnpinAllChatMessages extends BotApiMethodBoolean { public static final String PATH = "unpinAllChatMessages"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java index 532380621..9b5b8c014 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/pinnedmessages/UnpinChatMessage.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.pinnedmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -33,7 +32,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UnpinChatMessage extends BotApiMethodBoolean { public static final String PATH = "unpinChatMessage"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java index 6a890cb22..59597e64c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/SendPoll.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.polls; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -38,7 +37,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendPoll extends BotApiMethodMessage { public static final String PATH = "sendPoll"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java index f91b40eab..c423286f5 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/polls/StopPoll.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.polls; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class StopPoll extends BotApiMethod { public static final String PATH = "stopPoll"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java index ebc6b4ed7..d9b6fcd18 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/reactions/SetMessageReaction.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.reactions; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -40,7 +39,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetMessageReaction extends BotApiMethodBoolean { public static final String PATH = "setMessageReaction"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java index 2bf728635..2897e455b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAnimation.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -38,7 +37,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendAnimation extends SendMediaBotMethod { public static final String PATH = "sendAnimation"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java index a30fa13d6..4e2aefd0a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -39,7 +38,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendAudio extends SendMediaBotMethod { public static final String PATH = "sendaudio"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java index 6eae543ad..0ad4b6780 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendChatAction.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.methods.send; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendChatAction extends BotApiMethodBoolean { public static final String PATH = "sendChatAction"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java index b32c24806..c4752bfea 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendContact.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -31,7 +30,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendContact extends BotApiMethodMessage { public static final String PATH = "sendContact"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java index 3cbd2ee4f..8df46d552 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDice.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -34,7 +33,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendDice extends BotApiMethodMessage { private static final List VALIDEMOJIS = Collections.unmodifiableList(Arrays.asList("🎲", "🎯", "🏀", "⚽", "🎳", "🎰")); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java index e95caa85b..1853ddad8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -35,7 +34,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendDocument extends SendMediaBotMethod { public static final String PATH = "senddocument"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java index 2c957b2dd..e3ecf71fa 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendGame.java @@ -17,7 +17,6 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -47,7 +46,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendGame extends BotApiMethodMessage { public static final String PATH = "sendGame"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java index ffa7732d9..5b6866542 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendLocation.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -30,7 +29,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendLocation extends BotApiMethodMessage { public static final String PATH = "sendlocation"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java index 22a9b6be2..4e11e464f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMediaGroup.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -43,7 +42,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendMediaGroup extends PartialBotApiMethod> { public static final String PATH = "sendMediaGroup"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java index eb5c6a51b..481ae109a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendMessage.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -36,7 +35,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendMessage extends BotApiMethodMessage { public static final String PATH = "sendmessage"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java index a890f73d9..9810087f6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPaidMedia.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -38,7 +37,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendPaidMedia extends PartialBotApiMethod> { public static final String PATH = "sendPaidMedia"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java index 9090d98f8..d49d3a9e0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendPhoto.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -36,7 +35,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendPhoto extends SendMediaBotMethod { public static final String PATH = "sendphoto"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java index 30458e000..76ccfc980 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendSticker.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendSticker extends SendMediaBotMethod { public static final String PATH = "sendsticker"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java index cab88625b..f5791e7d7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVenue.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -31,7 +30,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendVenue extends BotApiMethodMessage { public static final String PATH = "sendVenue"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java index 5d89a0af4..eb8159904 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideo.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -36,7 +35,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendVideo extends SendMediaBotMethod { public static final String PATH = "sendvideo"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java index bd85e1e77..5178a5852 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVideoNote.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -33,7 +32,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendVideoNote extends SendMediaBotMethod { public static final String PATH = "sendvideonote"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java index 20715ad46..b1596a591 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendVoice.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.send; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -39,7 +38,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SendVoice extends SendMediaBotMethod { public static final String PATH = "sendVoice"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java index f03f54fcb..a8998ed98 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/AddStickerToSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -29,7 +28,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class AddStickerToSet extends PartialBotApiMethod { public static final String PATH = "addStickerToSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java index 906aea6a9..b05abc586 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/CreateNewStickerSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -14,7 +13,6 @@ import lombok.extern.jackson.Jacksonized; import org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod; import org.telegram.telegrambots.meta.api.objects.stickers.InputSticker; -import org.telegram.telegrambots.meta.exceptions.TelegramApiException; import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; @@ -37,7 +35,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class CreateNewStickerSet extends PartialBotApiMethod { public static final String PATH = "createNewStickerSet"; @@ -92,32 +89,6 @@ public String getMethod() { return PATH; } - /** - * Returns the sticker format. Will only work if all stickers are of the same type, an exception is thrown otherwise - * @deprecated Use the format within each sticker - */ - @Deprecated - public String getStickerFormat() throws TelegramApiException { - List formats = stickers.stream().map(InputSticker::getFormat).distinct().toList(); - if (formats.size() > 1) { - throw new TelegramApiException("Multiple format present in strickers"); - } - return formats.isEmpty() ? null : formats.get(0); - } - - /** - * Returns the sticker format. - * Will only work if no sticker with other format already exists in the list - * @deprecated Use the format within each sticker - */ - @Deprecated - public void setStickerFormat(String stickerFormat) throws TelegramApiException { - String existingFormat = getStickerFormat(); - if (existingFormat == null || !existingFormat.equals(stickerFormat)) { - this.stickers.forEach(x -> x.setFormat(stickerFormat)); - } - } - @Override public Boolean deserializeResponse(String answer) throws TelegramApiRequestException { return deserializeResponse(answer, Boolean.class); diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java index 610f3c321..ff8423042 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerFromSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +24,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteStickerFromSet extends BotApiMethodBoolean { private static final String PATH = "deleteStickerFromSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerSet.java index de14adee6..1f20ecf25 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/DeleteStickerSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteStickerSet extends BotApiMethodBoolean { public static final String PATH = "deleteStickerSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java index 252e2f783..08872738a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/GetStickerSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -27,7 +26,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GetStickerSet extends BotApiMethod { private static final String PATH = "getStickerSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/ReplaceStickerInSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/ReplaceStickerInSet.java index 07611a89f..5b8c427da 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/ReplaceStickerInSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/ReplaceStickerInSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ReplaceStickerInSet extends PartialBotApiMethod { public static final String PATH = "replaceStickerInSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java index f83abc4af..2ec5ae57c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetCustomEmojiStickerSetThumbnail.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -30,7 +29,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetCustomEmojiStickerSetThumbnail extends BotApiMethodBoolean { public static final String PATH = "setCustomEmojiStickerSetThumbnail"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerEmojiList.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerEmojiList.java index d693e39d2..54391db7d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerEmojiList.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerEmojiList.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -32,7 +31,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetStickerEmojiList extends BotApiMethodBoolean { public static final String PATH = "setStickerEmojiList"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerKeywords.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerKeywords.java index 2dc91cf42..b72ef4e0f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerKeywords.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerKeywords.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -34,7 +33,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetStickerKeywords extends BotApiMethodBoolean { public static final String PATH = "setStickerKeywords"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerMaskPosition.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerMaskPosition.java index 6b2591ac7..5a5683b45 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerMaskPosition.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerMaskPosition.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetStickerMaskPosition extends BotApiMethodBoolean { public static final String PATH = "setStickerMaskPosition"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java index afe1dce50..879d2c14b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerPositionInSet.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetStickerPositionInSet extends BotApiMethodBoolean { private static final String PATH = "setStickerPositionInSet"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumbnail.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumbnail.java index 30c432090..352f0e57d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumbnail.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetThumbnail.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -31,7 +30,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetStickerSetThumbnail extends BotApiMethodBoolean { public static final String PATH = "setStickerSetThumbnail"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetTitle.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetTitle.java index ce94d4235..c263363f4 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetTitle.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/SetStickerSetTitle.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetStickerSetTitle extends BotApiMethodBoolean { public static final String PATH = "setStickerSetTitle"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java index c582a61f0..43e7ca5cb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/stickers/UploadStickerFile.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -31,7 +30,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UploadStickerFile extends PartialBotApiMethod { public static final String PATH = "uploadStickerFile"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java index d5ed93ce4..a37ea1118 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updates/SetWebhook.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.updates; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -37,7 +36,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class SetWebhook extends PartialBotApiMethod { public static final String PATH = "setWebhook"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java index 3970303f1..446251ea8 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessage.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -35,7 +34,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteMessage extends BotApiMethodBoolean { public static final String PATH = "deleteMessage"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessages.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessages.java index f432d0032..46408bb40 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessages.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/DeleteMessages.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -34,7 +33,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class DeleteMessages extends BotApiMethodBoolean { private static final String PATH = "deleteMessages"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java index 6d6fe6146..dca6bf012 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageLiveLocation.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -33,7 +32,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditMessageLiveLocation extends BotApiMethodSerializable { public static final String PATH = "editMessageLiveLocation"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java index 1d12c7c49..3024d49cd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageMedia.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; import lombok.AllArgsConstructor; @@ -44,7 +43,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditMessageMedia extends PartialBotApiMethod { public static final String PATH = "editMessageMedia"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java index c88af3c5b..44c71de34 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/updatingmessages/EditMessageText.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.updatingmessages; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -40,7 +39,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class EditMessageText extends BotApiMethodSerializable { public static final String PATH = "editmessagetext"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java index ee2396195..c0d665c11 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/webapp/AnswerWebAppQuery.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.methods.webapp; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -33,7 +32,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class AnswerWebAppQuery extends BotApiMethod { public static final String PATH = "answerWebAppQuery"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ApiResponse.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ApiResponse.java index 203b92d43..d6b021224 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ApiResponse.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ApiResponse.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; @@ -16,7 +15,6 @@ * Response from Telegram Server */ @Getter -@JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @Builder @NoArgsConstructor diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java index 8eb6b65f4..bc40be208 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Audio.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -26,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Audio implements BotApiObject { private static final String FILEID_FIELD = "file_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Birthdate.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Birthdate.java index e1dfea719..df475c635 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Birthdate.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Birthdate.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -26,7 +25,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Birthdate implements BotApiObject { private static final String DAY_FIELD = "day"; private static final String MONTH_FIELD = "month"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java deleted file mode 100644 index e74b95498..000000000 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Chat.java +++ /dev/null @@ -1,401 +0,0 @@ -package org.telegram.telegrambots.meta.api.objects; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.Setter; -import lombok.ToString; -import lombok.experimental.SuperBuilder; -import lombok.extern.jackson.Jacksonized; -import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; -import org.telegram.telegrambots.meta.api.objects.business.BusinessIntro; -import org.telegram.telegrambots.meta.api.objects.business.BusinessLocation; -import org.telegram.telegrambots.meta.api.objects.business.BusinessOpeningHours; -import org.telegram.telegrambots.meta.api.objects.message.Message; -import org.telegram.telegrambots.meta.api.objects.reactions.ReactionType; - -import java.util.List; - -/** - * This object represents a Telegram chat with a user or a group - * @author Ruben Bermudez - * @version 6.1 - * @deprecated Use {{@link org.telegram.telegrambots.meta.api.objects.chat.Chat}} - */ -@SuppressWarnings("WeakerAccess") -@EqualsAndHashCode(callSuper = false) -@Getter -@Setter -@ToString -@RequiredArgsConstructor -@AllArgsConstructor -@SuperBuilder -@Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) -@Deprecated -public class Chat implements BotApiObject { - - private static final String ID_FIELD = "id"; - private static final String TYPE_FIELD = "type"; - private static final String TITLE_FIELD = "title"; - private static final String USERNAME_FIELD = "username"; - private static final String FIRSTNAME_FIELD = "first_name"; - private static final String LASTNAME_FIELD = "last_name"; - private static final String BIO_FIELD = "bio"; - private static final String PHOTO_FIELD = "photo"; - private static final String DESCRIPTION_FIELD = "description"; - private static final String INVITELINK_FIELD = "invite_link"; - private static final String PINNEDMESSAGE_FIELD = "pinned_message"; - private static final String STICKERSETNAME_FIELD = "sticker_set_name"; - private static final String CANSETSTICKERSET_FIELD = "can_set_sticker_set"; - private static final String PERMISSIONS_FIELD = "permissions"; - private static final String SLOWMODEDELAY_FIELD = "slow_mode_delay"; - private static final String LINKEDCHATID_FIELD = "linked_chat_id"; - private static final String LOCATION_FIELD = "location"; - private static final String MESSAGEAUTODELETETIME_FIELD = "message_auto_delete_time"; - private static final String HASPRIVATEFORWARDS_FIELD = "has_private_forwards"; - private static final String HASPROTECTEDCONTENT_FIELD = "has_protected_content"; - private static final String JOINTOSENDMESSAGES_FIELD = "join_to_send_messages"; - private static final String JOINBYREQUEST_FIELD = "join_by_request"; - private static final String HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD = "has_restricted_voice_and_video_messages"; - private static final String ISFORUM_FIELD = "is_forum"; - private static final String ACTIVEUSERNAMES_FIELD = "active_usernames"; - private static final String HASAGGRESSIVEANTISPAMENABLED_FIELD = "has_aggressive_anti_spam_enabled"; - private static final String HASHIDDENMEMBERS_FIELD = "has_hidden_members"; - private static final String AVAILABLE_REACTIONS_FIELD = "available_reactions"; - private static final String ACCENT_COLOR_ID_FIELD = "accent_color_id"; - private static final String BACKGROUND_CUSTOM_EMOJI_ID_FIELD = "background_custom_emoji_id"; - private static final String PROFILE_ACCENT_COLOR_ID_FIELD = "profile_accent_color_id"; - private static final String PROFILE_BACKGROUND_CUSTOM_EMOJI_ID_FIELD = "profile_background_custom_emoji_id"; - private static final String HAS_VISIBLE_HISTORY_FIELD = "has_visible_history"; - private static final String EMOJI_STATUS_CUSTOM_ID_FIELD = "emoji_status_custom_emoji_id"; - private static final String EMOJI_STATUS_EXPIRATION_DATE_FIELD = "emoji_status_expiration_date"; - private static final String UNRESTRICT_BOOST_COUNT_FIELD = "unrestrict_boost_count"; - private static final String CUSTOM_EMOJI_STICKER_SET_NAME_FIELD = "custom_emoji_sticker_set_name"; - private static final String BIRTHDATE_FIELD = "birthdate"; - private static final String BUSINESS_INTRO_FIELD = "business_intro"; - private static final String BUSINESS_LOCATION_FIELD = "business_location"; - private static final String BUSINESS_OPENING_HOURS_FIELD = "business_opening_hours"; - private static final String PERSONAL_CHAT_FIELD = "personal_chat"; - - private static final String USERCHATTYPE = "private"; - private static final String GROUPCHATTYPE = "group"; - private static final String CHANNELCHATTYPE = "channel"; - private static final String SUPERGROUPCHATTYPE = "supergroup"; - - /** - * Unique identifier for this chat. - * This number may be greater than 32 bits and some programming languages may - * have difficulty/silent defects in interpreting it. But it smaller than 52 bits, - * so a signed 64 bit integer or double-precision float type are safe for storing this identifier. - */ - @JsonProperty(ID_FIELD) - @NonNull - private Long id; - /** - * Type of the chat, one of “private”, “group” or “channel” or "supergroup" - */ - @JsonProperty(TYPE_FIELD) - @NonNull - private String type; - /** - * Optional. - * Title of the chat, only for channels and group chat - */ - @JsonProperty(TITLE_FIELD) - private String title; - /** - * Optional. - * Interlocutor's first name for private chats - */ - @JsonProperty(FIRSTNAME_FIELD) - private String firstName; - /** - * Optional. - * Interlocutor's last name for private chats - */ - @JsonProperty(LASTNAME_FIELD) - private String lastName; - /** - * Optional - * Username of the chat, only for private chats and channels if available - */ - @JsonProperty(USERNAME_FIELD) - private String userName; - /** - * Optional. - * Chat photo. Returned only in getChat. - */ - @JsonProperty(PHOTO_FIELD) - private ChatPhoto photo; - /** - * Optional. - * Description, for groups, supergroups and channel chats. Returned only in getChat. - */ - @JsonProperty(DESCRIPTION_FIELD) - private String description; - /** - * Optional. - * Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. - */ - @JsonProperty(INVITELINK_FIELD) - private String inviteLink; - /** - * Optional. - * The most recent pinned message (by sending date). Returned only in getChat. - */ - @JsonProperty(PINNEDMESSAGE_FIELD) - private Message pinnedMessage; - /** - * Optional. - * For supergroups, name of Group sticker set. Returned only in getChat. - */ - @JsonProperty(STICKERSETNAME_FIELD) - private String stickerSetName; - /** - * Optional. - * True, if the bot can change group the sticker set. Returned only in getChat. - */ - @JsonProperty(CANSETSTICKERSET_FIELD) - private Boolean canSetStickerSet; - /** - * Optional. - * Default chat member permissions, for groups and supergroups. Returned only in getChat. - */ - @JsonProperty(PERMISSIONS_FIELD) - private ChatPermissions permissions; - /** - * Optional. - * For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. - * Returned only in getChat. - */ - @JsonProperty(SLOWMODEDELAY_FIELD) - private Integer slowModeDelay; - /** - * Optional. - * Bio of the other party in a private chat. Returned only in getChat. - */ - @JsonProperty(BIO_FIELD) - private String bio; - /** - * Optional. - * Unique identifier for the linked chat, - * i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. - * This identifier may be greater than 32 bits and some programming - * languages may have difficulty/silent defects in interpreting it. - * But it is smaller than 52 bits, so a signed 64 bit integer or - * double-precision float type are safe for storing this identifier. - * Returned only in getChat. - */ - @JsonProperty(LINKEDCHATID_FIELD) - private Long linkedChatId; - /** - * Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. - */ - @JsonProperty(LOCATION_FIELD) - private ChatLocation location; - /** - * Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat. - */ - @JsonProperty(MESSAGEAUTODELETETIME_FIELD) - private Integer messageAutoDeleteTime; - /** - * Optional. - * True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. - * Returned only in getChat. - */ - @JsonProperty(HASPRIVATEFORWARDS_FIELD) - private Boolean hasPrivateForwards; - /** - * Optional. - * True, if messages from the chat can't be forwarded to other chats. - * Returned only in getChat. - */ - @JsonProperty(HASPROTECTEDCONTENT_FIELD) - private Boolean hasProtectedContent; - /** - * Optional. - * True, if users need to join the supergroup before they can send messages. - * Returned only in getChat. - */ - @JsonProperty(JOINTOSENDMESSAGES_FIELD) - private Boolean joinToSendMessages; - /** - * Optional. - * True, if all users directly joining the supergroup need to be approved by supergroup administrators. - * Returned only in getChat. - */ - @JsonProperty(JOINBYREQUEST_FIELD) - private Boolean joinByRequest; - /** - * Optional. - * True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. - * Returned only in getChat. - */ - @JsonProperty(HASRESTRICTEDVOICEANDVIDEOMESSAGES_FIELD) - private Boolean hasRestrictedVoiceAndVideoMessages; - /** - * Optional. - * True, if the supergroup chat is a forum (has topics enabled) - */ - @JsonProperty(ISFORUM_FIELD) - private Boolean isForum; - /** - * Optional. - * If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. - * Returned only in getChat. - */ - @JsonProperty(ACTIVEUSERNAMES_FIELD) - private List activeUsernames; - /** - * Optional. - * Custom emoji identifier of the emoji status of the chat or the other party in a private chat. - * Returned only in getChat. - */ - @JsonProperty(EMOJI_STATUS_CUSTOM_ID_FIELD) - private String emojiStatusCustomEmojiId; - /** - * Optional. - * True, if aggressive anti-spam checks are enabled in the supergroup. - * The field is only available to chat administrators. - * Returned only in getChat. - */ - @JsonProperty(HASAGGRESSIVEANTISPAMENABLED_FIELD) - private Boolean hasAggressiveAntiSpamEnabled; - /** - * Optional. - * True, if non-administrators can only get the list of bots and administrators in the chat. - * Returned only in getChat. - */ - @JsonProperty(HASHIDDENMEMBERS_FIELD) - private Boolean hasHiddenMembers; - /** - * Optional. - * Expiration date of the emoji status of the other party in a private chat, if any. - * Returned only in getChat. - */ - @JsonProperty(EMOJI_STATUS_EXPIRATION_DATE_FIELD) - private Boolean emojiStatusExpirationDate; - /** - * Optional. - * List of available reactions allowed in the chat. - * If omitted, then all emoji reactions are allowed. - * Returned only in getChat. - */ - @JsonProperty(AVAILABLE_REACTIONS_FIELD) - private List availableReactions; - /** - * Optional. - * Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. - * See accent colors for more details. - * Returned only in getChat. - * Always returned in getChat. - */ - @JsonProperty(ACCENT_COLOR_ID_FIELD) - private Integer accentColorId; - /** - * Optional. - * Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. - * Returned only in getChat. - */ - @JsonProperty(BACKGROUND_CUSTOM_EMOJI_ID_FIELD) - private String backgroundCustomEmojiId; - /** - * Optional. - * Identifier of the accent color for the chat's profile background. - * See profile accent colors for more details. - * Returned only in getChat. - */ - @JsonProperty(PROFILE_ACCENT_COLOR_ID_FIELD) - private Boolean profileAccentColorId; - /** - * Optional. - * Custom emoji identifier of the emoji chosen by the chat for its profile background. - * Returned only in getChat. - */ - @JsonProperty(PROFILE_BACKGROUND_CUSTOM_EMOJI_ID_FIELD) - private String profileBackgroundCustomEmojiId; - /** - * Optional. - * True, if new chat members will have access to old messages; available only to chat administrators. - * Returned only in getChat. - */ - @JsonProperty(HAS_VISIBLE_HISTORY_FIELD) - private Boolean hasVisibleHistory; - /** - * Optional. - * For supergroups, the minimum number of boosts that a non-administrator - * user needs to add in order to ignore slow mode and chat permissions. - * Returned only in getChat. - */ - @JsonProperty(UNRESTRICT_BOOST_COUNT_FIELD) - private Integer unrestrictBoostCount; - /** - * Optional. - * For supergroups, the name of the group's custom emoji sticker set. Custom emoji from - * this set can be used by all users and bots in the group. - * Returned only in getChat. - */ - @JsonProperty(CUSTOM_EMOJI_STICKER_SET_NAME_FIELD) - private String customEmojiStickerSetName; - /** - * Optional. - * For private chats, the date of birth of the user. - * Returned only in getChat. - */ - @JsonProperty(BIRTHDATE_FIELD) - private Birthdate birthdate; - /** - * Optional. - * For private chats with business accounts, the intro of the business. - * Returned only in getChat. - */ - @JsonProperty(BUSINESS_INTRO_FIELD) - private BusinessIntro businessIntro; - /** - * Optional. - * For private chats with business accounts, the location of the business. - * Returned only in getChat. - */ - @JsonProperty(BUSINESS_LOCATION_FIELD) - private BusinessLocation businessLocation; - /** - * Optional. - * For private chats with business accounts, the opening hours of the business. - * Returned only in getChat. - */ - @JsonProperty(BUSINESS_OPENING_HOURS_FIELD) - private BusinessOpeningHours businessOpeningHours; - /** - * Optional. - * For private chats, the personal channel of the user. - * Returned only in getChat. - */ - @JsonProperty(PERSONAL_CHAT_FIELD) - private Chat personalChat; - - @JsonIgnore - public Boolean isGroupChat() { - return GROUPCHATTYPE.equals(type); - } - - @JsonIgnore - public Boolean isChannelChat() { - return CHANNELCHATTYPE.equals(type); - } - - @JsonIgnore - public Boolean isUserChat() { - return USERCHATTYPE.equals(type); - } - - @JsonIgnore - public Boolean isSuperGroupChat() { - return SUPERGROUPCHATTYPE.equals(type); - } -} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatLocation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatLocation.java index 0eadd160a..45111d359 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatLocation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatLocation.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -27,7 +25,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ChatLocation implements BotApiObject { private static final String LOCATION_FIELD = "location"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java deleted file mode 100644 index 4369d2a7c..000000000 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatMemberUpdated.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.telegram.telegrambots.meta.api.objects; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import lombok.experimental.SuperBuilder; -import lombok.extern.jackson.Jacksonized; -import org.telegram.telegrambots.meta.api.objects.chat.Chat; -import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMember; - -/** - * @author Ruben Bermudez - * @version 5.1 - * This object represents changes in the status of a chat member. - * @deprecated Use {{@link org.telegram.telegrambots.meta.api.objects.chatmember.ChatMemberUpdated}} - */ -@EqualsAndHashCode(callSuper = false) -@Getter -@Setter -@ToString -@SuperBuilder -@Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) -@Deprecated -public class ChatMemberUpdated extends org.telegram.telegrambots.meta.api.objects.chatmember.ChatMemberUpdated { - public ChatMemberUpdated(Chat chat, User from, Integer date, ChatMember oldChatMember, ChatMember newChatMember, - ChatInviteLink inviteLink, Boolean viaChatFolderInviteLink) { - super(chat, from, date, oldChatMember, newChatMember, inviteLink, viaChatFolderInviteLink,null); - } - - public ChatMemberUpdated() { - super(); - } -} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java index cde9d1fde..9a9209c6a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPermissions.java @@ -1,12 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -29,7 +26,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ChatPermissions implements BotApiObject { private static final String CAN_SEND_MESSAGES_FIELD = "can_send_messages"; private static final String CANSENDAUDIOS_FIELD = "can_send_audios"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPhoto.java index e8cd2b0bb..9cc6098a0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatPhoto.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -26,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ChatPhoto implements BotApiObject { private static final String SMALLFILEID_FIELD = "small_file_id"; private static final String SMALLFILEUNIQUEID_FIELD = "small_file_unique_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java index 3ee017ff7..fce685601 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ChatShared.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -28,7 +27,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ChatShared implements BotApiObject { private static final String REQUEST_ID_FIELD = "request_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java index 79aea59d6..c7d2467f9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Dice.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -26,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Dice implements BotApiObject { private static final String VALUE_FIELD = "value"; private static final String EMOJI_FIELD = "emoji"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java index 625e46df1..a6259694b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Document.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -27,7 +25,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Document implements BotApiObject { private static final String FILEID_FIELD = "file_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LinkPreviewOptions.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LinkPreviewOptions.java index 39545f23c..005fdb08c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LinkPreviewOptions.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LinkPreviewOptions.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -27,7 +25,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class LinkPreviewOptions implements BotApiObject, Validable { private static final String IS_DISABLED_FIELD = "is_disabled"; private static final String URL_FIELD = "url"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java index 548d3ec3b..1cfc2c278 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/LoginUrl.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -32,7 +31,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class LoginUrl implements Validable, BotApiObject { private static final String URL_FIELD = "url"; private static final String FORWARD_TEXT_FIELD = "forward_text"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MemberStatus.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MemberStatus.java deleted file mode 100644 index 68fbe834c..000000000 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MemberStatus.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.telegram.telegrambots.meta.api.objects; - -/** - * @author Ruben Bermudez - * @version 1.0 - * Group members categories - * @deprecated Use {{@link org.telegram.telegrambots.meta.api.objects.chatmember.MemberStatus}} - */ -@Deprecated -public final class MemberStatus { - public static final String CREATOR = "creator"; - public static final String ADMINISTRATOR = "administrator"; - public static final String MEMBER = "member"; - public static final String LEFT = "left"; - public static final String KICKED = "kicked"; -} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java index 6b12908df..f402a9afd 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageEntity.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -29,7 +28,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class MessageEntity implements BotApiObject { private static final String TYPE_FIELD = "type"; private static final String OFFSET_FIELD = "offset"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageId.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageId.java index f70812874..49fd46e50 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageId.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/MessageId.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -26,7 +25,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class MessageId implements BotApiObject { private static final String MESSAGEID_FIELD = "message_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java index 4bb1da5ab..da9e46f7a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/PhotoSize.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -25,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class PhotoSize implements BotApiObject { private static final String FILEID_FIELD = "file_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ProximityAlertTriggered.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ProximityAlertTriggered.java index 60a6a1806..565d56754 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ProximityAlertTriggered.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/ProximityAlertTriggered.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -28,7 +26,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ProximityAlertTriggered implements BotApiObject { private static final String TRAVELER_FIELD = "traveler"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/TextQuote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/TextQuote.java index f4df05f3f..ed16ffc24 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/TextQuote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/TextQuote.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -28,7 +26,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class TextQuote implements BotApiObject { private static final String TEXT_FIELD = "text"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java index 80f3b0b5e..edad9c5d6 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/User.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -26,7 +25,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class User implements BotApiObject { private static final String ID_FIELD = "id"; private static final String FIRST_NAME_FIELD = "first_name"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java index f86d851fb..7c130270a 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UserShared.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -28,7 +27,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UserShared implements BotApiObject { private static final String USER_ID_FIELD = "user_id"; private static final String FIRST_NAME_FIELD = "first_name"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UsersShared.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UsersShared.java index 71052fac2..016831313 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UsersShared.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/UsersShared.java @@ -1,7 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -14,7 +12,6 @@ import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import java.util.List; -import java.util.stream.Collectors; /** * @author Ruben Bermudez @@ -29,7 +26,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class UsersShared implements BotApiObject { private static final String REQUEST_ID_FIELD = "request_id"; private static final String USERS_FIELD = "users"; @@ -44,16 +40,4 @@ public class UsersShared implements BotApiObject { */ @JsonProperty(USERS_FIELD) private List users; - - /** - * Use {{@link UsersShared#getUsers()}} - */ - @Deprecated - @JsonIgnore - public List getUserIds() { - if (users == null) { - return null; - } - return users.stream().map(UserShared::getUserId).collect(Collectors.toList()); - } } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Venue.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Venue.java index 587d1c670..57e48a2f1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Venue.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Venue.java @@ -1,12 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -27,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Venue implements BotApiObject { private static final String LOCATION_FIELD = "location"; private static final String TITLE_FIELD = "title"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java index 36bbe3385..5c539fd48 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Video.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -26,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Video implements BotApiObject { private static final String FILEID_FIELD = "file_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java index 878caa1b3..d114dea0d 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/VideoNote.java @@ -1,11 +1,9 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.ToString; @@ -26,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class VideoNote implements BotApiObject { private static final String FILEID_FIELD = "file_id"; private static final String FILEUNIQUEID_FIELD = "file_unique_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java index d1a1f627a..3d8cdfd81 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Voice.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -25,7 +24,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Voice implements BotApiObject { private static final String FILEID_FIELD = "file_id"; private static final String FILEUNIQUEID_FIELD = "file_unique_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java index 77a638106..c16638928 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/WriteAccessAllowed.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +24,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class WriteAccessAllowed implements BotApiObject { private static final String FROM_REQUEST_FIELD = "from_request"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/boost/ChatBoostSourceGiveaway.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/boost/ChatBoostSourceGiveaway.java index cd8d8317c..84526f3cb 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/boost/ChatBoostSourceGiveaway.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/boost/ChatBoostSourceGiveaway.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.boost; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -28,7 +27,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ChatBoostSourceGiveaway implements ChatBoostSource { private static final String SOURCE_FIELD = "source"; private static final String GIVEAWAY_MESSAGE_ID_FIELD = "giveaway_message_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/business/BusinessMessagesDeleted.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/business/BusinessMessagesDeleted.java index a46d7cc21..401638a72 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/business/BusinessMessagesDeleted.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/business/BusinessMessagesDeleted.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.business; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -28,7 +27,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class BusinessMessagesDeleted implements BotApiObject { private static final String BUSINESS_CONNECTION_ID_FIELD = "business_connection_id"; private static final String CHAT_FIELD = "chat"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java index 8b97fa8c1..de2457de7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/chatmember/ChatMemberMember.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.chatmember; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -29,7 +28,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ChatMemberMember implements ChatMember { public static final String STATUS = "member"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java index 620d9910e..58dcf0536 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/commands/BotCommand.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.commands; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class BotCommand implements BotApiObject, Validable { private static final String COMMAND_FIELD = "command"; private static final String DESCRIPTION_FIELD = "description"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java index 82b325c9a..4e561676c 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/games/Animation.java @@ -26,7 +26,6 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.SuperBuilder; -import lombok.experimental.Tolerate; import lombok.extern.jackson.Jacksonized; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; import org.telegram.telegrambots.meta.api.objects.PhotoSize; @@ -114,36 +113,4 @@ public class Animation implements BotApiObject { */ @JsonProperty(FILE_SIZE_FIELD) private Long fileSize; - - /** - * @deprecated Use {{@link #getMimeType()}} instead - */ - @Deprecated - @Tolerate - public String getMimetype() { - return mimeType; - } - - /** - * @deprecated Use {{@link #setMimeType(String)}} instead - */ - @Deprecated - @Tolerate - public void setMimetype(String mimetype) { - this.mimeType = mimetype; - } - - public static abstract class AnimationBuilder> { - - /** - * @deprecated Use {{@link #mimeType(String)}} instead - */ - @Deprecated - @Tolerate - public B mimetype(String mimetype) { - this.mimeType = mimetype; - return self(); - } - } - } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/gifts/Gift.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/gifts/Gift.java new file mode 100644 index 000000000..0bef53da0 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/gifts/Gift.java @@ -0,0 +1,68 @@ +package org.telegram.telegrambots.meta.api.objects.gifts; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; +import org.telegram.telegrambots.meta.api.objects.stickers.Sticker; + +/** + * @author Ruben Bermudez + * @version 8.0 + * + * This object represents a gift that can be sent by the bot. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@AllArgsConstructor +@SuperBuilder +@Jacksonized +public class Gift implements BotApiObject { + private static final String ID_FIELD = "id"; + private static final String STICKER_FIELD = "sticker"; + private static final String STAR_COUNT_FIELD = "star_count"; + private static final String TOTAL_COUNT_FIELD = "total_count"; + private static final String REMAINING_COUNT_FIELD = "remaining_count"; + + /** + * Unique identifier of the gift + */ + @JsonProperty(ID_FIELD) + @NonNull + private String id; + /** + * The sticker that represents the gift + */ + @JsonProperty(STICKER_FIELD) + @NonNull + private Sticker sticker; + /** + * The number of Telegram Stars that must be paid to send the sticker + */ + @JsonProperty(STAR_COUNT_FIELD) + @NonNull + private Integer starCount; + /** + * Optional. + * The total number of the gifts of this type that can be sent; for limited gifts only + */ + @JsonProperty(TOTAL_COUNT_FIELD) + private Integer totalCount; + /** + * Optional. + * The number of remaining gifts of this type that can be sent; for limited gifts only + */ + @JsonProperty(REMAINING_COUNT_FIELD) + @NonNull + private Integer remainingCount; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/gifts/Gifts.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/gifts/Gifts.java new file mode 100644 index 000000000..4d8db99ec --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/gifts/Gifts.java @@ -0,0 +1,37 @@ +package org.telegram.telegrambots.meta.api.objects.gifts; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +import java.util.List; + +/** + * @author Ruben Bermudez + * @version 8.0 + * + * This object represent a list of gifts. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@AllArgsConstructor +@SuperBuilder +@Jacksonized +public class Gifts implements BotApiObject { + private static final String GIFTS_FIELD = "gifts"; + /** + * The list of gifts + */ + @JsonProperty(GIFTS_FIELD) + @NonNull + private List gifts; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/Giveaway.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/Giveaway.java index 5de9bd64c..4392fb9c9 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/Giveaway.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/Giveaway.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.giveaway; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -28,7 +27,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Giveaway implements BotApiObject { public static final String CHATS_FIELD = "chats"; public static final String WINNERS_SELECTION_DATE_FIELD = "winners_selection_date"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCompleted.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCompleted.java index b3ec9ec96..bd14e1b09 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCompleted.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCompleted.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.giveaway; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -27,7 +26,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GiveawayCompleted implements BotApiObject { public static final String WINNER_COUNT_FIELD = "winner_count"; public static final String UNCLAIMED_PRIZE_COUNT_FIELD = "unclaimed_prize_count"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCreated.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCreated.java index f14def4e1..55dcc4698 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCreated.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayCreated.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.giveaway; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +23,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GiveawayCreated implements BotApiObject { private static final String PRIZE_STAR_COUNT_FIELD = "prize_star_count"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayWinners.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayWinners.java index e7d556f88..2e98da868 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayWinners.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/giveaway/GiveawayWinners.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.giveaway; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -11,8 +10,8 @@ import lombok.experimental.SuperBuilder; import lombok.extern.jackson.Jacksonized; import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; -import org.telegram.telegrambots.meta.api.objects.chat.Chat; import org.telegram.telegrambots.meta.api.objects.User; +import org.telegram.telegrambots.meta.api.objects.chat.Chat; import java.util.List; @@ -30,7 +29,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class GiveawayWinners implements BotApiObject { public static final String CHAT_FIELD = "chat"; public static final String GIVEAWAY_MESSAGE_ID_FIELD = "giveaway_message_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/paid/InputPaidMedia.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/paid/InputPaidMedia.java index e22d80d00..357a3d7e7 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/paid/InputPaidMedia.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/media/paid/InputPaidMedia.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects.media.paid; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -38,7 +37,6 @@ @RequiredArgsConstructor @AllArgsConstructor @SuperBuilder -@JsonIgnoreProperties(ignoreUnknown = true) @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java index b6ec9b830..5ff42a755 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/Message.java @@ -1,7 +1,6 @@ package org.telegram.telegrambots.meta.api.objects.message; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -80,7 +79,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Message implements MaybeInaccessibleMessage { private static final String MESSAGE_ID_FIELD = "message_id"; private static final String MESSAGE_THREAD_ID_FIELD = "message_thread_id"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/PreparedInlineMessage.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/PreparedInlineMessage.java new file mode 100644 index 000000000..b63cae606 --- /dev/null +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/message/PreparedInlineMessage.java @@ -0,0 +1,44 @@ +package org.telegram.telegrambots.meta.api.objects.message; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; +import org.telegram.telegrambots.meta.api.interfaces.BotApiObject; + +/** + * @author Ruben Bermudez + * @version 8.0 + * + * Describes an inline message to be sent by a user of a Mini App. + */ +@EqualsAndHashCode(callSuper = false) +@Getter +@Setter +@ToString +@RequiredArgsConstructor +@AllArgsConstructor +@SuperBuilder +@Jacksonized +@JsonIgnoreProperties(ignoreUnknown = true) +public class PreparedInlineMessage implements BotApiObject { + private static final String ID_FIELD = "id"; + private static final String EXPIRATION_DATE_FIELD = "expiration_date"; + + /** + * Unique identifier of the prepared message + */ + @JsonProperty(ID_FIELD) + private String messageId; + /** + * Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used + */ + @JsonProperty(EXPIRATION_DATE_FIELD) + private Integer expirationDate; +} diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/Invoice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/Invoice.java index 706cf8366..cae5f36ab 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/Invoice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/Invoice.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.payments; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -27,7 +26,6 @@ @AllArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class Invoice implements BotApiObject { private static final String TITLE_FIELD = "title"; private static final String DESCRIPTION_FIELD = "description"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java index 07be72374..ae74e9189 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/LabeledPrice.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.payments; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class LabeledPrice implements Validable, BotApiObject { private static final String LABEL_FIELD = "label"; private static final String AMOUNT_FIELD = "amount"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/PaidMediaPurchased.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/PaidMediaPurchased.java index cfc78c1fa..1d2327d69 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/PaidMediaPurchased.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/PaidMediaPurchased.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.payments; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +24,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class PaidMediaPurchased implements BotApiObject { private static final String FROM_FIELD = "from"; private static final String PAID_MEDIA_PAYLOAD_FIELD = "paid_media_payload"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/SuccessfulPayment.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/SuccessfulPayment.java index 0980423ca..1607005b1 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/SuccessfulPayment.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/SuccessfulPayment.java @@ -35,6 +35,9 @@ public class SuccessfulPayment implements BotApiObject { private static final String ORDER_INFO_FIELD = "order_info"; private static final String TELEGRAM_PAYMENT_CHARGE_ID_FIELD = "telegram_payment_charge_id"; private static final String PROVIDER_PAYMENT_CHARGE_ID_FIELD = "provider_payment_charge_id"; + private static final String SUBSCRIPTION_EXPIRATION_DATE_FIELD = "subscription_expiration_date"; + private static final String IS_RECURRING_FIELD = "is_recurring"; + private static final String IS_FIRST_RECURRING_FIELD = "is_first_recurring"; /** * Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars @@ -74,4 +77,22 @@ public class SuccessfulPayment implements BotApiObject { */ @JsonProperty(PROVIDER_PAYMENT_CHARGE_ID_FIELD) private String providerPaymentChargeId; + /** + * Optional. + * Expiration date of the subscription, in Unix time; for recurring payments only + */ + @JsonProperty(SUBSCRIPTION_EXPIRATION_DATE_FIELD) + private Integer subscriptionExpirationDate; + /** + * Optional. + * True, if the payment is a recurring payment for a subscription + */ + @JsonProperty(IS_RECURRING_FIELD) + private Boolean isRecurring; + /** + * Optional. + * True, if the payment is the first payment for a subscription + */ + @JsonProperty(IS_FIRST_RECURRING_FIELD) + private Boolean isFirstRecurring; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/paidmedia/PaidMediaPhoto.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/paidmedia/PaidMediaPhoto.java index dae4f3d4e..fcfa817dc 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/paidmedia/PaidMediaPhoto.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/paidmedia/PaidMediaPhoto.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.payments.paidmedia; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -11,7 +10,6 @@ import lombok.experimental.SuperBuilder; import lombok.extern.jackson.Jacksonized; import org.telegram.telegrambots.meta.api.objects.PhotoSize; -import org.telegram.telegrambots.meta.api.objects.payments.transactionpartner.TransactionPartner; import java.util.List; @@ -27,7 +25,6 @@ @ToString @RequiredArgsConstructor @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) @SuperBuilder public class PaidMediaPhoto implements PaidMedia { private static final String TYPE_FIELD = "type"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java index b0916c802..1a76e1db0 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/payments/transactionpartner/TransactionPartnerUser.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.payments.transactionpartner; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,6 @@ @ToString @RequiredArgsConstructor @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) @SuperBuilder public class TransactionPartnerUser implements TransactionPartner { private static final String TYPE_FIELD = "type"; @@ -36,6 +34,8 @@ public class TransactionPartnerUser implements TransactionPartner { private static final String INVOICE_PAYLOAD_FIELD = "invoice_payload"; private static final String PAID_MEDIA_FIELD = "paid_media"; private static final String PAID_MEDIA_PAYLOAD_FIELD = "paid_media_payload"; + private static final String GIFT_FIELD = "gift"; + private static final String SUBSCRIPTION_PERIOD_FIELD = "subscription_period"; /** * Type of the transaction partner, always “user” @@ -67,4 +67,18 @@ public class TransactionPartnerUser implements TransactionPartner { */ @JsonProperty(PAID_MEDIA_PAYLOAD_FIELD) private String paidMediaPayload; + + /** + * Optional. + * The gift sent to the user by the bot + */ + @JsonProperty(GIFT_FIELD) + private String gift; + + /** + * Optional. + * The duration of the paid subscription + */ + @JsonProperty(SUBSCRIPTION_PERIOD_FIELD) + private Integer subscriptionPeriod; } diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypeEmoji.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypeEmoji.java index 121d644b7..c67495b28 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypeEmoji.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypeEmoji.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.reactions; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ReactionTypeEmoji implements ReactionType { private static final String TYPE_FIELD = "type"; private static final String EMOJI_FIELD = "emoji"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java index f32c4060e..e1010791b 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/reactions/ReactionTypePaid.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.reactions; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -26,7 +25,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class ReactionTypePaid implements ReactionType { private static final String TYPE_FIELD = "type"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java index 0096df7e3..10b682524 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/MaskPosition.java @@ -1,6 +1,5 @@ package org.telegram.telegrambots.meta.api.objects.stickers; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import lombok.EqualsAndHashCode; @@ -28,7 +27,6 @@ @RequiredArgsConstructor @SuperBuilder @Jacksonized -@JsonIgnoreProperties(ignoreUnknown = true) public class MaskPosition implements Validable, BotApiObject { private static final String POINT_FIELD = "point"; private static final String XSHIFT_FIELD = "x_shift"; diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java index 446dfb08e..905840d1f 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/stickers/StickerSet.java @@ -52,18 +52,6 @@ public class StickerSet implements BotApiObject { */ @JsonProperty(STICKERS_FIELD) private List stickers; - /** - * List of all set stickers - */ - @JsonProperty(IS_ANIMATED_FIELD) - @Deprecated - private Boolean isAnimated; - /** - * True, if the sticker set contains video stickers - */ - @JsonProperty(IS_VIDEO_FIELD) - @Deprecated - private Boolean isVideo; /** * Optional. * Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format diff --git a/telegrambots-springboot-longpolling-starter/src/main/java/org/telegram/telegrambots/longpolling/starter/TelegramBotInitializer.java b/telegrambots-springboot-longpolling-starter/src/main/java/org/telegram/telegrambots/longpolling/starter/TelegramBotInitializer.java index 103cf860f..53e70aef0 100644 --- a/telegrambots-springboot-longpolling-starter/src/main/java/org/telegram/telegrambots/longpolling/starter/TelegramBotInitializer.java +++ b/telegrambots-springboot-longpolling-starter/src/main/java/org/telegram/telegrambots/longpolling/starter/TelegramBotInitializer.java @@ -1,5 +1,6 @@ package org.telegram.telegrambots.longpolling.starter; +import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.telegram.telegrambots.longpolling.BotSession; @@ -9,7 +10,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; -import java.util.Objects; import java.util.stream.Stream; @Slf4j @@ -18,10 +18,8 @@ public class TelegramBotInitializer implements InitializingBean { private final TelegramBotsLongPollingApplication telegramBotsApplication; private final List longPollingBots; - public TelegramBotInitializer(TelegramBotsLongPollingApplication telegramBotsApplication, - List longPollingBots) { - Objects.requireNonNull(telegramBotsApplication); - Objects.requireNonNull(longPollingBots); + public TelegramBotInitializer(@NonNull TelegramBotsLongPollingApplication telegramBotsApplication, + @NonNull List longPollingBots) { this.telegramBotsApplication = telegramBotsApplication; this.longPollingBots = longPollingBots; } diff --git a/telegrambots-springboot-webhook-starter/src/main/java/org/telegram/telegrambots/webhook/starter/TelegramBotInitializer.java b/telegrambots-springboot-webhook-starter/src/main/java/org/telegram/telegrambots/webhook/starter/TelegramBotInitializer.java index 5ed8de1f0..75a71c13a 100644 --- a/telegrambots-springboot-webhook-starter/src/main/java/org/telegram/telegrambots/webhook/starter/TelegramBotInitializer.java +++ b/telegrambots-springboot-webhook-starter/src/main/java/org/telegram/telegrambots/webhook/starter/TelegramBotInitializer.java @@ -1,5 +1,6 @@ package org.telegram.telegrambots.webhook.starter; +import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.telegram.telegrambots.meta.exceptions.TelegramApiException; @@ -7,7 +8,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; -import java.util.Objects; import java.util.stream.Stream; @Slf4j @@ -16,10 +16,8 @@ public class TelegramBotInitializer implements InitializingBean { private final TelegramBotsSpringWebhookApplication telegramBotsApplication; private final List webhookBots; - public TelegramBotInitializer(TelegramBotsSpringWebhookApplication telegramBotsApplication, - List webhookBots) { - Objects.requireNonNull(telegramBotsApplication); - Objects.requireNonNull(webhookBots); + public TelegramBotInitializer(@NonNull TelegramBotsSpringWebhookApplication telegramBotsApplication, + @NonNull List webhookBots) { this.telegramBotsApplication = telegramBotsApplication; this.webhookBots = webhookBots; } diff --git a/telegrambots-test-reports/pom.xml b/telegrambots-test-reports/pom.xml index a4e21c579..e59d65499 100644 --- a/telegrambots-test-reports/pom.xml +++ b/telegrambots-test-reports/pom.xml @@ -17,8 +17,9 @@ Easy to use library to create Telegram Bots - 17 - 17 + 17 + ${java.version} + ${java.version} UTF-8 UTF-8 diff --git a/telegrambots-webhook/pom.xml b/telegrambots-webhook/pom.xml index 63a3060cd..1d386871f 100644 --- a/telegrambots-webhook/pom.xml +++ b/telegrambots-webhook/pom.xml @@ -51,8 +51,9 @@ - 17 - 17 + 17 + ${java.version} + ${java.version} UTF-8 UTF-8