{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments/83387870","pull_request_review_id":4235527,"id":83387870,"diff_hunk":"@@ -0,0 +1,103 @@\n+package views.support\n+import com.gu.i18n.{Country, CountryGroup, Currency, GBP}\n+import com.gu.memsub.Product.Membership\n+import com.gu.memsub.Subscription.ProductRatePlanId\n+import com.gu.memsub.subsv2.{CatalogPlan, _}\n+import com.gu.memsub.{Subscription => _, _}\n+import com.gu.salesforce.{FreeTier, PaidTier, Tier}\n+\n+import scala.language.higherKinds\n+import scala.util.Try\n+\n+/**\n+  * this is a temporary situation until membership is refactored more properly to understand the new membership-common models\n+  * please delete me and refactor all the things properly!\n+  */\n+object MembershipCompat {\n+\n+  implicit class MonthYearMembership(in: MonthYearPlans[CatalogPlan.PaidMember]) {\n+    def tier: PaidTier = in.month.tier\n+  }\n+\n+  implicit class GenericMembership(in: Plan[Membership, ChargeList with SingleBenefit[MemberTier]]) {\n+\n+    def currency: Currency = in.charges.currencies.head\n+\n+    def tier: Tier = in.charges.benefit match {\n+      case Supporter => Tier.supporter\n+      case Partner => Tier.partner\n+      case Patron => Tier.patron\n+      case Friend => Tier.friend\n+      case Staff => Tier.staff\n+\n+    }\n+  }\n+\n+  implicit class PaidMembership(in: Plan[Membership, PaidCharge[PaidMemberTier, BillingPeriod]]) {\n+\n+    def currencyOrGBP(cg: Country): Currency = CountryGroup\n+      .byCountryCode(cg.alpha2).map(_.currency)\n+      .filter(in.charges.price.currencies.contains)\n+      .getOrElse(GBP)\n+\n+    def tier: PaidTier = in.charges.benefit match {\n+      case Supporter => Tier.supporter\n+      case Partner => Tier.partner\n+      case Patron => Tier.patron\n+    }\n+  }\n+\n+  implicit class YMPlans(in: MonthYearPlans[CatalogPlan.PaidMember]) {\n+\n+    def get(b: BillingPeriod): CatalogPlan.PaidMember[BillingPeriod] = b match {\n+      case Month() => in.month\n+      case Year() => in.year\n+      case _ => throw new RuntimeException(\"can't have quarterly membership\")\n+    }\n+  }\n+\n+  implicit class FreeMembership(in: CatalogPlan.FreeMember) {\n+\n+    def currencyOrGBP(cg: Country): Currency = CountryGroup\n+      .byCountryCode(cg.alpha2).map(_.currency)\n+      .filter(in.charges.currencies.contains)\n+      .getOrElse(GBP)\n+\n+    def tier: FreeTier = in.charges.benefit match {\n+      case Friend => Tier.friend\n+      case Staff => Tier.staff\n+    }\n+  }\n+\n+  implicit class tierCatalog(in: Catalog) {\n+\n+    def find(prpId: ProductRatePlanId) =\n+      Seq(in.friend, in.supporter.month, in.supporter.year, in.partner.month, in.partner.year, in.patron.month, in.patron.year)\n+        .find(_.id == prpId)\n+\n+    def unsafeFind(prpId: ProductRatePlanId) =\n+      find(prpId).getOrElse(throw new Exception(s\"no plan with $prpId\"))\n+\n+    def unsafeFindPaid(prpId: ProductRatePlanId): CatalogPlan.PaidMember[BillingPeriod] =\n+      Seq(in.supporter.month, in.supporter.year, in.partner.month, in.partner.year, in.patron.month, in.patron.year)\n+        .find(_.id == prpId).getOrElse(throw new Exception(s\"no paid plan with id $prpId\"))\n+\n+    def unsafeFindFree(prpId: ProductRatePlanId): CatalogPlan.FreeMember = Seq(in.friend, in.staff)\n+        .find(_.id == prpId).getOrElse(throw new Exception(s\"no free plan with id $prpId\"))\n+\n+    def findPaid(p: PaidTier): MonthYearPlans[CatalogPlan.PaidMember] = p match {\n+      case Tier.Supporter() => in.supporter\n+      case Tier.Partner() => in.partner\n+      case Tier.Patron() => in.patron\n+    }\n+\n+    def findPaid(p: ProductRatePlanId): Option[CatalogPlan.PaidMember[BillingPeriod]] =\n+      Try(unsafeFindPaid(p)).toOption\n+\n+    def findFree(f: FreeTier) = f match {\n+      case Tier.Friend() => in.friend\n+      case Tier.Staff() => in.friend // fix","path":"frontend/app/views/support/MembershipCompat.scala","position":99,"original_position":99,"commit_id":"b8e1e7c6bb5f23998ecc0695b132582cd39ea0cb","original_commit_id":"b8e1e7c6bb5f23998ecc0695b132582cd39ea0cb","user":{"login":"johnduffell","id":7304387,"avatar_url":"https://avatars.githubusercontent.com/u/7304387?v=3","gravatar_id":"","url":"https://api.github.com/users/johnduffell","html_url":"https://github.com/johnduffell","followers_url":"https://api.github.com/users/johnduffell/followers","following_url":"https://api.github.com/users/johnduffell/following{/other_user}","gists_url":"https://api.github.com/users/johnduffell/gists{/gist_id}","starred_url":"https://api.github.com/users/johnduffell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnduffell/subscriptions","organizations_url":"https://api.github.com/users/johnduffell/orgs","repos_url":"https://api.github.com/users/johnduffell/repos","events_url":"https://api.github.com/users/johnduffell/events{/privacy}","received_events_url":"https://api.github.com/users/johnduffell/received_events","type":"User","site_admin":false},"body":"oh dear! no idea why that was there, it was all a race to deploy before tom left so I don't think it got reviewed at all. thanks for fixing!","created_at":"2016-10-14T09:31:05Z","updated_at":"2016-10-14T09:31:05Z","html_url":"https://github.com/guardian/membership-frontend/pull/1332#discussion_r83387870","pull_request_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332","_links":{"self":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments/83387870"},"html":{"href":"https://github.com/guardian/membership-frontend/pull/1332#discussion_r83387870"},"pull_request":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332","id":87874849,"html_url":"https://github.com/guardian/membership-frontend/pull/1332","diff_url":"https://github.com/guardian/membership-frontend/pull/1332.diff","patch_url":"https://github.com/guardian/membership-frontend/pull/1332.patch","issue_url":"https://api.github.com/repos/guardian/membership-frontend/issues/1332","number":1332,"state":"closed","locked":false,"title":"New subs model","user":{"login":"johnduffell","id":7304387,"avatar_url":"https://avatars.githubusercontent.com/u/7304387?v=3","gravatar_id":"","url":"https://api.github.com/users/johnduffell","html_url":"https://github.com/johnduffell","followers_url":"https://api.github.com/users/johnduffell/followers","following_url":"https://api.github.com/users/johnduffell/following{/other_user}","gists_url":"https://api.github.com/users/johnduffell/gists{/gist_id}","starred_url":"https://api.github.com/users/johnduffell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnduffell/subscriptions","organizations_url":"https://api.github.com/users/johnduffell/orgs","repos_url":"https://api.github.com/users/johnduffell/repos","events_url":"https://api.github.com/users/johnduffell/events{/privacy}","received_events_url":"https://api.github.com/users/johnduffell/received_events","type":"User","site_admin":false},"body":"Update to the latest membership common!\r\n\r\nThis gives us the new refactored models with the new readers to allow guardian weekly.  Also okhttp3 and some small changes.\r\n\r\n@tomverran ","created_at":"2016-10-04T11:18:03Z","updated_at":"2016-10-14T09:31:05Z","closed_at":"2016-10-04T12:39:51Z","merged_at":"2016-10-04T12:39:51Z","merge_commit_sha":"6ce630bff01ef1da34b876cc353faa7cc3b867cc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332/commits","review_comments_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332/comments","review_comment_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/membership-frontend/issues/1332/comments","statuses_url":"https://api.github.com/repos/guardian/membership-frontend/statuses/b8e1e7c6bb5f23998ecc0695b132582cd39ea0cb","head":{"label":"guardian:new-subs-model","ref":"new-subs-model","sha":"b8e1e7c6bb5f23998ecc0695b132582cd39ea0cb","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":28401521,"name":"membership-frontend","full_name":"guardian/membership-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/membership-frontend","description":"Bringing the Guardian to life through live events and meet-ups","fork":false,"url":"https://api.github.com/repos/guardian/membership-frontend","forks_url":"https://api.github.com/repos/guardian/membership-frontend/forks","keys_url":"https://api.github.com/repos/guardian/membership-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/membership-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/membership-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/membership-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/membership-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/membership-frontend/events","assignees_url":"https://api.github.com/repos/guardian/membership-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/membership-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/membership-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/membership-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/membership-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/membership-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/membership-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/membership-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/membership-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/membership-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/membership-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/membership-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/membership-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/membership-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/membership-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/membership-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/membership-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/membership-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/membership-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/membership-frontend/merges","archive_url":"https://api.github.com/repos/guardian/membership-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/membership-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/membership-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/membership-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/membership-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/membership-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/membership-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/membership-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/membership-frontend/deployments","created_at":"2014-12-23T14:14:38Z","updated_at":"2016-10-11T08:54:01Z","pushed_at":"2016-10-14T08:58:48Z","git_url":"git://github.com/guardian/membership-frontend.git","ssh_url":"git@github.com:guardian/membership-frontend.git","clone_url":"https://github.com/guardian/membership-frontend.git","svn_url":"https://github.com/guardian/membership-frontend","homepage":"https://membership.theguardian.com/","size":49480,"stargazers_count":28,"watchers_count":28,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":5,"forks":16,"open_issues":5,"watchers":28,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"ef2b714b688b720ef10eaff45b4d13ac919cfbad","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":28401521,"name":"membership-frontend","full_name":"guardian/membership-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/membership-frontend","description":"Bringing the Guardian to life through live events and meet-ups","fork":false,"url":"https://api.github.com/repos/guardian/membership-frontend","forks_url":"https://api.github.com/repos/guardian/membership-frontend/forks","keys_url":"https://api.github.com/repos/guardian/membership-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/membership-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/membership-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/membership-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/membership-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/membership-frontend/events","assignees_url":"https://api.github.com/repos/guardian/membership-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/membership-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/membership-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/membership-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/membership-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/membership-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/membership-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/membership-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/membership-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/membership-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/membership-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/membership-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/membership-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/membership-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/membership-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/membership-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/membership-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/membership-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/membership-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/membership-frontend/merges","archive_url":"https://api.github.com/repos/guardian/membership-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/membership-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/membership-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/membership-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/membership-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/membership-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/membership-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/membership-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/membership-frontend/deployments","created_at":"2014-12-23T14:14:38Z","updated_at":"2016-10-11T08:54:01Z","pushed_at":"2016-10-14T08:58:48Z","git_url":"git://github.com/guardian/membership-frontend.git","ssh_url":"git@github.com:guardian/membership-frontend.git","clone_url":"https://github.com/guardian/membership-frontend.git","svn_url":"https://github.com/guardian/membership-frontend","homepage":"https://membership.theguardian.com/","size":49480,"stargazers_count":28,"watchers_count":28,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":5,"forks":16,"open_issues":5,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332"},"html":{"href":"https://github.com/guardian/membership-frontend/pull/1332"},"issue":{"href":"https://api.github.com/repos/guardian/membership-frontend/issues/1332"},"comments":{"href":"https://api.github.com/repos/guardian/membership-frontend/issues/1332/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1332/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/membership-frontend/statuses/b8e1e7c6bb5f23998ecc0695b132582cd39ea0cb"}}}}
{"actor":{"display_login":"johnduffell"}}