package controllers.api;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.HashMap;
import play.mvc.Router;
import play.mvc.Http.StatusCode;
import models.Message;
import models.User;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import controllers.Data;
public class Profile extends MeApi {
public static void get() {
User current = getCurrentUser();
renderTemplate("api/user.json", current);
//renderJSON(gson().toJson(current, User.class));
}
public static void save(JsonObject body) {
User user = gson().fromJson(body, User.class);
user.update();
response.status = StatusCode.OK;
String url = Router.reverse("api.Profile.get").url;
response.setHeader("location", url);
}
public static void publicProfile(Long id) {
User user = User.findById(id);
if(user==null) notFound();
renderTemplate("api/publicUser.json", user);
}
}