package gr.sperfect.djuqbox.webapp.client;

import gr.sperfect.djuqbox.webapp.shared.data.Room;
import gr.sperfect.djuqbox.webapp.shared.data.User;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import org.fusesource.restygwt.client.Attribute;
import org.fusesource.restygwt.client.MethodCallback;
import org.fusesource.restygwt.client.RestService;

public interface RestApiService extends RestService {


	//http://resty-gwt.github.io/documentation/restygwt-user-guide.html
	
	@GET
	@Path("rooms")  // prepei na einai javax.ws.rs.Path !!!!!
	public void getRooms( MethodCallback<List<Room>> callback);
	
	@GET
	@Path("rooms/{id}")  // prepei na einai javax.ws.rs.Path !!!!!
	public void getRoom(@PathParam("id") String aRoomId,  MethodCallback<Room> callback);
	
	
	@POST
	@Path("rooms")  
	public void createRoom(Room r, MethodCallback<Room> callback);
	
	@PUT
	@Path("rooms")  
	public void updateRoom(Room r, MethodCallback<Room> callback);
	
	
		
	@GET
	@Path("rooms/{id}/users")  
	public void getRoomUsers(@PathParam("id") @Attribute("id") Room r, MethodCallback<List<User>> callback );
	
	
	
	//paizei!!
	@POST
	@Path("rooms/{id}/users")  
	public void addUserToRoom(@PathParam("id") String aRoomId, User r, MethodCallback<Void> callback );
	
	
	
//	@PUT
//	@Path("room/users") 
//	public void createRoom(Room r, User u,  MethodCallback<Room> callback);
	//den ginetai Methods can optionally declare one method argument before the callback to pass via the request body
	
//	@PUT
//	@Path("room/users") 
//	public void addUserToRoom(RoomUser ru,  MethodCallback<Room> callback);

	
	@GET
	@Path("users")  // prepei na einai javax.ws.rs.Path !!!!!
	public void getUsers( MethodCallback<List<User>> callback);
	
	
	@GET
	@Path("users/{id}")  // prepei na einai javax.ws.rs.Path !!!!!
	public void getUser(@PathParam("id") String aUserId,  MethodCallback<User> callback);
	
}


@@ -169,24 +169,52 @@
 il.List;%0D%0A%0D%0A
+import javax.ws.rs.DELETE;%0D%0A
 import javax
@@ -1032,32 +1032,37 @@
 T%0D%0A%09@Path(%22rooms
+/%7Bid%7D
 %22)  %0D%0A%09public vo
@@ -1067,32 +1067,66 @@
 void updateRoom(
+@PathParam(%22id%22) @Attribute(%22id%22) 
 Room r, MethodCa
@@ -1149,24 +1149,158 @@
 lback);%0D%0A%09%0D%0A
+%09@DELETE%0D%0A%09@Path(%22rooms/%7Bid%7D%22)  %0D%0A%09public void deleteRoom(@PathParam(%22id%22) @Attribute(%22id%22) Room r, MethodCallback%3CVoid%3E callback );%0D%0A
 %09%0D%0A%09%09%0D%0A%09@GET
@@ -1606,24 +1606,30 @@
 ;%0D%0A%09%0D%0A%09%0D%0A%09%0D%0A
+%09%0D%0A%09%0D%0A
 //%09@PUT%0D%0A//%09

delete room