{"action":"created","comment":{"url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/comments/234177738","pull_request_review_id":175766501,"id":234177738,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDE3NzczOA==","diff_hunk":"@@ -16,35 +16,47 @@\n \n package controllers\n \n-import javax.inject.Inject\n-import play.api.i18n.{I18nSupport, MessagesApi}\n-import uk.gov.hmrc.play.bootstrap.controller.FrontendController\n+import config.FrontendAppConfig\n import connectors.DataCacheConnector\n import controllers.actions._\n-import config.FrontendAppConfig\n-import models.Mode\n-import pages.ConfirmationPage\n+import javax.inject.Inject\n+import mapper.CaseRequestMapper\n+import models.Confirmation.format\n+import models._\n import navigation.Navigator\n+import pages.ConfirmationPage\n+import play.api.i18n.{I18nSupport, MessagesApi}\n import play.api.mvc.{Action, AnyContent}\n+import service.CasesService\n+import uk.gov.hmrc.play.bootstrap.controller.FrontendController\n import views.html.declaration\n \n-import scala.concurrent.Future\n+import scala.concurrent.ExecutionContext.Implicits.global\n \n class DeclarationController @Inject()(\n-                                        appConfig: FrontendAppConfig,\n-                                        override val messagesApi: MessagesApi,\n-                                        dataCacheConnector: DataCacheConnector,\n-                                        navigator: Navigator,\n-                                        identify: IdentifierAction,\n-                                        getData: DataRetrievalAction\n-                                      ) extends FrontendController with I18nSupport {\n+                                       appConfig: FrontendAppConfig,\n+                                       override val messagesApi: MessagesApi,\n+                                       dataCacheConnector: DataCacheConnector,\n+                                       navigator: Navigator,\n+                                       identify: IdentifierAction,\n+                                       getData: DataRetrievalAction,\n+                                       service: CasesService\n+                                     ) extends FrontendController with I18nSupport {\n \n   def onPageLoad(mode: Mode): Action[AnyContent] = (identify andThen getData) { implicit request =>\n     Ok(declaration(appConfig, mode))\n   }\n \n   def onSubmit(mode: Mode): Action[AnyContent] = (identify andThen getData).async { implicit request =>\n-    Future.successful(Redirect(navigator.nextPage(ConfirmationPage, mode)(request.userAnswers.get)))\n+    val answers: UserAnswers = request.userAnswers.get\n+\n+    service\n+      .createCase(new CaseRequestMapper().map(answers))\n+      .map(c => answers.set(ConfirmationPage, Confirmation(c.reference)))\n+      .flatMap(updatedAnswers => {\n+        dataCacheConnector.save(updatedAnswers.cacheMap)\n+          .map(_ => Redirect(navigator.nextPage(ConfirmationPage, mode)(updatedAnswers)))\n+      })","path":"app/controllers/DeclarationController.scala","position":60,"original_position":59,"commit_id":"3cad8c9307d727f7fbce27b42d7559ade44a2bb6","original_commit_id":"8bca28ed08652bc798219b425ca0bca65a0b5606","user":{"login":"gokyo","id":6510179,"node_id":"MDQ6VXNlcjY1MTAxNzk=","avatar_url":"https://avatars2.githubusercontent.com/u/6510179?v=4","gravatar_id":"","url":"https://api.github.com/users/gokyo","html_url":"https://github.com/gokyo","followers_url":"https://api.github.com/users/gokyo/followers","following_url":"https://api.github.com/users/gokyo/following{/other_user}","gists_url":"https://api.github.com/users/gokyo/gists{/gist_id}","starred_url":"https://api.github.com/users/gokyo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gokyo/subscriptions","organizations_url":"https://api.github.com/users/gokyo/orgs","repos_url":"https://api.github.com/users/gokyo/repos","events_url":"https://api.github.com/users/gokyo/events{/privacy}","received_events_url":"https://api.github.com/users/gokyo/received_events","type":"User","site_admin":false},"body":"Look at the code.\r\nThe for-comprehension is very tidy and simple to read\r\n\r\nIn my opinion map and flatMap are readable, but in this case you have lot of brackets\r\nIt is very messy to read","created_at":"2018-11-16T11:44:50Z","updated_at":"2018-11-16T11:44:50Z","html_url":"https://github.com/hmrc/binding-tariff-trader-frontend/pull/13#discussion_r234177738","pull_request_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/comments/234177738"},"html":{"href":"https://github.com/hmrc/binding-tariff-trader-frontend/pull/13#discussion_r234177738"},"pull_request":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13"}},"in_reply_to_id":234142879},"pull_request":{"url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13","id":231468107,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxNDY4MTA3","html_url":"https://github.com/hmrc/binding-tariff-trader-frontend/pull/13","diff_url":"https://github.com/hmrc/binding-tariff-trader-frontend/pull/13.diff","patch_url":"https://github.com/hmrc/binding-tariff-trader-frontend/pull/13.patch","issue_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/13","number":13,"state":"open","locked":false,"title":"DIT-409 Hook up Trader UI with the Cases Backend (WIP)","user":{"login":"ed0906","id":4864094,"node_id":"MDQ6VXNlcjQ4NjQwOTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4864094?v=4","gravatar_id":"","url":"https://api.github.com/users/ed0906","html_url":"https://github.com/ed0906","followers_url":"https://api.github.com/users/ed0906/followers","following_url":"https://api.github.com/users/ed0906/following{/other_user}","gists_url":"https://api.github.com/users/ed0906/gists{/gist_id}","starred_url":"https://api.github.com/users/ed0906/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ed0906/subscriptions","organizations_url":"https://api.github.com/users/ed0906/orgs","repos_url":"https://api.github.com/users/ed0906/repos","events_url":"https://api.github.com/users/ed0906/events{/privacy}","received_events_url":"https://api.github.com/users/ed0906/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-16T09:37:26Z","updated_at":"2018-11-16T11:44:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3e11ac2f4faeae3d0c3a56da7986ec7b2f93c01","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13/commits","review_comments_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13/comments","review_comment_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/13/comments","statuses_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/statuses/3cad8c9307d727f7fbce27b42d7559ade44a2bb6","head":{"label":"hmrc:DIT-409","ref":"DIT-409","sha":"3cad8c9307d727f7fbce27b42d7559ade44a2bb6","user":{"login":"hmrc","id":5755339,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3NTUzMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5755339?v=4","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"repo":{"id":153767758,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM3Njc3NTg=","name":"binding-tariff-trader-frontend","full_name":"hmrc/binding-tariff-trader-frontend","private":false,"owner":{"login":"hmrc","id":5755339,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3NTUzMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5755339?v=4","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/hmrc/binding-tariff-trader-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend","forks_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/forks","keys_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/teams","hooks_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/hooks","issue_events_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/events","assignees_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/tags","blobs_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/languages","stargazers_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/stargazers","contributors_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/contributors","subscribers_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/subscribers","subscription_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/subscription","commits_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/merges","archive_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/downloads","issues_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/deployments","created_at":"2018-10-19T10:42:53Z","updated_at":"2018-11-16T11:05:55Z","pushed_at":"2018-11-16T11:39:58Z","git_url":"git://github.com/hmrc/binding-tariff-trader-frontend.git","ssh_url":"git@github.com:hmrc/binding-tariff-trader-frontend.git","clone_url":"https://github.com/hmrc/binding-tariff-trader-frontend.git","svn_url":"https://github.com/hmrc/binding-tariff-trader-frontend","homepage":"","size":289,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"hmrc:master","ref":"master","sha":"e38f0030b456083648d23a23af4e52ee8788d217","user":{"login":"hmrc","id":5755339,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3NTUzMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5755339?v=4","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"repo":{"id":153767758,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM3Njc3NTg=","name":"binding-tariff-trader-frontend","full_name":"hmrc/binding-tariff-trader-frontend","private":false,"owner":{"login":"hmrc","id":5755339,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3NTUzMzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5755339?v=4","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/hmrc/binding-tariff-trader-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend","forks_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/forks","keys_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/teams","hooks_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/hooks","issue_events_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/events","assignees_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/tags","blobs_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/languages","stargazers_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/stargazers","contributors_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/contributors","subscribers_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/subscribers","subscription_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/subscription","commits_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/merges","archive_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/downloads","issues_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/deployments","created_at":"2018-10-19T10:42:53Z","updated_at":"2018-11-16T11:05:55Z","pushed_at":"2018-11-16T11:39:58Z","git_url":"git://github.com/hmrc/binding-tariff-trader-frontend.git","ssh_url":"git@github.com:hmrc/binding-tariff-trader-frontend.git","clone_url":"https://github.com/hmrc/binding-tariff-trader-frontend.git","svn_url":"https://github.com/hmrc/binding-tariff-trader-frontend","homepage":"","size":289,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13"},"html":{"href":"https://github.com/hmrc/binding-tariff-trader-frontend/pull/13"},"issue":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/13"},"comments":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/hmrc/binding-tariff-trader-frontend/statuses/3cad8c9307d727f7fbce27b42d7559ade44a2bb6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"gokyo"}}