Skip to content

Commit

Permalink
New methods setGameScore and getGameHighScores
Browse files Browse the repository at this point in the history
  • Loading branch information
pengrad committed Oct 3, 2016
1 parent f4a4275 commit 41c3c62
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/main/java/com/pengrad/telegrambot/model/GameHighScore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.pengrad.telegrambot.model;

/**
* Stas Parshin
* 04 October 2016
*/
public class GameHighScore {

private Integer position;
private User user;
private Integer score;

public Integer position() {
return position;
}

public User user() {
return user;
}

public Integer score() {
return score;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

GameHighScore that = (GameHighScore) o;

if (!position.equals(that.position)) return false;
if (!user.equals(that.user)) return false;
return score.equals(that.score);

}

@Override
public int hashCode() {
int result = position.hashCode();
result = 31 * result + user.hashCode();
result = 31 * result + score.hashCode();
return result;
}

@Override
public String toString() {
return "GameHighScore{" +
"position=" + position +
", user=" + user +
", score=" + score +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.pengrad.telegrambot.request;

import com.pengrad.telegrambot.response.GetWebhookInfoResponse;

/**
* Stas Parshin
* 04 October 2016
*/
public class GetGameHighScores extends BaseRequest<GetGameHighScores, GetWebhookInfoResponse> {

public GetGameHighScores(int userId, Object chatId, int messageId) {
super(GetWebhookInfoResponse.class);
add("user_id", userId).add("chat_id", chatId).add("message_id", messageId);
}

public GetGameHighScores(int userId, String inlineMessageId) {
super(GetWebhookInfoResponse.class);
add("user_id", userId).add("inline_message_id", inlineMessageId);
}

}
26 changes: 26 additions & 0 deletions src/main/java/com/pengrad/telegrambot/request/SetGameScore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.pengrad.telegrambot.request;

import com.pengrad.telegrambot.response.BaseResponse;
import com.pengrad.telegrambot.response.SendResponse;

/**
* Stas Parshin
* 03 October 2016
*/
public class SetGameScore extends BaseRequest<SetGameScore, BaseResponse> {

public SetGameScore(int userId, int score, Object chatId, int messageId) {
super(SendResponse.class);
add("user_id", userId).add("score", score).add("chat_id", chatId).add("message_id", messageId);
}

public SetGameScore(int userId, int score, String inlineMessageId) {
super(SendResponse.class);
add("user_id", userId).add("score", score).add("inline_message_id", inlineMessageId);
}

public SetGameScore editMessage(boolean edit_message) {
return add("edit_message", edit_message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.pengrad.telegrambot.response;

import com.pengrad.telegrambot.model.GameHighScore;

import java.util.Arrays;

/**
* Stas Parshin
* 04 October 2016
*/
public class GetGameHighScoresResponse {

private GameHighScore[] result;

public GameHighScore[] result() {
return result;
}

@Override
public String toString() {
return "GetGameHighScoresResponse{" +
"result=" + Arrays.toString(result) +
'}';
}
}

0 comments on commit 41c3c62

Please sign in to comment.