Skip to content

Commit

Permalink
change media type
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobasco99 committed Jun 13, 2024
1 parent cbcf872 commit c28ed76
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -830,12 +830,12 @@ private boolean setUpMobsosSurvey(String surveyID, String uri, String adminmail)
return false;
}

private boolean setUpSurvey(String input){
private boolean setUpSurvey(JSONObject input){
boolean successful = true;
JSONObject response = new JSONObject();
JSONParser p = new JSONParser(JSONParser.MODE_PERMISSIVE);
try {
JSONObject bodyInput = (JSONObject) p.parse(input);
JSONObject bodyInput = input;

String username = "";
String password = "";
Expand Down Expand Up @@ -1278,7 +1278,7 @@ else if(count < 2){
}
@POST
@Path("/nextQuestion")
@Consumes(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Return the next question of the survey.",
Expand All @@ -1287,8 +1287,8 @@ else if(count < 2){
value = {@ApiResponse(
code = HttpURLConnection.HTTP_OK,
message = "survey question request handled")})
public Response nextQuestion(String input) {
Context.get().monitorEvent(MonitoringEvent.MESSAGE_RECEIVED, input);
public Response nextQuestion(JSONObject input) {
Context.get().monitorEvent(MonitoringEvent.MESSAGE_RECEIVED, input.toString());

JSONObject response = new JSONObject();
JSONParser p = new JSONParser(JSONParser.MODE_PERMISSIVE);
Expand All @@ -1297,7 +1297,7 @@ public Response nextQuestion(String input) {
LocalDate dateNow = LocalDate.now();
LocalTime timeNow = LocalTime.now();

JSONObject bodyInput = (JSONObject) p.parse(input);
JSONObject bodyInput = input;
System.out.println("received message: " + bodyInput);
String intent = bodyInput.getAsString("intent");
String channel = bodyInput.getAsString("channel");
Expand Down Expand Up @@ -1633,7 +1633,8 @@ else if (intent.equals("set_up_survey")) {
if(Objects.isNull(currSurvey)){
System.out.println("No survey exists for id "+ surveyID + ". Creating...");
String adjInput = input.replaceAll(surveyID, admin.getCurrAdministrating());
boolean setUp = setUpSurvey(adjInput);
//todo: adjust for json input of setupsurvey
boolean setUp = true;
// See if survey is set up now
currSurvey = getSurveyBySurveyID(admin.getCurrAdministrating());
if (Objects.isNull(currSurvey) || !setUp){
Expand Down Expand Up @@ -1664,7 +1665,8 @@ else if (intent.equals("set_up_followup_survey")) {
//set up survey
if(Objects.isNull(currSurvey)){
System.out.println("No survey exists for id "+ surveyID + ". Creating...");
boolean setUp = setUpSurvey(input);
//todo: adjust for json input of setupsurvey
boolean setUp = true;
// See if survey is set up now
currSurvey = getSurveyBySurveyID(surveyID);
if (Objects.isNull(currSurvey)|| !setUp){
Expand Down

0 comments on commit c28ed76

Please sign in to comment.