package cactusServer.resources;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import cactusServer.entities.*;
import cactusServer.models.Accounts;
@Path("/accounts")
public class AccountsRest {
private HttpServletResponse response;
@PUT
@Produces(MediaType.APPLICATION_JSON)
public Session loginAccount(@FormParam("userID") String userID, @FormParam("userPass") String userPass) {
return Accounts.getInstance().loginAccount(userID, userPass);
}
@POST
@Path("/logout")
@Produces(MediaType.TEXT_PLAIN)
public String logoutAccount(@FormParam("token") String token) {
return Accounts.getInstance().logoutAccount(token);
}
@POST
@Produces(MediaType.APPLICATION_JSON)
public Session createAccount(@FormParam("userID") String userID, @FormParam("userName") String userName,
@FormParam("userPass") String userPass) {
return Accounts.getInstance().createAcount(userID, userName, userPass);
}
@GET
@Path("/{uniqueID}")
@Produces(MediaType.APPLICATION_JSON)
public Account getAccount(@PathParam("uniqueID") String uniqueID) {
return Accounts.getInstance().getAccountByuniqueID(uniqueID);
}
}