package es.uv.saic.feign;

import java.io.File;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import es.uv.saic.domain.EvidenciaIndicadorEnquesta;
import es.uv.saic.domain.InstanciaTascaVer;
import es.uv.saic.domain.Proces;
import es.uv.saic.domain.Tipus;
import es.uv.saic.dto.ProcesDTO;

@FeignClient(name = "saic-core-service", contextId = "procedures-controller")
public interface ProceduresClient {
    @PostMapping("/procedures")
	public HashMap<String, Object> getActiveInstances(@RequestParam(required = false) String _new,
        @RequestParam String usuari);

    @GetMapping("/procedure/{id}/{usuari}")
	    public HashMap<String, Object> getInstance(@PathVariable BigInteger id, @PathVariable String usuari);
    
    @PostMapping("/procedure/files/{id}")
	@ResponseBody 
	public HashMap<String, Object> updateInstanciaTascaEvidencia(@PathVariable BigInteger id, @RequestParam Map<String,String> params, 
        @RequestBody(required = true) List<File> evidencias, @RequestParam String usuari);
    
    @PostMapping("/procedure/{id}")
	public HashMap<String, Object> updateInstanciaTasca(@PathVariable BigInteger id, @RequestBody Map<String,String> params,
        @RequestParam(required = false) List<MultipartFile> evidencias, @RequestParam String usuari);

    @PostMapping("/procedure/save/{id}")
	@ResponseBody
	public HashMap<String, Object> saveDraft(@PathVariable BigInteger id, @RequestBody String text, 
        @RequestParam boolean manual, @RequestParam String usuari);

    @GetMapping("/procedure/drafts/{id}")
	public HashMap<String, Object> getDrafts(@PathVariable BigInteger id);

    @GetMapping("/procedure/draft/{id}")
	@ResponseBody
	public InstanciaTascaVer getDraft(@PathVariable BigInteger id, @RequestParam Timestamp dataMod);

    @PostMapping("/procedure/draft/{id}")
	@ResponseBody
	public String restoreDraft(@PathVariable BigInteger id, @RequestParam Timestamp dataMod);

     @GetMapping("/proces/getAll")
    List<ProcesDTO> getAll();

    @GetMapping("/tipus/findAll")
	public List<Tipus> findAll();

    @PostMapping("/search/years")
	public HashMap<String, Object> getYearsByCenterTitulation(
        @RequestParam(name="centers[]", required=false) List<Integer> centres,
        @RequestParam("titulations[]") List<Integer> titulacions, @RequestParam String usuari);

    @PostMapping("/search/procedures")
	public HashMap<String, Object> getProceduresByCenterTitulationYear(
        @RequestParam(name="centers[]", required=false) List<Integer> centres,
        @RequestParam("years[]") List<Integer> cursos,
        @RequestParam("titulations[]") List<Integer> titulacions,
        @RequestParam String usuari);

    @PostMapping("/find/procedure")
	public HashMap<String, Object> findProcedure(@RequestParam("procedure") String idProces, 
        @RequestParam("action") String action);

    @PostMapping("/template/form")
	public HashMap<String, Object> formTemplate(@RequestParam("id") Integer idPlantilla,
			@RequestParam("action") String action);
          
    @GetMapping("/find/proces/{idProces}")
	public Proces findProcesByID(@PathVariable Integer idProces);

    @GetMapping("/getByProcesEvidencia")
	public List<EvidenciaIndicadorEnquesta> getByProcesEvidencia(@RequestParam String nomProces, @RequestParam String evidencia);
}
