Skip to content
Snippets Groups Projects
Commit 754d824c authored by Felipe D'Abrantes's avatar Felipe D'Abrantes
Browse files

Implement relevant API calls to User functionality

parent 21408745
No related branches found
No related tags found
1 merge request!14Add endpoints to manage Dailies
package models
import models.HttpCall
import play.api.libs.json.JsValue
import org.bson.types.ObjectId
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
object User {
def getUserFriends(userId: ObjectId): Future[Seq[ObjectId]] = {
// TODO: Fetch user friends from Friend Service
println("Fetching friends for", userId.toString())
val friends: Seq[ObjectId] = Seq(new ObjectId("641128f7e80bcd1ba39d04af"))
Future.successful(friends)
println(s"Fetching friends for user with ID {$userId}")
HttpCall.get("http://localhost:9000/test/getFriends").map[Seq[ObjectId]]((json: JsValue) => {
val sequence: Seq[String] = json.as[Seq[String]]
sequence.map[ObjectId](new ObjectId(_))
})
}
def userExists(userId: ObjectId): Future[Boolean] = {
// TODO: Fetch user verification from User Service
println("Verifying user with ID ", userId.toString(), " exists")
val exists: Boolean = true
Future.successful(exists)
println(s"Verifying user with ID {$userId} exists")
HttpCall.get("http://localhost:9000/test/verifyUser").map[Boolean](_.as[Boolean])
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment