package es.uv.saic.feign;

import java.io.IOException;
import java.text.ParseException;
import java.util.List;
import java.util.Optional;

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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import es.uv.saic.domain.Calendari;

@FeignClient(value = "calendari-service", url = "${saic.url.domain}")
public interface CalendarClient {
    	@ResponseBody
	@PostMapping("/ajax/calendar")
	public Calendari calendarAddEvent(@RequestParam("idProces") Integer idProces, 
        @RequestParam("titulacions") List<String> titulacions, @RequestParam("centres") List<String> centres, 
        @RequestParam("data") String data, @RequestParam("instancia") Optional<Integer> instancia) throws IOException, ParseException;

    @ResponseBody
	@PostMapping("/ajax/calendar/{id}")
	public Calendari calendarAddEvent(@PathVariable("id") Integer id, 
        @RequestParam("idProces") Integer idProces, @RequestParam("titulacions") List<String> titulacions, 
        @RequestParam("centres") List<String> centres, @RequestParam("data") String data) throws IOException, ParseException;

    @ResponseBody
	@GetMapping("/ajax/calendar")
	public List<Calendari> calendarGetEvents() throws IOException, ParseException;

    @ResponseBody
	@DeleteMapping("/ajax/calendar")
	public Integer calendarDeleteEvent(@RequestParam("id") Integer id) throws IOException, ParseException;

    @ResponseBody
	@PostMapping("/ajax/instantiate")
    public List<String> instantiate(@RequestParam("id") Integer id,
        @RequestParam("idProces") Integer idProces, @RequestParam("centres") List<Integer> centres,
        @RequestParam("titulacions") List<Integer> titulacions, @RequestParam String usuari) throws IOException, ParseException;   
}
