@ Override public final Message execute ( SendDocument sendDocument ) throws TelegramApiException { assertParamNotNull ( sendDocument , "sendDocument" ) ; sendDocument . validate ( ) ; try { String url = getBaseUrl ( ) + SendDocument . PATH ; HttpPost httppost = configuredHttpPost ( url ) ; MultipartEntityBuilder builder = MultipartEntityBuilder . create ( ) ; builder . setLaxMode ( ) ; builder . setCharset ( StandardCharsets . UTF_8 ) ; builder . addTextBody ( SendDocument . CHATID_FIELD , sendDocument . getChatId ( ) , TEXT_PLAIN_CONTENT_TYPE ) ; addInputFile ( builder , sendDocument . getDocument ( ) , SendDocument . DOCUMENT_FIELD , true ) ; if ( sendDocument . getReplyMarkup ( ) != null ) { builder . addTextBody ( SendDocument . REPLYMARKUP_FIELD , objectMapper . writeValueAsString ( sendDocument . getReplyMarkup ( ) ) , TEXT_PLAIN_CONTENT_TYPE ) ; } if ( sendDocument . getReplyToMessageId ( ) != null ) { builder . addTextBody ( SendDocument . REPLYTOMESSAGEID_FIELD , sendDocument . getReplyToMessageId ( ) . toString ( ) , TEXT_PLAIN_CONTENT_TYPE ) ; } if ( sendDocument . getCaption ( ) != null ) { builder . addTextBody ( SendDocument . CAPTION_FIELD , sendDocument . getCaption ( ) , TEXT_PLAIN_CONTENT_TYPE ) ; if ( sendDocument . getParseMode ( ) != null ) { builder . addTextBody ( SendDocument . PARSEMODE_FIELD , sendDocument . getParseMode ( ) , TEXT_PLAIN_CONTENT_TYPE ) ; } } if ( sendDocument . getDisableNotification ( ) != null ) { builder . addTextBody ( SendDocument . DISABLENOTIFICATION_FIELD , sendDocument . getDisableNotification ( ) . toString ( ) , TEXT_PLAIN_CONTENT_TYPE ) ; } if ( sendDocument . getThumb ( ) != null ) { addInputFile ( builder , sendDocument . getThumb ( ) , SendDocument . THUMB_FIELD , false ) ; builder . addTextBody ( SendDocument . THUMB_FIELD , sendDocument . getThumb ( ) . getAttachName ( ) , TEXT_PLAIN_CONTENT_TYPE ) ; } HttpEntity multipart = builder . build ( ) ; httppost . setEntity ( multipart ) ; return sendDocument . deserializeResponse ( sendHttpPostRequest ( httppost ) ) ; } catch ( IOException e ) { throw new TelegramApiException ( "Unable to send document" , e ) ; } }
Specific Send Requests