package com.rjconsultores.ventaboletos.rest;

import javax.annotation.security.RolesAllowed;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.rjconsultores.ventaboletos.rest.bean.ParamsSincronizarCorrida;
import com.rjconsultores.ventaboletos.rest.service.SincronizarCorridaService;
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;

@Path("/sincronizarCorridas")
public class SincronizarCorridas {
	
	@POST
	@Consumes({ MediaType.APPLICATION_JSON })
	@RolesAllowed("EMBARCADA")
	@Produces({ MediaType.APPLICATION_JSON })
	public Response buscarCorridas(ParamsSincronizarCorrida params) throws Exception {
		SincronizarCorridaService service = (SincronizarCorridaService) AppContext.getApplicationContext().getBean("sincronizarCorridaService");

		try {
			return Response.ok(service.buscarListaCorridasPorId(params), MediaType.APPLICATION_JSON).build();
		} catch (Exception e) {
			return Response.status(Response.Status.NOT_ACCEPTABLE).entity(e.getMessage()).build();
		}
	}
}
