Skip to content
Snippets Groups Projects
Commit 0540a341 authored by ivarnm's avatar ivarnm
Browse files

#10 Add getPlayerById

parent 2fcfeee6
No related branches found
No related tags found
1 merge request!21Resolve "Query intermediate"
......@@ -11,6 +11,7 @@ import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import com.gameware.game.models.Game;
import com.gameware.game.models.Highscore;
import com.gameware.game.models.Player;
import com.gameware.game.models.Round;
import com.gameware.game.models.Tournament;
......@@ -244,4 +245,14 @@ public class QueryIntermediate {
}
// ---------------- Player methods ----------------
public static Player getPlayerById(String playerId) throws IOException, NoSuchElementException {
String route = "players/username/" + playerId;
String[] response = sendGetRequest(route);
checkStatusCode(response);
Player player = json.fromJson(Player.class, response[1].substring(1, response[1].length()-1));
checkObjectNotNull(player);
return player;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment