@@ -0,0 +1,2074 @@
+package REST.readingEndpoint;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.json.JSONObject;%0A%0Aimport com.mashape.unirest.http.HttpResponse;%0Aimport com.mashape.unirest.http.JsonNode;%0A%0Aimport strategy.RESTStrategy;%0A%0Apublic class Update extends RESTStrategy%7B%0A%09%0A%09private String readingGroupId;%0A%09private String readingId;%0A%0A%09@Override%0A%09public void beforeExperiment() throws Exception %7B%0A%09%09HashMap%3CString, HashMap%3CString, String%3E%3E parameters = new HashMap%3CString, HashMap%3CString, String%3E%3E();%0A%09%09HashMap%3CString, String%3E readingGroup = new HashMap%3CString, String%3E();%0A%09%09readingGroup.put(%22name%22, %22ReadingGroup%22);%0A%09%09parameters.put(%22reading_group%22, readingGroup);%0A%09%09JSONObject jsonBody = new JSONObject(parameters);%0A%09%09HttpResponse%3CJsonNode%3E response = post(buildUrl(READING_GROUP_PATH), jsonBody);%0A%09%09readingGroupId = ((JSONObject) (response.getBody().getObject().get(%22reading_group%22))).get(%22id%22).toString();%0A%09%09%0A%09%09parameters = new HashMap%3CString, HashMap%3CString, String%3E%3E();%0A%09%09HashMap%3CString, String%3E reading = new HashMap%3CString, String%3E();%0A%09%09reading.put(%22label%22, %22label%22);%0A%09%09reading.put(%22color%22, %22FF0000%22);%0A%09%09reading.put(%22grade%22, %220.0%22);%0A%09%09reading.put(%22reading_group_id%22, readingGroupId.toString());%0A%09%09parameters.put(%22reading%22, reading);%0A%09%09jsonBody = new JSONObject(parameters);%0A%09%09response = post(buildUrl(READING_GROUP_PATH + %22/%22 + readingGroupId + %22/readings%22), jsonBody);%0A%09%09%0A%09%09readingId = ((JSONObject) (response.getBody().getObject().get(%22reading%22))).get(%22id%22).toString();%0A%09%7D%0A%0A%09@Override%0A%09public String request(String string) throws Exception %7B%0A%09%09HashMap%3CString, String%3E parameters = new HashMap%3CString, String%3E();%0A%09%09parameters.put(%22grade%22, %221.0%22);%0A%09%09JSONObject jsonBody = new JSONObject(parameters);%0A%09%09put(buildUrl(READING_GROUP_PATH + %22/%22 + readingGroupId + %22/readings/%22 + readingId), jsonBody);%0A%09%09return readingId;%0A%09%7D%0A%09%0A%09@Override%0A%09public void afterExperiment() throws Exception %7B%0A%09%09delete(buildUrl(READING_GROUP_PATH + %22/%22 + readingGroupId));%0A%09%7D%0A%0A%09@Override%0A%09public void configure(Map%3CObject, Object%3E options) %7B%0A%09%09configure(options, %22kalibro_configuration%22);%0A%09%7D%0A%0A%7D%0A

Add Reading#update experiment