{"action":"created","comment":{"url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/comments/27136079","id":27136079,"diff_hunk":"@@ -0,0 +1,80 @@\n+package controllers\r\n+\r\n+import javax.inject._\r\n+import controllers.requests.user.{GetUserResponse, UpdateUserRequest}\r\n+import org.slf4j._\r\n+import play.api.libs.json.Json\r\n+import play.api.mvc._\r\n+import play.api.libs.concurrent.Execution.Implicits._\r\n+import play.modules.reactivemongo.MongoController\r\n+\r\n+import scala.concurrent.Future\r\n+\r\n+import business.repositories._\r\n+import business.services._\r\n+import business.models._\r\n+\r\n+import requests._\r\n+import requests.JsonFormats._\r\n+import requests.Mappings._\r\n+\r\n+\r\n+/**\r\n+ * Created by liviuignat on 21/03/15.\r\n+ */\r\n+\r\n+@Singleton\r\n+class UsersController @Inject() (encriptionService: IStringEncriptionService, userRepository: IUserRepository)  extends Controller with MongoController {\r\n+  private final val logger: Logger = LoggerFactory.getLogger(classOf[UsersController])\r\n+\r\n+  def getUserById(id: String) = Action.async {\r\n+    userRepository.getById(id).map {\r\n+      case Some(user) => {\r\n+        val response: GetUserResponse = user\r\n+        val responseJson = Json.toJson(response)\r\n+        Ok(responseJson)\r\n+      }\r\n+      case None => NotFound(Json.obj(\"message\" -> \"No such item\"))\r\n+    }\r\n+  }\r\n+\r\n+  def getUserSearch() = Action.async(parse.anyContent) {\r\n+    req => {\r\n+      val query = req.getQueryString(\"q\");\r\n+\r\n+      userRepository.getAll(query).map({\r\n+        users => {\r\n+          val response: List[GetUserResponse] = users.map(user => {\r\n+            val userResponse: GetUserResponse = user\r\n+            userResponse\r\n+          })\r\n+          Ok(Json.toJson(response))\r\n+        }\r\n+      })\r\n+    }\r\n+  }\r\n+\r\n+  def updateUserById(id: String) = Action.async(parse.json) { req =>\r\n+    Json.fromJson[UpdateUserRequest](req.body).fold(\r\n+      invalid => {\r\n+        Future.successful(BadRequest(Json.obj(\"message\" -> \"Invalid json\")))\r\n+      },\r\n+      updateUserRequest => {\r\n+        updateUserRequest.id = Some(id)\r\n+        val user: User = updateUserRequest\r\n+\r\n+        userRepository.update(user).map({\r\n+          case lastError if lastError.ok() => Ok(\"\")\r\n+          case lastError if !lastError.ok() => InternalServerError(Json.obj(\"message\" -> \"Internal server error\"))\r\n+        })\r\n+      }\r\n+    )\r\n+  }\r\n+\r\n+  def deleteUserById(id: String) = Action.async {\r\n+      userRepository.delete(id).map({\r","path":"app/controllers/UsersController.scala","position":75,"original_position":75,"commit_id":"2e7abd90d32e9e18dfc41e37a9ee00c48fa60545","original_commit_id":"2e7abd90d32e9e18dfc41e37a9ee00c48fa60545","user":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"body":"idem :)","created_at":"2015-03-25T16:09:06Z","updated_at":"2015-03-25T16:09:06Z","html_url":"https://github.com/liviuignat/PlayAndScala/pull/1#discussion_r27136079","pull_request_url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/comments/27136079"},"html":{"href":"https://github.com/liviuignat/PlayAndScala/pull/1#discussion_r27136079"},"pull_request":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1","id":31775349,"html_url":"https://github.com/liviuignat/PlayAndScala/pull/1","diff_url":"https://github.com/liviuignat/PlayAndScala/pull/1.diff","patch_url":"https://github.com/liviuignat/PlayAndScala/pull/1.patch","issue_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/1","number":1,"state":"open","locked":false,"title":"Feature/mongo","user":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"body":"Build history: https://travis-ci.org/liviuignat/PlayAndScala/builds\r\nConnectivity to mongo with features:\r\n- create user - repository + controller\r\n- find user by id - repository + controller\r\n- add BDD integration tests based on FunSpec - Jasmine like\r\n- refactor some components","created_at":"2015-03-23T21:21:51Z","updated_at":"2015-03-25T16:09:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d271ba41565dd05ff3f1e2a81d467ebb5bc9ec67","assignee":{"login":"tudorraul","id":1492162,"avatar_url":"https://avatars.githubusercontent.com/u/1492162?v=3","gravatar_id":"","url":"https://api.github.com/users/tudorraul","html_url":"https://github.com/tudorraul","followers_url":"https://api.github.com/users/tudorraul/followers","following_url":"https://api.github.com/users/tudorraul/following{/other_user}","gists_url":"https://api.github.com/users/tudorraul/gists{/gist_id}","starred_url":"https://api.github.com/users/tudorraul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tudorraul/subscriptions","organizations_url":"https://api.github.com/users/tudorraul/orgs","repos_url":"https://api.github.com/users/tudorraul/repos","events_url":"https://api.github.com/users/tudorraul/events{/privacy}","received_events_url":"https://api.github.com/users/tudorraul/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/liviuignat/PlayAndScala/milestones/1","html_url":"https://github.com/liviuignat/PlayAndScala/milestones/CRUD%20for%20uesr%20auth%20using%20MongoDB","labels_url":"https://api.github.com/repos/liviuignat/PlayAndScala/milestones/1/labels","id":1035200,"number":1,"title":"CRUD for uesr auth using MongoDB","description":null,"creator":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2015-03-23T21:30:20Z","updated_at":"2015-03-23T21:30:20Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1/commits","review_comments_url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1/comments","review_comment_url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/1/comments","statuses_url":"https://api.github.com/repos/liviuignat/PlayAndScala/statuses/2e7abd90d32e9e18dfc41e37a9ee00c48fa60545","head":{"label":"liviuignat:feature/mongo","ref":"feature/mongo","sha":"2e7abd90d32e9e18dfc41e37a9ee00c48fa60545","user":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"repo":{"id":31987946,"name":"PlayAndScala","full_name":"liviuignat/PlayAndScala","owner":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liviuignat/PlayAndScala","description":"Play framework prototype and Scala ","fork":false,"url":"https://api.github.com/repos/liviuignat/PlayAndScala","forks_url":"https://api.github.com/repos/liviuignat/PlayAndScala/forks","keys_url":"https://api.github.com/repos/liviuignat/PlayAndScala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liviuignat/PlayAndScala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liviuignat/PlayAndScala/teams","hooks_url":"https://api.github.com/repos/liviuignat/PlayAndScala/hooks","issue_events_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/events{/number}","events_url":"https://api.github.com/repos/liviuignat/PlayAndScala/events","assignees_url":"https://api.github.com/repos/liviuignat/PlayAndScala/assignees{/user}","branches_url":"https://api.github.com/repos/liviuignat/PlayAndScala/branches{/branch}","tags_url":"https://api.github.com/repos/liviuignat/PlayAndScala/tags","blobs_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/refs{/sha}","trees_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liviuignat/PlayAndScala/statuses/{sha}","languages_url":"https://api.github.com/repos/liviuignat/PlayAndScala/languages","stargazers_url":"https://api.github.com/repos/liviuignat/PlayAndScala/stargazers","contributors_url":"https://api.github.com/repos/liviuignat/PlayAndScala/contributors","subscribers_url":"https://api.github.com/repos/liviuignat/PlayAndScala/subscribers","subscription_url":"https://api.github.com/repos/liviuignat/PlayAndScala/subscription","commits_url":"https://api.github.com/repos/liviuignat/PlayAndScala/commits{/sha}","git_commits_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/commits{/sha}","comments_url":"https://api.github.com/repos/liviuignat/PlayAndScala/comments{/number}","issue_comment_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/comments{/number}","contents_url":"https://api.github.com/repos/liviuignat/PlayAndScala/contents/{+path}","compare_url":"https://api.github.com/repos/liviuignat/PlayAndScala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liviuignat/PlayAndScala/merges","archive_url":"https://api.github.com/repos/liviuignat/PlayAndScala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liviuignat/PlayAndScala/downloads","issues_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues{/number}","pulls_url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls{/number}","milestones_url":"https://api.github.com/repos/liviuignat/PlayAndScala/milestones{/number}","notifications_url":"https://api.github.com/repos/liviuignat/PlayAndScala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liviuignat/PlayAndScala/labels{/name}","releases_url":"https://api.github.com/repos/liviuignat/PlayAndScala/releases{/id}","created_at":"2015-03-10T23:42:45Z","updated_at":"2015-03-23T21:33:48Z","pushed_at":"2015-03-25T14:41:45Z","git_url":"git://github.com/liviuignat/PlayAndScala.git","ssh_url":"git@github.com:liviuignat/PlayAndScala.git","clone_url":"https://github.com/liviuignat/PlayAndScala.git","svn_url":"https://github.com/liviuignat/PlayAndScala","homepage":null,"size":2788,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"liviuignat:develop","ref":"develop","sha":"9f1ca6a7ebc03a65411531ca85f706d4abb4d06e","user":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"repo":{"id":31987946,"name":"PlayAndScala","full_name":"liviuignat/PlayAndScala","owner":{"login":"liviuignat","id":2430288,"avatar_url":"https://avatars.githubusercontent.com/u/2430288?v=3","gravatar_id":"","url":"https://api.github.com/users/liviuignat","html_url":"https://github.com/liviuignat","followers_url":"https://api.github.com/users/liviuignat/followers","following_url":"https://api.github.com/users/liviuignat/following{/other_user}","gists_url":"https://api.github.com/users/liviuignat/gists{/gist_id}","starred_url":"https://api.github.com/users/liviuignat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liviuignat/subscriptions","organizations_url":"https://api.github.com/users/liviuignat/orgs","repos_url":"https://api.github.com/users/liviuignat/repos","events_url":"https://api.github.com/users/liviuignat/events{/privacy}","received_events_url":"https://api.github.com/users/liviuignat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liviuignat/PlayAndScala","description":"Play framework prototype and Scala ","fork":false,"url":"https://api.github.com/repos/liviuignat/PlayAndScala","forks_url":"https://api.github.com/repos/liviuignat/PlayAndScala/forks","keys_url":"https://api.github.com/repos/liviuignat/PlayAndScala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liviuignat/PlayAndScala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liviuignat/PlayAndScala/teams","hooks_url":"https://api.github.com/repos/liviuignat/PlayAndScala/hooks","issue_events_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/events{/number}","events_url":"https://api.github.com/repos/liviuignat/PlayAndScala/events","assignees_url":"https://api.github.com/repos/liviuignat/PlayAndScala/assignees{/user}","branches_url":"https://api.github.com/repos/liviuignat/PlayAndScala/branches{/branch}","tags_url":"https://api.github.com/repos/liviuignat/PlayAndScala/tags","blobs_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/refs{/sha}","trees_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liviuignat/PlayAndScala/statuses/{sha}","languages_url":"https://api.github.com/repos/liviuignat/PlayAndScala/languages","stargazers_url":"https://api.github.com/repos/liviuignat/PlayAndScala/stargazers","contributors_url":"https://api.github.com/repos/liviuignat/PlayAndScala/contributors","subscribers_url":"https://api.github.com/repos/liviuignat/PlayAndScala/subscribers","subscription_url":"https://api.github.com/repos/liviuignat/PlayAndScala/subscription","commits_url":"https://api.github.com/repos/liviuignat/PlayAndScala/commits{/sha}","git_commits_url":"https://api.github.com/repos/liviuignat/PlayAndScala/git/commits{/sha}","comments_url":"https://api.github.com/repos/liviuignat/PlayAndScala/comments{/number}","issue_comment_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/comments{/number}","contents_url":"https://api.github.com/repos/liviuignat/PlayAndScala/contents/{+path}","compare_url":"https://api.github.com/repos/liviuignat/PlayAndScala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liviuignat/PlayAndScala/merges","archive_url":"https://api.github.com/repos/liviuignat/PlayAndScala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liviuignat/PlayAndScala/downloads","issues_url":"https://api.github.com/repos/liviuignat/PlayAndScala/issues{/number}","pulls_url":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls{/number}","milestones_url":"https://api.github.com/repos/liviuignat/PlayAndScala/milestones{/number}","notifications_url":"https://api.github.com/repos/liviuignat/PlayAndScala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liviuignat/PlayAndScala/labels{/name}","releases_url":"https://api.github.com/repos/liviuignat/PlayAndScala/releases{/id}","created_at":"2015-03-10T23:42:45Z","updated_at":"2015-03-23T21:33:48Z","pushed_at":"2015-03-25T14:41:45Z","git_url":"git://github.com/liviuignat/PlayAndScala.git","ssh_url":"git@github.com:liviuignat/PlayAndScala.git","clone_url":"https://github.com/liviuignat/PlayAndScala.git","svn_url":"https://github.com/liviuignat/PlayAndScala","homepage":null,"size":2788,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1"},"html":{"href":"https://github.com/liviuignat/PlayAndScala/pull/1"},"issue":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/1"},"comments":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/liviuignat/PlayAndScala/statuses/2e7abd90d32e9e18dfc41e37a9ee00c48fa60545"}}}}