String startTime = request.getParameter("startTime");
String duration = request.getParameter("duration");
log.info("Log sleep :: date = " + logDate + ", startTime = " + startTime + ", duration = " + duration);
List<String> messages = new ArrayList<String>();
SleepLog sleepLog;
try {
sleepLog = context.getApiClientService().getClient().logSleep(
context.getOurUser(),
FitbitApiService.getValidLocalDateOrNull(logDate),
FitbitApiService.getValidTimeOrNull(startTime),
Long.valueOf(duration)
);
String message = "Log sleep added. logId = " + sleepLog.getLogId() + ".";
messages.add(message);
log.info(message);
} catch (FitbitAPIException e) {
populateMessages(messages, e);
log.error("Error during log sleep.", e);