package be.ac.ulb.code.wit.resources;

import java.io.Reader;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import org.apache.abdera.util.Constants;

import be.ac.ulb.code.wit.contacts.Contacts;

@Path(ServicePaths.CONTACT)
public class Contact {
	private GroupContact groupHandler = new GroupContact();

	@GET
	@Produces(Constants.ENTRY_MEDIA_TYPE)
	public Response getContact(@PathParam("contactid") final String contactId) {
		return groupHandler.getContact(contactId, Contacts.GROUP_ALLCONTACTS);
	}

	@PUT
    @Produces(Constants.ENTRY_MEDIA_TYPE)
    @Consumes(Constants.ENTRY_MEDIA_TYPE)
    public Response updateContact(@PathParam("contactid") final String contactId, final Reader data) {
		return groupHandler.updateContact(contactId, Contacts.GROUP_ALLCONTACTS, data);
	}

	@DELETE
    public Response deleteContact(@PathParam("contactid") final String contactId) {
		return groupHandler.deleteContact(contactId, Contacts.GROUP_ALLCONTACTS);
	}
}
