Package controllers.api

Source Code of controllers.api.Profile

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);
  }
 
}
TOP

Related Classes of controllers.api.Profile

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.