package es.uv.saic.feign;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

import es.uv.saic.domain.Acreditacio;
import es.uv.saic.domain.AcreditacioTransfer;

@FeignClient(name = "saic-core-service", contextId = "admin-controller")
public interface AdminClient {
    @PostMapping("/admins/instance")
    HashMap<String, Object> instantiate(@RequestParam("procedure") Integer idProces,
			@RequestParam("center") Integer idCentre,
			@RequestParam("titulation") Integer idTitulacio);
     
    @DeleteMapping("/admins/instance")
    void deleteInstance(@RequestParam BigInteger idInstancia);
    
    @PostMapping("/admins/instance/clear")
    String clearInstance(@RequestParam BigInteger idInstancia);

    @PostMapping("/admins/instance/close")
    String closeInstance(@RequestParam BigInteger idInstancia);

    @DeleteMapping("/admins/instance/task")
    String removeTask(@RequestParam BigInteger idInstanciaTasca);

    @PostMapping("/admin/instance/task/clear")
    String clearTask(@RequestParam BigInteger idInstanciaTasca);

    @PostMapping("/admins/instance/task/reload")
    String reloadTask(@RequestParam BigInteger idInstanciaTasca);

    @PostMapping("/admins/instance/task/reactivate")
    String activateTask(@RequestParam BigInteger idInstanciaTasca);

    @PostMapping("/admins/instance/task/edit")
    String editTask(@RequestParam BigInteger idInstanciaTasca);

    @PostMapping("/admins/mailing")
    void sendMails( @RequestParam Integer idRol, @RequestParam("centres[]") List<Integer> centres,
			@RequestParam String subject, @RequestParam String body);

    @PutMapping("/admins/procedures")
    void newProcedure(@RequestParam Map<String,String> params, 
			@RequestParam(name="idTascap[]", required=false) List<String> idTascap, 
			@RequestParam(name="dataLimit[]", required=false) List<String> dataLimit, 
			@RequestParam(name="tipus[]", required=false) List<String> tipus,
			@RequestParam(name="codiEvidencia[]", required=false) List<String> codiEvidencia, 
			@RequestParam(name="idTascaSeg[]", required=false) List<String> idTascaSeg, 
			@RequestParam(name="idTascaSeg2[]", required=false) List<String> idTascaSeg2,
			@RequestParam(name="opcions[]", required=false) List<String> opcions,
			@RequestParam(name="idRol[]", required=false) List<String> idRol, 
			@RequestParam(name="titolCas[]", required=false) List<String> titolCas, 
			@RequestParam(name="titolVal[]", required=false) List<String> titolVal,
			@RequestParam(name="descripcioCas[]", required=false) List<String> descripcioCas, 
			@RequestParam(name="descripcioVal[]", required=false) List<String> descripcioVal,
			@RequestParam(name="nomEvidenciaCas[]", required=false) List<String> nomEvidenciaCas, 
			@RequestParam(name="nomEvidenciaVal[]", required=false) List<String> nomEvidenciaVal,
			@RequestParam(name="idPlantilla[]", required=false) List<String> idPlantilla,
			@RequestParam(name="informe[]", required=false) List<Boolean> informe);
    
    @PostMapping("/admins/procedures")
    void editProcedure(@RequestParam Map<String,String> params, 
			@RequestParam(name="idTascap[]", required=false) List<String> idTascap, 
			@RequestParam(name="dataLimit[]", required=false) List<String> dataLimit, 
			@RequestParam(name="tipus[]", required=false) List<String> tipus,
			@RequestParam(name="codiEvidencia[]", required=false) List<String> codiEvidencia, 
			@RequestParam(name="idTascaSeg[]", required=false) List<String> idTascaSeg, 
			@RequestParam(name="idTascaSeg2[]", required=false) List<String> idTascaSeg2,
			@RequestParam(name="opcions[]", required=false) List<String> opcions,
			@RequestParam(name="idRol[]", required=false) List<String> idRol, 
			@RequestParam(name="titolCas[]", required=false) List<String> titolCas, 
			@RequestParam(name="titolVal[]", required=false) List<String> titolVal,
			@RequestParam(name="descripcioCas[]", required=false) List<String> descripcioCas, 
			@RequestParam(name="descripcioVal[]", required=false) List<String> descripcioVal,
			@RequestParam(name="nomEvidenciaCas[]", required=false) List<String> nomEvidenciaCas, 
			@RequestParam(name="nomEvidenciaVal[]", required=false) List<String> nomEvidenciaVal,
			@RequestParam(name="idPlantilla[]", required=false) List<String> idPlantilla,
			@RequestParam(name="informe[]", required=false) List<Boolean> informe);

    @DeleteMapping("/admins/procedures")
    void removeProcedure(@RequestParam("idProces") Integer idProces);    
    
    @DeleteMapping("/admins/userrole")
    HashMap<String, Object> removeUserrole(@RequestParam("idRol") Integer idRol, @RequestParam("usuari") String usuari, 
		@RequestParam("lugar") Integer lugar, @RequestParam("tlugar") String tlugar);
    
    @PutMapping("/admins/userrole")
	HashMap<String, Object> newUserrole(@RequestParam("idRol") Integer idRol, @RequestParam(name="usuari", required=false) String usuari, @RequestParam("centre") Integer idCentre, 
			@RequestParam(name="titulacio", required=false) Integer idTitulacio, @RequestParam Map<String,String> params);
	
	@GetMapping("/admins/templates")
	List<String> getTemplates2();

	@PostMapping("/admins/templates/inds/update")
	void updateTemplateInds(@RequestParam(name="indicador[]", required=true) List<String> indicador,
			@RequestParam(name="enquesta[]", required=true) List<String> enquesta,
			@RequestParam(name="media[]", required=true) List<String> media,
			@RequestParam(name="evidencia", required=true) String evidencia,
			@RequestParam(name="proces", required=true) String proces
			);
	
	@GetMapping("/admins/acredita/{curs}/{grup}/{tambit}")  
	List<AcreditacioTransfer> acreditacionsByCurs(@PathVariable Integer curs, @PathVariable Integer grup, @PathVariable String tambit);

	@PostMapping("/admins/acredita") 
	Acreditacio UpdateAcreditacio(@RequestParam String tlugar, @RequestParam Integer lugar, 
									@RequestParam Integer grupCurs, @RequestParam Integer grupNum, @RequestParam Integer cursImpla,
									@RequestParam String dataAcred, @RequestParam String dataRenov, @RequestParam String dataSegui,
									@RequestParam String dataVerif, @RequestParam Boolean recom, @RequestParam Boolean segui);			
}
