package org.micord.controller;

import java.io.FileNotFoundException;
import java.util.List;

import org.micord.service.ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * REST Controller for API operations.
 */
@RestController
@RequestMapping("/api")
public class ApiController {

  @Autowired
  private ApiService apiService;

  @PostMapping("/block")
  public ResponseEntity<?> block(@RequestBody List<String> ids) throws FileNotFoundException {
    apiService.process("block", ids);
    return ResponseEntity.ok("");
  }

  @PostMapping("/unblock")
  public ResponseEntity<?> unblock(@RequestBody List<String> ids) throws FileNotFoundException {

    apiService.process("unblock", ids);
    return ResponseEntity.ok("");
  }

  @PostMapping("/removeFromSystem")
  public ResponseEntity<?> removeFromSystem(@RequestBody List<String> ids)
      throws FileNotFoundException {

    apiService.process("removeFromSystem", ids);
    return ResponseEntity.ok("");
  }

  @PostMapping("/removeFromCallList")
  public ResponseEntity<?> removeFromCallList(@RequestBody List<String> ids)
      throws FileNotFoundException {
    apiService.process("removeFromCallList", ids);
    return ResponseEntity.ok("");
  }
}
