@ApiParam(value="Distance measure unit", allowableValues = "SI, MILES_YARDS", required=true) @FormParam("distance_measure_unit") String distanceUnit,
@ApiParam(value="Weight measure unit", allowableValues = "SI, POUNDS, STONES", required=true) @FormParam("weight_measure_unit") String weightUnit,
@ApiParam(value="Temperature unit", allowableValues = "CELSIUS, FAHRENHEIT", required=true) @FormParam("temperature_unit") String temperatureUnit) {
try{
Guest guest = AuthHelper.getGuest();
GuestSettings.LengthMeasureUnit lngUnt = Enum.valueOf(
GuestSettings.LengthMeasureUnit.class, lengthUnit);
GuestSettings.DistanceMeasureUnit dstUnt = Enum.valueOf(
GuestSettings.DistanceMeasureUnit.class, distanceUnit);
GuestSettings.WeightMeasureUnit whtUnt = Enum.valueOf(
GuestSettings.WeightMeasureUnit.class, weightUnit);
GuestSettings.TemperatureUnit tempUnt = Enum.valueOf(
GuestSettings.TemperatureUnit.class, temperatureUnit);
settingsService.setLengthMeasureUnit(guest.getId(), lngUnt);
settingsService.setDistanceMeasureUnit(guest.getId(), dstUnt);
settingsService.setWeightMeasureUnit(guest.getId(), whtUnt);
settingsService.setTemperatureUnit(guest.getId(), tempUnt);
return Response.ok("settings updated!").build();
}
catch (Exception e){
return Response.serverError().entity("Failed to save settings: " + e.getMessage()).build();