Class VkMethod<VkResponse>

java.lang.Object
api.longpoll.bots.methods.impl.VkMethod<VkResponse>
Type Parameters:
VkResponse - VK API response type.
Direct Known Subclasses:
AddAddress, AddCallbackServer, CheckLink, CloseComments, CreateChat, CreateComment, Delete, Delete, DeleteAddress, DeleteCallbackServer, DeleteChatPhoto, DeleteComment, DeleteConversation, DisableOnline, Edit, EditAddress, EditCallbackServer, EditChat, EditOrder, EnableOnline, Execute, Get, Get, GetBanned, GetByConversationMessageId, GetById, GetById, GetById, GetCallbackConfirmationCode, GetCallbackServers, GetCallbackSettings, GetChatUploadServer, GetConversationMembers, GetConversations, GetConversationsById, GetGroupOrders, GetHistory, GetHistoryAttachments, GetImportantMessages, GetInviteLink, GetLinkStats, GetLongPollServer, GetLongPollSettings, GetMembers, GetMessagesUploadServer, GetMessagesUploadServer, GetOnlineStatus, GetOrderById, GetOrderItems, GetOwnerCoverPhotoUploadServer, GetPhotoUploadServer, GetReplies, GetServerTime, GetShortLink, GetStats, GetTokenPermissions, GetUpdates, GetVideoUploadServer, GetViewers, GetWallUploadServer, HideAllReplies, HideReply, IsMember, IsMessagesFromGroupAllowed, MarkAsAnsweredConversation, MarkAsImportantConversation, MarkAsRead, OpenComments, Pin, RemoveChatUser, ResolveScreenName, Restore, RestoreComment, Save, Save, SaveMessagesPhoto, SaveOwnerCoverPhoto, Search, SearchConversations, Send, SendEventAnswer, SetActivity, SetCallbackSettings, SetChatPhoto, SetLongPollSettings, SetSettings, Unpin, UploadMethod

public abstract class VkMethod<VkResponse> extends Object
Executes generic HTTP request to VK API.
  • Constructor Details

    • VkMethod

      public VkMethod(String url, String accessToken)
    • VkMethod

      public VkMethod(String url)
  • Method Details

    • executeAsync

      public CompletableFuture<VkResponse> executeAsync()
      Executes request to VK API asynchronously.
      Returns:
      VK API response wrapped to CompletableFuture
    • execute

      public VkResponse execute() throws VkApiException
      Executes request to VK API.
      Returns:
      VK API response.
      Throws:
      VkApiException - if errors occur.
    • getResponseClass

      protected abstract Class<VkResponse> getResponseClass()
      Gets a class of VK API response. This value is used during deserialization of received JSON.
      Returns:
      a class of VK API response.
    • newRequestBody

      protected okhttp3.RequestBody newRequestBody()
      Supplies new request body.
      Returns:
      request body.
    • addParam

      public VkMethod<VkResponse> addParam(String key, Object value)
      Adds URL parameter to HTTP request.
      Parameters:
      key - URL parameter key.
      value - URL parameter value.
      Returns:
      current instance.
    • setLang

      public VkMethod<VkResponse> setLang(Lang lang)
      Sets lang parameter.
      Parameters:
      lang - lang value.
      Returns:
      current instance.