{"action":"created","comment":{"url":"https://api.github.com/repos/finagle/finch/pulls/comments/35047847","id":35047847,"diff_hunk":"@@ -0,0 +1,206 @@\n+package io.finch.petstore\n+\n+import com.twitter.finagle.Service\n+import com.twitter.finagle.httpx.{Request, Response}\n+import com.twitter.util.{Future}\n+import io.finch.argonaut._\n+import io.finch.request._\n+import io.finch.response._\n+import io.finch.route._\n+\n+/**\n+ * Provides the paths and endpoints for all the API's public service methods.\n+ */\n+object endpoint extends ErrorHandling {\n+\n+  /**\n+   * Private method that compiles all pet service endpoints.\n+   * @return Bundled compilation of all pet service endpoints.\n+   */\n+  private def pets(db: PetstoreDb) =\n+    getPet(db) :+:\n+    addPet(db) :+:\n+    updatePet(db) :+:\n+    getPetsByStatus(db) :+:\n+    findPetsByTag(db) :+:\n+    deletePet(db) :+:\n+    updatePetViaForm(db) :+:\n+    uploadImage(db)\n+\n+  /**\n+   * Private method that compiles all store service endpoints.\n+   * @return Bundled compilation of all store service endpoints.\n+   */\n+  private def store(db: PetstoreDb) =\n+    getInventory(db) :+:\n+    addOrder(db) :+:\n+    deleteOrder(db) :+:\n+    findOrder(db)\n+\n+  /**\n+   * Private method that compiles all user service endpoints.\n+   * @return Bundled compilation of all user service endpoints.\n+   */\n+  private def users(db: PetstoreDb) =\n+    addUser(db) :+:\n+    addUsersViaList(db) :+:\n+    addUsersViaArray(db) :+:\n+    getUser(db) :+:\n+    deleteUser(db) :+:\n+    updateUser(db)\n+\n+  /**\n+   * Compiles together all the endpoints relating to public service methods.\n+   * @return A service that contains all provided endpoints of the API.\n+   */\n+  def makeService(db: PetstoreDb): Service[Request, Response] = handleExceptions andThen (\n+    pets(db) :+:\n+    store(db) :+:\n+    users(db)\n+  ).toService\n+\n+  /**\n+   * The long passed in the path becomes the ID of the Pet fetched.\n+   * @return A Router that contains the Pet fetched.\n+   */\n+  def getPet(db: PetstoreDb): Router[Future[Pet]] = Get / \"pet\" / long /> db.getPet\n+\n+  /**\n+   * The pet to be added must be passed in the body.\n+   * @return A Router that contains a RequestReader of the ID of the Pet added.\n+   */\n+  def addPet(db: PetstoreDb): Router[RequestReader[Long]] = Post / \"pet\" /> body.as[Pet].embedFlatMap(db.addPet)\n+\n+  /**\n+   * The updated, better version of the current pet must be passed in the body.\n+   * @return A Router that contains a RequestReader of the updated Pet.\n+   */\n+  def updatePet(db: PetstoreDb): Router[RequestReader[Pet]] = Put / \"pet\" /> {\n+    body.as[Pet].embedFlatMap { pet =>\n+      for {\n+        _ <- db.updatePet(pet.copy(id = Some(pet.id.getOrElse(-1))))","path":"petstore/src/main/scala/io/finch/petstore/endpoint.scala","position":81,"original_position":81,"commit_id":"3d2291be05fff38e4475fe6165b0ca5084a1cf97","original_commit_id":"3d2291be05fff38e4475fe6165b0ca5084a1cf97","user":{"login":"mimilei","id":1454638,"avatar_url":"https://avatars.githubusercontent.com/u/1454638?v=3","gravatar_id":"","url":"https://api.github.com/users/mimilei","html_url":"https://github.com/mimilei","followers_url":"https://api.github.com/users/mimilei/followers","following_url":"https://api.github.com/users/mimilei/following{/other_user}","gists_url":"https://api.github.com/users/mimilei/gists{/gist_id}","starred_url":"https://api.github.com/users/mimilei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimilei/subscriptions","organizations_url":"https://api.github.com/users/mimilei/orgs","repos_url":"https://api.github.com/users/mimilei/repos","events_url":"https://api.github.com/users/mimilei/events{/privacy}","received_events_url":"https://api.github.com/users/mimilei/received_events","type":"User","site_admin":false},"body":"Do we not have one already? If the id is empty or invalid, the getOrElse part of the method returns -1. So that when updatePet is called, it tries to fetch a pet at id -1, which doesn't exist. In response, updatePet in petstoreDb.scala will throw the MissingPet exception. Although after thinking about this, I'm pretty sure the None case inside updatePet will never be called.","created_at":"2015-07-20T21:41:46Z","updated_at":"2015-07-20T21:41:46Z","html_url":"https://github.com/finagle/finch/pull/352#discussion_r35047847","pull_request_url":"https://api.github.com/repos/finagle/finch/pulls/352","_links":{"self":{"href":"https://api.github.com/repos/finagle/finch/pulls/comments/35047847"},"html":{"href":"https://github.com/finagle/finch/pull/352#discussion_r35047847"},"pull_request":{"href":"https://api.github.com/repos/finagle/finch/pulls/352"}}},"pull_request":{"url":"https://api.github.com/repos/finagle/finch/pulls/352","id":40185595,"html_url":"https://github.com/finagle/finch/pull/352","diff_url":"https://github.com/finagle/finch/pull/352.diff","patch_url":"https://github.com/finagle/finch/pull/352.patch","issue_url":"https://api.github.com/repos/finagle/finch/issues/352","number":352,"state":"open","locked":false,"title":"Transferred working version of petstore project","user":{"login":"mimilei","id":1454638,"avatar_url":"https://avatars.githubusercontent.com/u/1454638?v=3","gravatar_id":"","url":"https://api.github.com/users/mimilei","html_url":"https://github.com/mimilei","followers_url":"https://api.github.com/users/mimilei/followers","following_url":"https://api.github.com/users/mimilei/following{/other_user}","gists_url":"https://api.github.com/users/mimilei/gists{/gist_id}","starred_url":"https://api.github.com/users/mimilei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimilei/subscriptions","organizations_url":"https://api.github.com/users/mimilei/orgs","repos_url":"https://api.github.com/users/mimilei/repos","events_url":"https://api.github.com/users/mimilei/events{/privacy}","received_events_url":"https://api.github.com/users/mimilei/received_events","type":"User","site_admin":false},"body":"Here is the petstore project in all its hopefully-not-inconsequential glory. ","created_at":"2015-07-16T23:02:52Z","updated_at":"2015-07-20T21:41:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3822205dca7dac0fc993b019dd35f65ac43980ab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/finagle/finch/pulls/352/commits","review_comments_url":"https://api.github.com/repos/finagle/finch/pulls/352/comments","review_comment_url":"https://api.github.com/repos/finagle/finch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/finagle/finch/issues/352/comments","statuses_url":"https://api.github.com/repos/finagle/finch/statuses/3d2291be05fff38e4475fe6165b0ca5084a1cf97","head":{"label":"mimilei:bestPetstoreEver","ref":"bestPetstoreEver","sha":"3d2291be05fff38e4475fe6165b0ca5084a1cf97","user":{"login":"mimilei","id":1454638,"avatar_url":"https://avatars.githubusercontent.com/u/1454638?v=3","gravatar_id":"","url":"https://api.github.com/users/mimilei","html_url":"https://github.com/mimilei","followers_url":"https://api.github.com/users/mimilei/followers","following_url":"https://api.github.com/users/mimilei/following{/other_user}","gists_url":"https://api.github.com/users/mimilei/gists{/gist_id}","starred_url":"https://api.github.com/users/mimilei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimilei/subscriptions","organizations_url":"https://api.github.com/users/mimilei/orgs","repos_url":"https://api.github.com/users/mimilei/repos","events_url":"https://api.github.com/users/mimilei/events{/privacy}","received_events_url":"https://api.github.com/users/mimilei/received_events","type":"User","site_admin":false},"repo":{"id":37077879,"name":"finch","full_name":"mimilei/finch","owner":{"login":"mimilei","id":1454638,"avatar_url":"https://avatars.githubusercontent.com/u/1454638?v=3","gravatar_id":"","url":"https://api.github.com/users/mimilei","html_url":"https://github.com/mimilei","followers_url":"https://api.github.com/users/mimilei/followers","following_url":"https://api.github.com/users/mimilei/following{/other_user}","gists_url":"https://api.github.com/users/mimilei/gists{/gist_id}","starred_url":"https://api.github.com/users/mimilei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mimilei/subscriptions","organizations_url":"https://api.github.com/users/mimilei/orgs","repos_url":"https://api.github.com/users/mimilei/repos","events_url":"https://api.github.com/users/mimilei/events{/privacy}","received_events_url":"https://api.github.com/users/mimilei/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mimilei/finch","description":"An idiomatic Scala version of finagle-http","fork":true,"url":"https://api.github.com/repos/mimilei/finch","forks_url":"https://api.github.com/repos/mimilei/finch/forks","keys_url":"https://api.github.com/repos/mimilei/finch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mimilei/finch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mimilei/finch/teams","hooks_url":"https://api.github.com/repos/mimilei/finch/hooks","issue_events_url":"https://api.github.com/repos/mimilei/finch/issues/events{/number}","events_url":"https://api.github.com/repos/mimilei/finch/events","assignees_url":"https://api.github.com/repos/mimilei/finch/assignees{/user}","branches_url":"https://api.github.com/repos/mimilei/finch/branches{/branch}","tags_url":"https://api.github.com/repos/mimilei/finch/tags","blobs_url":"https://api.github.com/repos/mimilei/finch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mimilei/finch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mimilei/finch/git/refs{/sha}","trees_url":"https://api.github.com/repos/mimilei/finch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mimilei/finch/statuses/{sha}","languages_url":"https://api.github.com/repos/mimilei/finch/languages","stargazers_url":"https://api.github.com/repos/mimilei/finch/stargazers","contributors_url":"https://api.github.com/repos/mimilei/finch/contributors","subscribers_url":"https://api.github.com/repos/mimilei/finch/subscribers","subscription_url":"https://api.github.com/repos/mimilei/finch/subscription","commits_url":"https://api.github.com/repos/mimilei/finch/commits{/sha}","git_commits_url":"https://api.github.com/repos/mimilei/finch/git/commits{/sha}","comments_url":"https://api.github.com/repos/mimilei/finch/comments{/number}","issue_comment_url":"https://api.github.com/repos/mimilei/finch/issues/comments{/number}","contents_url":"https://api.github.com/repos/mimilei/finch/contents/{+path}","compare_url":"https://api.github.com/repos/mimilei/finch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mimilei/finch/merges","archive_url":"https://api.github.com/repos/mimilei/finch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mimilei/finch/downloads","issues_url":"https://api.github.com/repos/mimilei/finch/issues{/number}","pulls_url":"https://api.github.com/repos/mimilei/finch/pulls{/number}","milestones_url":"https://api.github.com/repos/mimilei/finch/milestones{/number}","notifications_url":"https://api.github.com/repos/mimilei/finch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mimilei/finch/labels{/name}","releases_url":"https://api.github.com/repos/mimilei/finch/releases{/id}","created_at":"2015-06-08T16:11:13Z","updated_at":"2015-06-08T16:11:14Z","pushed_at":"2015-07-17T22:09:46Z","git_url":"git://github.com/mimilei/finch.git","ssh_url":"git@github.com:mimilei/finch.git","clone_url":"https://github.com/mimilei/finch.git","svn_url":"https://github.com/mimilei/finch","homepage":"","size":2838,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"finagle:master","ref":"master","sha":"cee995a603ec28bfa71169c287f065bdbb7869fa","user":{"login":"finagle","id":7944306,"avatar_url":"https://avatars.githubusercontent.com/u/7944306?v=3","gravatar_id":"","url":"https://api.github.com/users/finagle","html_url":"https://github.com/finagle","followers_url":"https://api.github.com/users/finagle/followers","following_url":"https://api.github.com/users/finagle/following{/other_user}","gists_url":"https://api.github.com/users/finagle/gists{/gist_id}","starred_url":"https://api.github.com/users/finagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finagle/subscriptions","organizations_url":"https://api.github.com/users/finagle/orgs","repos_url":"https://api.github.com/users/finagle/repos","events_url":"https://api.github.com/users/finagle/events{/privacy}","received_events_url":"https://api.github.com/users/finagle/received_events","type":"Organization","site_admin":false},"repo":{"id":18798826,"name":"finch","full_name":"finagle/finch","owner":{"login":"finagle","id":7944306,"avatar_url":"https://avatars.githubusercontent.com/u/7944306?v=3","gravatar_id":"","url":"https://api.github.com/users/finagle","html_url":"https://github.com/finagle","followers_url":"https://api.github.com/users/finagle/followers","following_url":"https://api.github.com/users/finagle/following{/other_user}","gists_url":"https://api.github.com/users/finagle/gists{/gist_id}","starred_url":"https://api.github.com/users/finagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finagle/subscriptions","organizations_url":"https://api.github.com/users/finagle/orgs","repos_url":"https://api.github.com/users/finagle/repos","events_url":"https://api.github.com/users/finagle/events{/privacy}","received_events_url":"https://api.github.com/users/finagle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/finagle/finch","description":"An idiomatic Scala version of finagle-http","fork":false,"url":"https://api.github.com/repos/finagle/finch","forks_url":"https://api.github.com/repos/finagle/finch/forks","keys_url":"https://api.github.com/repos/finagle/finch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/finagle/finch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/finagle/finch/teams","hooks_url":"https://api.github.com/repos/finagle/finch/hooks","issue_events_url":"https://api.github.com/repos/finagle/finch/issues/events{/number}","events_url":"https://api.github.com/repos/finagle/finch/events","assignees_url":"https://api.github.com/repos/finagle/finch/assignees{/user}","branches_url":"https://api.github.com/repos/finagle/finch/branches{/branch}","tags_url":"https://api.github.com/repos/finagle/finch/tags","blobs_url":"https://api.github.com/repos/finagle/finch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/finagle/finch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/finagle/finch/git/refs{/sha}","trees_url":"https://api.github.com/repos/finagle/finch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/finagle/finch/statuses/{sha}","languages_url":"https://api.github.com/repos/finagle/finch/languages","stargazers_url":"https://api.github.com/repos/finagle/finch/stargazers","contributors_url":"https://api.github.com/repos/finagle/finch/contributors","subscribers_url":"https://api.github.com/repos/finagle/finch/subscribers","subscription_url":"https://api.github.com/repos/finagle/finch/subscription","commits_url":"https://api.github.com/repos/finagle/finch/commits{/sha}","git_commits_url":"https://api.github.com/repos/finagle/finch/git/commits{/sha}","comments_url":"https://api.github.com/repos/finagle/finch/comments{/number}","issue_comment_url":"https://api.github.com/repos/finagle/finch/issues/comments{/number}","contents_url":"https://api.github.com/repos/finagle/finch/contents/{+path}","compare_url":"https://api.github.com/repos/finagle/finch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/finagle/finch/merges","archive_url":"https://api.github.com/repos/finagle/finch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/finagle/finch/downloads","issues_url":"https://api.github.com/repos/finagle/finch/issues{/number}","pulls_url":"https://api.github.com/repos/finagle/finch/pulls{/number}","milestones_url":"https://api.github.com/repos/finagle/finch/milestones{/number}","notifications_url":"https://api.github.com/repos/finagle/finch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/finagle/finch/labels{/name}","releases_url":"https://api.github.com/repos/finagle/finch/releases{/id}","created_at":"2014-04-15T12:17:44Z","updated_at":"2015-07-20T06:22:30Z","pushed_at":"2015-07-18T18:51:46Z","git_url":"git://github.com/finagle/finch.git","ssh_url":"git@github.com:finagle/finch.git","clone_url":"https://github.com/finagle/finch.git","svn_url":"https://github.com/finagle/finch","homepage":"","size":5867,"stargazers_count":361,"watchers_count":361,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":43,"mirror_url":null,"open_issues_count":33,"forks":43,"open_issues":33,"watchers":361,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/finagle/finch/pulls/352"},"html":{"href":"https://github.com/finagle/finch/pull/352"},"issue":{"href":"https://api.github.com/repos/finagle/finch/issues/352"},"comments":{"href":"https://api.github.com/repos/finagle/finch/issues/352/comments"},"review_comments":{"href":"https://api.github.com/repos/finagle/finch/pulls/352/comments"},"review_comment":{"href":"https://api.github.com/repos/finagle/finch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/finagle/finch/pulls/352/commits"},"statuses":{"href":"https://api.github.com/repos/finagle/finch/statuses/3d2291be05fff38e4475fe6165b0ca5084a1cf97"}}}}