Skip to content

Commit

Permalink
Remove field text from EditMessageCaption and EditMessageReplyMarkup …
Browse files Browse the repository at this point in the history
…constructors #119
  • Loading branch information
pengrad committed Dec 10, 2017
1 parent 2e57e92 commit 1a385fe
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,30 @@
*/
public class EditMessageCaption extends BaseRequest<EditMessageCaption, BaseResponse> {

public EditMessageCaption(Object chatId, int messageId, String text) {
public EditMessageCaption(Object chatId, int messageId) {
super(SendResponse.class);
add("chat_id", chatId).add("message_id", messageId).add("text", text);
add("chat_id", chatId).add("message_id", messageId);
}

public EditMessageCaption(String inlineMessageId, String text) {
public EditMessageCaption(String inlineMessageId) {
super(BaseResponse.class);
add("inline_message_id", inlineMessageId).add("text", text);
add("inline_message_id", inlineMessageId);
}

/**
* @deprecated Use EditMessageCaption(Object chatId, int messageId)
*/
@Deprecated
public EditMessageCaption(Object chatId, int messageId, String text) {
this(chatId, messageId);
}

/**
* @deprecated Use EditMessageCaption(String inlineMessageId)
*/
@Deprecated
public EditMessageCaption(String inlineMessageId, String text) {
this(inlineMessageId);
}

public EditMessageCaption caption(String caption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,30 @@
*/
public class EditMessageReplyMarkup extends BaseRequest<EditMessageReplyMarkup, BaseResponse> {

public EditMessageReplyMarkup(Object chatId, int messageId, String text) {
public EditMessageReplyMarkup(Object chatId, int messageId) {
super(SendResponse.class);
add("chat_id", chatId).add("message_id", messageId).add("text", text);
add("chat_id", chatId).add("message_id", messageId);
}

public EditMessageReplyMarkup(String inlineMessageId, String text) {
public EditMessageReplyMarkup(String inlineMessageId) {
super(BaseResponse.class);
add("inline_message_id", inlineMessageId).add("text", text);
add("inline_message_id", inlineMessageId);
}

/**
* @deprecated Use EditMessageReplyMarkup(Object chatId, int messageId)
*/
@Deprecated
public EditMessageReplyMarkup(Object chatId, int messageId, String text) {
this(chatId, messageId);
}

/**
* @deprecated Use EditMessageReplyMarkup(String inlineMessageId)
*/
@Deprecated
public EditMessageReplyMarkup(String inlineMessageId, String text) {
this(inlineMessageId);
}

public EditMessageReplyMarkup replyMarkup(InlineKeyboardMarkup replyMarkup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ public void editMessageText() {
public void editMessageCaption() {
String text = "Update " + System.currentTimeMillis();

BaseResponse response = bot.execute(new EditMessageCaption(chatId, 8124, text)
BaseResponse response = bot.execute(new EditMessageCaption(chatId, 8124)
.caption(text)
.replyMarkup(new InlineKeyboardMarkup()));
assertTrue(response.isOk());

response = bot.execute(new EditMessageCaption(channelName, 511, text).caption(text));
response = bot.execute(new EditMessageCaption(channelName, 511).caption(text));
assertTrue(response.isOk());

response = bot.execute(new EditMessageCaption("AgAAAPrwAQCj_Q4D2s-51_8jsuU", "").caption(text));
response = bot.execute(new EditMessageCaption("AgAAAPrwAQCj_Q4D2s-51_8jsuU").caption(text));
if (!response.isOk()) {
assertEquals(400, response.errorCode());
assertEquals("Bad Request: MESSAGE_ID_INVALID", response.description());
Expand All @@ -204,13 +204,13 @@ public void editMessageReplyMarkup() {
InlineKeyboardMarkup gameKeyboard = new InlineKeyboardMarkup(new InlineKeyboardButton[]{
new InlineKeyboardButton(text).callbackGame("test game")});

BaseResponse response = bot.execute(new EditMessageReplyMarkup(chatId, 8124, text).replyMarkup(keyboard));
BaseResponse response = bot.execute(new EditMessageReplyMarkup(chatId, 8124).replyMarkup(keyboard));
assertTrue(response.isOk());

response = bot.execute(new EditMessageReplyMarkup(channelName, 511, text).replyMarkup(keyboard));
response = bot.execute(new EditMessageReplyMarkup(channelName, 511).replyMarkup(keyboard));
assertTrue(response.isOk());

response = bot.execute(new EditMessageReplyMarkup("AgAAAPrwAQCj_Q4D2s-51_8jsuU", "").replyMarkup(gameKeyboard));
response = bot.execute(new EditMessageReplyMarkup("AgAAAPrwAQCj_Q4D2s-51_8jsuU").replyMarkup(gameKeyboard));
if (!response.isOk()) {
assertEquals(400, response.errorCode());
assertEquals("Bad Request: MESSAGE_ID_INVALID", response.description());
Expand Down

0 comments on commit 1a385fe

Please sign in to comment.