package ru.micord.ervu.audit.controller;


import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ru.micord.ervu.audit.model.AuditActionRequest;
import ru.micord.ervu.audit.service.AuditService;


/**
 * @author Adel Kalimullin
 */
@RestController
@RequestMapping("/audit")
public class AuditController {
  private final AuditService auditService;

  public AuditController(AuditService auditService) {
    this.auditService = auditService;
  }

  @RequestMapping(value = "/action", method = RequestMethod.POST)
  public ResponseEntity<Void> auditAction(
      HttpServletRequest request, @RequestBody AuditActionRequest actionEvent) {
    auditService.processActionEvent(request, actionEvent);
    return ResponseEntity.ok().build();
  }
}
