{"action":"created","comment":{"url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/comments/205710086","pull_request_review_id":141034792,"id":205710086,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTcxMDA4Ng==","diff_hunk":"@@ -61,4 +82,50 @@ class SubscriptionService @Inject()(agentSubscriptionConnector: AgentSubscriptio\n       case e => throw e\n     }\n   }\n+\n+  def completePartialSubscription(details: CompletePartialSubscriptionBody)(\n+    implicit hc: HeaderCarrier,\n+    ec: ExecutionContext): Future[(Boolean, Option[Arn])] =\n+    for {\n+      subscriptionProgress <- getSubscriptionStatus(details.utr, details.knownFacts.postcode) //FixMe APB-2805 this check should happen previously and can be stored in the session\n+      isPartiallySubscribed = subscriptionProgress.state == SubscriptionState.IsOnlySubscribedInETMP\n+      (wasPartiallySubscribed, optSucceededAllocatingArn) <- isPartiallySubscribed match {\n+                                                              case true =>\n+                                                                agentSubscriptionConnector\n+                                                                  .completePartialSubscription(details)\n+                                                                  .map(arn => (true, Some.apply(arn)))\n+                                                                  .recover {\n+                                                                    case e: Upstream4xxResponse\n+                                                                        if Seq(Status.FORBIDDEN, Status.CONFLICT) contains e.upstreamResponseCode =>\n+                                                                      (true, None)\n+                                                                    case e => throw e\n+                                                                  }\n+                                                              case false =>\n+                                                                Future successful (false, None)\n+                                                            }\n+    } yield (wasPartiallySubscribed, optSucceededAllocatingArn)\n+\n+  def getSubscriptionStatus(utr: Utr, postcode: String)(\n+    implicit hc: HeaderCarrier,\n+    ec: ExecutionContext): Future[SubscriptionProcess] =\n+    agentSubscriptionConnector.getRegistration(utr, postcode).map {\n+\n+      case Some(reg) if reg.isSubscribedToAgentServices && reg.isSubscribedToETMP =>","path":"app/uk/gov/hmrc/agentsubscriptionfrontend/service/SubscriptionService.scala","position":72,"original_position":72,"commit_id":"52087cdf2c4151491a0662ab3a81684068fdb6c3","original_commit_id":"52087cdf2c4151491a0662ab3a81684068fdb6c3","user":{"login":"rvijayan","id":1162138,"node_id":"MDQ6VXNlcjExNjIxMzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1162138?v=4","gravatar_id":"","url":"https://api.github.com/users/rvijayan","html_url":"https://github.com/rvijayan","followers_url":"https://api.github.com/users/rvijayan/followers","following_url":"https://api.github.com/users/rvijayan/following{/other_user}","gists_url":"https://api.github.com/users/rvijayan/gists{/gist_id}","starred_url":"https://api.github.com/users/rvijayan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvijayan/subscriptions","organizations_url":"https://api.github.com/users/rvijayan/orgs","repos_url":"https://api.github.com/users/rvijayan/repos","events_url":"https://api.github.com/users/rvijayan/events{/privacy}","received_events_url":"https://api.github.com/users/rvijayan/received_events","type":"User","site_admin":false},"body":"You can remove reg.isSubscribedToETMP from here since isSubscribedToAgentServices contains both.","created_at":"2018-07-27T09:00:27Z","updated_at":"2018-07-27T09:00:27Z","html_url":"https://github.com/hmrc/agent-subscription-frontend/pull/206#discussion_r205710086","pull_request_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/comments/205710086"},"html":{"href":"https://github.com/hmrc/agent-subscription-frontend/pull/206#discussion_r205710086"},"pull_request":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206"}}},"pull_request":{"url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206","id":204170053,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0MTcwMDUz","html_url":"https://github.com/hmrc/agent-subscription-frontend/pull/206","diff_url":"https://github.com/hmrc/agent-subscription-frontend/pull/206.diff","patch_url":"https://github.com/hmrc/agent-subscription-frontend/pull/206.patch","issue_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/206","number":206,"state":"open","locked":false,"title":"[APB-2816][AK] cater for partially subscribed agents, when HMRC-AS-AGENT enrolment is not allocated","user":{"login":"arkowalski","id":31273784,"node_id":"MDQ6VXNlcjMxMjczNzg0","avatar_url":"https://avatars0.githubusercontent.com/u/31273784?v=4","gravatar_id":"","url":"https://api.github.com/users/arkowalski","html_url":"https://github.com/arkowalski","followers_url":"https://api.github.com/users/arkowalski/followers","following_url":"https://api.github.com/users/arkowalski/following{/other_user}","gists_url":"https://api.github.com/users/arkowalski/gists{/gist_id}","starred_url":"https://api.github.com/users/arkowalski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arkowalski/subscriptions","organizations_url":"https://api.github.com/users/arkowalski/orgs","repos_url":"https://api.github.com/users/arkowalski/repos","events_url":"https://api.github.com/users/arkowalski/events{/privacy}","received_events_url":"https://api.github.com/users/arkowalski/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-26T14:54:53Z","updated_at":"2018-07-27T09:00:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d56df65cd0eb4dae30e3e20bebbc033809f23f2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206/commits","review_comments_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206/comments","review_comment_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/206/comments","statuses_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/statuses/52087cdf2c4151491a0662ab3a81684068fdb6c3","head":{"label":"hmrc:APB-2816","ref":"APB-2816","sha":"52087cdf2c4151491a0662ab3a81684068fdb6c3","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":80200470,"node_id":"MDEwOlJlcG9zaXRvcnk4MDIwMDQ3MA==","name":"agent-subscription-frontend","full_name":"hmrc/agent-subscription-frontend","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},"private":false,"html_url":"https://github.com/hmrc/agent-subscription-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/hmrc/agent-subscription-frontend","forks_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/forks","keys_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/teams","hooks_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/hooks","issue_events_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/events","assignees_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/tags","blobs_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/languages","stargazers_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/stargazers","contributors_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/contributors","subscribers_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/subscribers","subscription_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/subscription","commits_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/merges","archive_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/downloads","issues_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/deployments","created_at":"2017-01-27T10:58:40Z","updated_at":"2018-07-26T10:21:31Z","pushed_at":"2018-07-26T14:54:53Z","git_url":"git://github.com/hmrc/agent-subscription-frontend.git","ssh_url":"git@github.com:hmrc/agent-subscription-frontend.git","clone_url":"https://github.com/hmrc/agent-subscription-frontend.git","svn_url":"https://github.com/hmrc/agent-subscription-frontend","homepage":"","size":1094,"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":1,"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":1,"watchers":0,"default_branch":"master"}},"base":{"label":"hmrc:master","ref":"master","sha":"1230cab609dc904760a0fb627976bb9cf292b001","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":80200470,"node_id":"MDEwOlJlcG9zaXRvcnk4MDIwMDQ3MA==","name":"agent-subscription-frontend","full_name":"hmrc/agent-subscription-frontend","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},"private":false,"html_url":"https://github.com/hmrc/agent-subscription-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/hmrc/agent-subscription-frontend","forks_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/forks","keys_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/teams","hooks_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/hooks","issue_events_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/events","assignees_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/tags","blobs_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/languages","stargazers_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/stargazers","contributors_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/contributors","subscribers_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/subscribers","subscription_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/subscription","commits_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/merges","archive_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/downloads","issues_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/agent-subscription-frontend/deployments","created_at":"2017-01-27T10:58:40Z","updated_at":"2018-07-26T10:21:31Z","pushed_at":"2018-07-26T14:54:53Z","git_url":"git://github.com/hmrc/agent-subscription-frontend.git","ssh_url":"git@github.com:hmrc/agent-subscription-frontend.git","clone_url":"https://github.com/hmrc/agent-subscription-frontend.git","svn_url":"https://github.com/hmrc/agent-subscription-frontend","homepage":"","size":1094,"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":1,"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":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206"},"html":{"href":"https://github.com/hmrc/agent-subscription-frontend/pull/206"},"issue":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/206"},"comments":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/issues/206/comments"},"review_comments":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206/comments"},"review_comment":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/pulls/206/commits"},"statuses":{"href":"https://api.github.com/repos/hmrc/agent-subscription-frontend/statuses/52087cdf2c4151491a0662ab3a81684068fdb6c3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rvijayan"}}