package es.uv.saic.feign;

import java.io.IOException;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import es.uv.saic.domain.InstanciaTascaVer;

@FeignClient(value = "procedures-controller", url = "${saic.url.domain}")
public interface ProceduresClient {
    @PostMapping("/procedures")
	public HashMap<String, Object> getActiveInstances(@RequestParam(required = false) String _new,
        @RequestParam String usuari);

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

    @PostMapping("/procedure/save/{id}")
	@ResponseBody
	public HashMap<String, Object> saveDraft(@RequestParam String location, @PathVariable BigInteger id, @RequestParam 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);
}
