Skip to content
Snippets Groups Projects
Commit 2fcfeee6 authored by ivarnm's avatar ivarnm
Browse files

#10 Add putRoundScore

parent 276edc9a
No related branches found
No related tags found
1 merge request!21Resolve "Query intermediate"
...@@ -43,6 +43,14 @@ public class QueryIntermediate { ...@@ -43,6 +43,14 @@ public class QueryIntermediate {
return sendRequest(httpPost); 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 // Send a request to server and return response code and text
private static String[] sendRequest(HttpRequest request) { private static String[] sendRequest(HttpRequest request) {
final String[] response = new String[2]; final String[] response = new String[2];
...@@ -224,5 +232,16 @@ public class QueryIntermediate { ...@@ -224,5 +232,16 @@ public class QueryIntermediate {
return round; 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;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment