{"action":"created","comment":{"url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/comments/64522507","id":64522507,"diff_hunk":"@@ -0,0 +1,65 @@\n+package parking.controllers;\n+\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.web.bind.annotation.*;\n+import parking.beans.document.AvailablePeriod;\n+import parking.beans.document.ParkingLot;\n+import parking.beans.request.RecallParking;\n+import parking.beans.request.SetUnusedRequest;\n+import parking.beans.response.Parking;\n+import parking.exceptions.ApplicationException;\n+import parking.helper.AvailableDatesConverter;\n+import parking.service.ParkingService;\n+\n+import javax.servlet.http.HttpServletRequest;\n+import javax.validation.Valid;\n+import java.util.List;\n+import java.util.function.Function;\n+import java.util.stream.Collectors;\n+\n+@RestController\n+@RequestMapping(value = \"/v2/parking\")\n+public class ParkingControllerV2 {\n+    @Autowired\n+    private ParkingService parkingService;\n+\n+    @RequestMapping(value = \"/available\", method = RequestMethod.GET)\n+    public List<Parking> getAllAvailable(HttpServletRequest request) throws ApplicationException {\n+        Function<ParkingLot, Parking> mapper = lot -> new Parking(lot, true);\n+        return parkingService.getAvailable(request).stream()\n+                .map(mapper)\n+                .collect(Collectors.<Parking>toList());\n+    }\n+\n+    @RequestMapping(value = \"/availability\", method = RequestMethod.PUT)\n+    public void freeOwnersParking(@Valid @RequestBody SetUnusedRequest request, HttpServletRequest httpRequest) throws ApplicationException {\n+        AvailableDatesConverter converter = new AvailableDatesConverter();\n+        List<AvailablePeriod> availablePeriods;\n+\n+        if(request.getAvailableDates().size() == 0){\n+            return;\n+        }\n+        else {\n+            availablePeriods = converter.convertToInterval(request.getAvailableDates());\n+        }\n+\n+        for(AvailablePeriod p: availablePeriods) {\n+            parkingService.freeOwnersParking(p.getFreeFrom(), p.getFreeTill(), httpRequest);\n+        }\n+    }\n+\n+    @RequestMapping(value = \"/availability\", method = RequestMethod.DELETE)\n+    public void recallParking(@Valid @RequestBody RecallParking recallParking, HttpServletRequest request) throws ApplicationException {\n+        parkingService.recallParking(recallParking.getAvailableDates(), request);\n+    }\n+\n+    @RequestMapping(value = \"/{lotNumber}/reservation\", method = RequestMethod.PUT)\n+    public void reserveOwnersParking(@PathVariable(value = \"lotNumber\") Integer lotNumber, HttpServletRequest httpRequest) throws ApplicationException {\n+        parkingService.reserve(lotNumber, httpRequest);\n+    }\n+\n+    @RequestMapping(value = \"/{lotNumber}/reservation\", method = RequestMethod.DELETE)\n+    public void cancelReservation(@PathVariable(value = \"lotNumber\") Integer lotNumber, HttpServletRequest request) throws ApplicationException {","path":"src/main/java/parking/controllers/ParkingControllerV2.java","position":62,"original_position":62,"commit_id":"25ca96c816a6451f2a011f5f3a427c383ea8b3dc","original_commit_id":"2712a3a9452eb65ac82484be509bc9100a594947","user":{"login":"LinaPo","id":4890310,"avatar_url":"https://avatars.githubusercontent.com/u/4890310?v=3","gravatar_id":"","url":"https://api.github.com/users/LinaPo","html_url":"https://github.com/LinaPo","followers_url":"https://api.github.com/users/LinaPo/followers","following_url":"https://api.github.com/users/LinaPo/following{/other_user}","gists_url":"https://api.github.com/users/LinaPo/gists{/gist_id}","starred_url":"https://api.github.com/users/LinaPo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinaPo/subscriptions","organizations_url":"https://api.github.com/users/LinaPo/orgs","repos_url":"https://api.github.com/users/LinaPo/repos","events_url":"https://api.github.com/users/LinaPo/events{/privacy}","received_events_url":"https://api.github.com/users/LinaPo/received_events","type":"User","site_admin":false},"body":"It is optional, it is useful when PathVariable name does not match the argument name. I think I will leave it there since it does not make any harm. ","created_at":"2016-05-25T06:44:55Z","updated_at":"2016-05-25T06:44:55Z","html_url":"https://github.com/parking-lots/parking-rest-api/pull/34#discussion_r64522507","pull_request_url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/comments/64522507"},"html":{"href":"https://github.com/parking-lots/parking-rest-api/pull/34#discussion_r64522507"},"pull_request":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34","id":71209433,"html_url":"https://github.com/parking-lots/parking-rest-api/pull/34","diff_url":"https://github.com/parking-lots/parking-rest-api/pull/34.diff","patch_url":"https://github.com/parking-lots/parking-rest-api/pull/34.patch","issue_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/34","number":34,"state":"open","locked":false,"title":"Feature/new rest","user":{"login":"LinaPo","id":4890310,"avatar_url":"https://avatars.githubusercontent.com/u/4890310?v=3","gravatar_id":"","url":"https://api.github.com/users/LinaPo","html_url":"https://github.com/LinaPo","followers_url":"https://api.github.com/users/LinaPo/followers","following_url":"https://api.github.com/users/LinaPo/following{/other_user}","gists_url":"https://api.github.com/users/LinaPo/gists{/gist_id}","starred_url":"https://api.github.com/users/LinaPo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinaPo/subscriptions","organizations_url":"https://api.github.com/users/LinaPo/orgs","repos_url":"https://api.github.com/users/LinaPo/repos","events_url":"https://api.github.com/users/LinaPo/events{/privacy}","received_events_url":"https://api.github.com/users/LinaPo/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-24T12:18:49Z","updated_at":"2016-05-25T06:44:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76d4bf916ac56ad12da4d26a3db676f894fa1b1f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34/commits","review_comments_url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34/comments","review_comment_url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/34/comments","statuses_url":"https://api.github.com/repos/parking-lots/parking-rest-api/statuses/25ca96c816a6451f2a011f5f3a427c383ea8b3dc","head":{"label":"parking-lots:feature/new-rest","ref":"feature/new-rest","sha":"25ca96c816a6451f2a011f5f3a427c383ea8b3dc","user":{"login":"parking-lots","id":16131159,"avatar_url":"https://avatars.githubusercontent.com/u/16131159?v=3","gravatar_id":"","url":"https://api.github.com/users/parking-lots","html_url":"https://github.com/parking-lots","followers_url":"https://api.github.com/users/parking-lots/followers","following_url":"https://api.github.com/users/parking-lots/following{/other_user}","gists_url":"https://api.github.com/users/parking-lots/gists{/gist_id}","starred_url":"https://api.github.com/users/parking-lots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parking-lots/subscriptions","organizations_url":"https://api.github.com/users/parking-lots/orgs","repos_url":"https://api.github.com/users/parking-lots/repos","events_url":"https://api.github.com/users/parking-lots/events{/privacy}","received_events_url":"https://api.github.com/users/parking-lots/received_events","type":"Organization","site_admin":false},"repo":{"id":47346238,"name":"parking-rest-api","full_name":"parking-lots/parking-rest-api","owner":{"login":"parking-lots","id":16131159,"avatar_url":"https://avatars.githubusercontent.com/u/16131159?v=3","gravatar_id":"","url":"https://api.github.com/users/parking-lots","html_url":"https://github.com/parking-lots","followers_url":"https://api.github.com/users/parking-lots/followers","following_url":"https://api.github.com/users/parking-lots/following{/other_user}","gists_url":"https://api.github.com/users/parking-lots/gists{/gist_id}","starred_url":"https://api.github.com/users/parking-lots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parking-lots/subscriptions","organizations_url":"https://api.github.com/users/parking-lots/orgs","repos_url":"https://api.github.com/users/parking-lots/repos","events_url":"https://api.github.com/users/parking-lots/events{/privacy}","received_events_url":"https://api.github.com/users/parking-lots/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/parking-lots/parking-rest-api","description":"","fork":false,"url":"https://api.github.com/repos/parking-lots/parking-rest-api","forks_url":"https://api.github.com/repos/parking-lots/parking-rest-api/forks","keys_url":"https://api.github.com/repos/parking-lots/parking-rest-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parking-lots/parking-rest-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parking-lots/parking-rest-api/teams","hooks_url":"https://api.github.com/repos/parking-lots/parking-rest-api/hooks","issue_events_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/events{/number}","events_url":"https://api.github.com/repos/parking-lots/parking-rest-api/events","assignees_url":"https://api.github.com/repos/parking-lots/parking-rest-api/assignees{/user}","branches_url":"https://api.github.com/repos/parking-lots/parking-rest-api/branches{/branch}","tags_url":"https://api.github.com/repos/parking-lots/parking-rest-api/tags","blobs_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parking-lots/parking-rest-api/statuses/{sha}","languages_url":"https://api.github.com/repos/parking-lots/parking-rest-api/languages","stargazers_url":"https://api.github.com/repos/parking-lots/parking-rest-api/stargazers","contributors_url":"https://api.github.com/repos/parking-lots/parking-rest-api/contributors","subscribers_url":"https://api.github.com/repos/parking-lots/parking-rest-api/subscribers","subscription_url":"https://api.github.com/repos/parking-lots/parking-rest-api/subscription","commits_url":"https://api.github.com/repos/parking-lots/parking-rest-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/parking-lots/parking-rest-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/parking-lots/parking-rest-api/contents/{+path}","compare_url":"https://api.github.com/repos/parking-lots/parking-rest-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parking-lots/parking-rest-api/merges","archive_url":"https://api.github.com/repos/parking-lots/parking-rest-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parking-lots/parking-rest-api/downloads","issues_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues{/number}","pulls_url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls{/number}","milestones_url":"https://api.github.com/repos/parking-lots/parking-rest-api/milestones{/number}","notifications_url":"https://api.github.com/repos/parking-lots/parking-rest-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parking-lots/parking-rest-api/labels{/name}","releases_url":"https://api.github.com/repos/parking-lots/parking-rest-api/releases{/id}","deployments_url":"https://api.github.com/repos/parking-lots/parking-rest-api/deployments","created_at":"2015-12-03T16:53:15Z","updated_at":"2016-01-11T07:32:18Z","pushed_at":"2016-05-24T15:01:44Z","git_url":"git://github.com/parking-lots/parking-rest-api.git","ssh_url":"git@github.com:parking-lots/parking-rest-api.git","clone_url":"https://github.com/parking-lots/parking-rest-api.git","svn_url":"https://github.com/parking-lots/parking-rest-api","homepage":null,"size":295,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":1,"default_branch":"integration"}},"base":{"label":"parking-lots:feature/parking-sharing","ref":"feature/parking-sharing","sha":"cff09f43d42dd3a72927a1595ac398e87ccecbfe","user":{"login":"parking-lots","id":16131159,"avatar_url":"https://avatars.githubusercontent.com/u/16131159?v=3","gravatar_id":"","url":"https://api.github.com/users/parking-lots","html_url":"https://github.com/parking-lots","followers_url":"https://api.github.com/users/parking-lots/followers","following_url":"https://api.github.com/users/parking-lots/following{/other_user}","gists_url":"https://api.github.com/users/parking-lots/gists{/gist_id}","starred_url":"https://api.github.com/users/parking-lots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parking-lots/subscriptions","organizations_url":"https://api.github.com/users/parking-lots/orgs","repos_url":"https://api.github.com/users/parking-lots/repos","events_url":"https://api.github.com/users/parking-lots/events{/privacy}","received_events_url":"https://api.github.com/users/parking-lots/received_events","type":"Organization","site_admin":false},"repo":{"id":47346238,"name":"parking-rest-api","full_name":"parking-lots/parking-rest-api","owner":{"login":"parking-lots","id":16131159,"avatar_url":"https://avatars.githubusercontent.com/u/16131159?v=3","gravatar_id":"","url":"https://api.github.com/users/parking-lots","html_url":"https://github.com/parking-lots","followers_url":"https://api.github.com/users/parking-lots/followers","following_url":"https://api.github.com/users/parking-lots/following{/other_user}","gists_url":"https://api.github.com/users/parking-lots/gists{/gist_id}","starred_url":"https://api.github.com/users/parking-lots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parking-lots/subscriptions","organizations_url":"https://api.github.com/users/parking-lots/orgs","repos_url":"https://api.github.com/users/parking-lots/repos","events_url":"https://api.github.com/users/parking-lots/events{/privacy}","received_events_url":"https://api.github.com/users/parking-lots/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/parking-lots/parking-rest-api","description":"","fork":false,"url":"https://api.github.com/repos/parking-lots/parking-rest-api","forks_url":"https://api.github.com/repos/parking-lots/parking-rest-api/forks","keys_url":"https://api.github.com/repos/parking-lots/parking-rest-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parking-lots/parking-rest-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parking-lots/parking-rest-api/teams","hooks_url":"https://api.github.com/repos/parking-lots/parking-rest-api/hooks","issue_events_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/events{/number}","events_url":"https://api.github.com/repos/parking-lots/parking-rest-api/events","assignees_url":"https://api.github.com/repos/parking-lots/parking-rest-api/assignees{/user}","branches_url":"https://api.github.com/repos/parking-lots/parking-rest-api/branches{/branch}","tags_url":"https://api.github.com/repos/parking-lots/parking-rest-api/tags","blobs_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parking-lots/parking-rest-api/statuses/{sha}","languages_url":"https://api.github.com/repos/parking-lots/parking-rest-api/languages","stargazers_url":"https://api.github.com/repos/parking-lots/parking-rest-api/stargazers","contributors_url":"https://api.github.com/repos/parking-lots/parking-rest-api/contributors","subscribers_url":"https://api.github.com/repos/parking-lots/parking-rest-api/subscribers","subscription_url":"https://api.github.com/repos/parking-lots/parking-rest-api/subscription","commits_url":"https://api.github.com/repos/parking-lots/parking-rest-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/parking-lots/parking-rest-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/parking-lots/parking-rest-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/parking-lots/parking-rest-api/contents/{+path}","compare_url":"https://api.github.com/repos/parking-lots/parking-rest-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parking-lots/parking-rest-api/merges","archive_url":"https://api.github.com/repos/parking-lots/parking-rest-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parking-lots/parking-rest-api/downloads","issues_url":"https://api.github.com/repos/parking-lots/parking-rest-api/issues{/number}","pulls_url":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls{/number}","milestones_url":"https://api.github.com/repos/parking-lots/parking-rest-api/milestones{/number}","notifications_url":"https://api.github.com/repos/parking-lots/parking-rest-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parking-lots/parking-rest-api/labels{/name}","releases_url":"https://api.github.com/repos/parking-lots/parking-rest-api/releases{/id}","deployments_url":"https://api.github.com/repos/parking-lots/parking-rest-api/deployments","created_at":"2015-12-03T16:53:15Z","updated_at":"2016-01-11T07:32:18Z","pushed_at":"2016-05-24T15:01:44Z","git_url":"git://github.com/parking-lots/parking-rest-api.git","ssh_url":"git@github.com:parking-lots/parking-rest-api.git","clone_url":"https://github.com/parking-lots/parking-rest-api.git","svn_url":"https://github.com/parking-lots/parking-rest-api","homepage":null,"size":295,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":1,"default_branch":"integration"}},"_links":{"self":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34"},"html":{"href":"https://github.com/parking-lots/parking-rest-api/pull/34"},"issue":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/34"},"comments":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/parking-lots/parking-rest-api/statuses/25ca96c816a6451f2a011f5f3a427c383ea8b3dc"}}}}
{"actor":{"display_login":"LinaPo"}}