diff --git a/frontend/core/src/com/gameware/game/QueryIntermediate.java b/frontend/core/src/com/gameware/game/QueryIntermediate.java index 79d2c077db31ad60244b57c0e40fe0d6f928ce49..154fdc3a3d41f36167b43fe9e2312d6f4e461103 100644 --- a/frontend/core/src/com/gameware/game/QueryIntermediate.java +++ b/frontend/core/src/com/gameware/game/QueryIntermediate.java @@ -43,6 +43,14 @@ public class QueryIntermediate { return sendRequest(httpPost); } + private static String[] sendPutRequest(String route, Map<String, String> params) { + HttpRequest httpPut = new HttpRequest(HttpMethods.PUT); + httpPut.setUrl(baseUrl + route); + httpPut.setHeader("Content-Type", "application/x-www-form-urlencoded"); + httpPut.setContent(HttpParametersUtils.convertHttpParameters(params)); + return sendRequest(httpPut); + } + // Send a request to server and return response code and text private static String[] sendRequest(HttpRequest request) { final String[] response = new String[2]; @@ -224,5 +232,16 @@ public class QueryIntermediate { return round; } + public static Round putRoundScore(String roundId, int score) throws IOException, NoSuchElementException { + String route = "rounds/" + roundId; + Map<String, String> params = new HashMap<>(); + params.put("scoreValue", Integer.toString(score)); + String[] response = sendPutRequest(route, params); + checkStatusCode(response); + Round round = json.fromJson(Round.class, response[1]); + checkObjectNotNull(round); + return round; + } + }