Interface ApiMethod<R extends Serializable>

Type Parameters:
R - result type of the method
All Known Subinterfaces:
ApiMethodBoolean, ApiMethodMessage, ApiMethodMultiResponse, MultiPartApiMethod<R>, MultiPartApiMethodBoolean, MultiPartApiMethodMessage
All Known Implementing Classes:
AddStickerToSet, AnswerCallbackQuery, AnswerInlineQuery, AnswerPreCheckoutQuery, AnswerShippingQuery, AnswerWebAppQuery, ApproveChatJoinRequest, ApproveSuggestedPost, BanChatMember, BanChatSenderChat, BatchCopyMessages, BatchDeleteMessages, BatchForwardMessages, CloseForumTopic, CloseGeneralForumTopic, ConvertGiftToStars, CopyMessage, CopyTextButton, CreateChatInviteLink, CreateChatSubscriptionInviteLink, CreateForumTopic, CreateInvoiceLink, CreateNewStickerSet, DeclineChatJoinRequest, DeclineSuggestedPost, DeleteBusinessMessages, DeleteChatPhoto, DeleteChatStickerSet, DeleteForumTopic, DeleteMessage, DeleteMyCommands, DeleteStickerFromSet, DeleteStickerSet, DeleteStory, DeleteWebhook, EditChatInviteLink, EditChatSubscriptionInviteLink, EditForumTopic, EditGeneralForumTopic, EditMessageCaption, EditMessageChecklist, EditMessageLiveLocation, EditMessageMedia, EditMessageReplyMarkup, EditMessageText, EditStory, EditUserStarSubscription, ExportChatInviteLink, ForwardMessage, GetAvailableGifts, GetBusinessAccountGifts, GetBusinessAccountStarBalance, GetBusinessConnection, GetChat, GetChatAdministrators, GetChatGifts, GetChatMember, GetChatMemberCount, GetChatMenuButton, GetCustomEmojiStickers, GetFile, GetForumTopicIconStickers, GetGameHighScores, GetMe, GetMyCommands, GetMyDefaultAdministratorRights, GetMyDescription, GetMyName, GetMyShortDescription, GetMyStarBalance, GetStarTransactions, GetStickerSet, GetUpdates, GetUserChatBoosts, GetUserGifts, GetUserProfileAudios, GetUserProfilePhotos, GetWebhookInfo, GiftPremiumSubscription, HideGeneralForumTopic, LeaveChat, PinChatMessage, PostStory, PromoteChatMember, ReadBusinessMessage, RefundStarPayment, RemoveBusinessAccountProfilePhoto, RemoveChatVerification, RemoveMyProfilePhoto, RemoveUserVerification, ReopenForumTopic, ReopenGeneralForumTopic, ReplaceStickerInSet, RepostStory, RestrictChatMember, RevokeChatInviteLink, SavePreparedInlineMessage, SendAnimation, SendAudio, SendChatAction, SendChecklist, SendContact, SendDice, SendDocument, SendGame, SendGift, SendInvoice, SendLocation, SendMediaGroup, SendMessage, SendMessageDraft, SendPaidMedia, SendPhoto, SendPoll, SendSticker, SendVenue, SendVideo, SendVideoNote, SendVoice, SetBusinessAccountBio, SetBusinessAccountGiftSettings, SetBusinessAccountName, SetBusinessAccountProfilePhoto, SetBusinessAccountUsername, SetChatAdministratorCustomTitle, SetChatDescription, SetChatMenuButton, SetChatPermissions, SetChatPhoto, SetChatStickerSet, SetChatTitle, SetCustomEmojiStickerSetThumbnail, SetGameScore, SetMessageReaction, SetMyCommands, SetMyDefaultAdministratorRights, SetMyDescription, SetMyName, SetMyProfilePhoto, SetMyShortDescription, SetPassportDataErrors, SetStickerEmojiList, SetStickerKeywords, SetStickerMaskPosition, SetStickerPositionInSet, SetStickerSetThumbnail, SetStickerSetTitle, SetUserEmojiStatus, SetWebhook, StopMessageLiveLocation, StopPoll, TransferBusinessAccountStars, TransferGift, UnbanChatMember, UnbanChatSenderChat, UnhideGeneralForumTopic, UnpinAllChatMessages, UnpinAllForumTopicMessages, UnpinAllGeneralForumTopicMessages, UnpinChatMessage, UpgradeGift, UploadStickerFile, VerifyChat, VerifyUser

public interface ApiMethod<R extends Serializable>
Base interface for all Telegram Bot API methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.fasterxml.jackson.databind.ObjectMapper
    The object mapper used to serialize and deserialize objects to and from JSON.
  • Method Summary

    Modifier and Type
    Method
    Description
    deserializeResponse(@NotNull String answer)
    Deserializes the response from the Telegram Bot API.
    default R
    deserializeResponse(@NotNull String answer, @NotNull Class<R> returnClass)
    Deserializes the response from the Telegram Bot API into a specific class.
    default <K extends Serializable>
    R
    deserializeResponseArray(@NotNull String answer, @NotNull Class<K> returnClass)
    Deserializes the response from the Telegram Bot API into an array of a specific class.
    default <K extends Serializable>
    R
    deserializeResponseSerializable(String answer, Class<K> returnClass)
    Deserializes the response from the Telegram Bot API into a specific serializable class
    @NotNull String
    Returns the endpoint URL for the Telegram Bot API method.
  • Field Details

    • OBJECT_MAPPER

      static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
      The object mapper used to serialize and deserialize objects to and from JSON.
  • Method Details

    • getEndpointURL

      @NotNull @NotNull String getEndpointURL()
      Returns the endpoint URL for the Telegram Bot API method.
      Returns:
      the endpoint URL
    • deserializeResponse

      @Internal @NotNull R deserializeResponse(@NotNull @NotNull String answer) throws TelegramRequestException
      Deserializes the response from the Telegram Bot API.
      Parameters:
      answer - the response from the Telegram Bot API
      Returns:
      the deserialized response
      Throws:
      TelegramRequestException - if an error occurs while deserializing the response
    • deserializeResponse

      @Internal @NotNull default R deserializeResponse(@NotNull @NotNull String answer, @NotNull @NotNull Class<R> returnClass) throws TelegramRequestException
      Deserializes the response from the Telegram Bot API into a specific class.
      Parameters:
      answer - the response from the Telegram Bot API
      returnClass - the class to deserialize the response into
      Returns:
      the deserialized response
      Throws:
      TelegramRequestException - if an error occurs while deserializing the response
    • deserializeResponseArray

      @Internal @NotNull default <K extends Serializable> R deserializeResponseArray(@NotNull @NotNull String answer, @NotNull @NotNull Class<K> returnClass) throws TelegramRequestException
      Deserializes the response from the Telegram Bot API into an array of a specific class.
      Type Parameters:
      K - the class to deserialize the response into
      Parameters:
      answer - the response from the Telegram Bot API
      returnClass - the class to deserialize the response into
      Returns:
      the deserialized response
      Throws:
      TelegramRequestException - if an error occurs while deserializing the response
    • deserializeResponseSerializable

      @Internal default <K extends Serializable> R deserializeResponseSerializable(String answer, Class<K> returnClass) throws TelegramRequestException
      Deserializes the response from the Telegram Bot API into a specific serializable class
      Type Parameters:
      K - the class to deserialize the response into
      Parameters:
      answer - the response from the Telegram Bot API
      returnClass - the class to deserialize the response into
      Returns:
      the deserialized response
      Throws:
      TelegramRequestException - if an error occurs while deserializing the response