Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLS-11277 : Changed email to EmailAddress #665

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class SubmissionController @Inject() (
form <- cache.readOption[SubmitterInfo].map { osi =>
(osi.map(_.fullName), osi.map(_.contactPhone), osi.map(_.email))
.mapN { (name, phone, email) =>
submitterInfoForm.bind(Map("fullName" -> name, "contactPhone" -> phone, "email" -> email))
submitterInfoForm.bind(Map("fullName" -> name, "contactPhone" -> phone, "email" -> email.value))
}
.getOrElse(submitterInfoForm)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SubscriptionController @Inject() (

private def makeSubEmail(subscriberContact: SubscriberContact, cbcId: CBCId): Email =
Email(
List(subscriberContact.email),
List(subscriberContact.email.value),
"cbcr_subscription",
Map("f_name" -> subscriberContact.firstName, "s_name" -> subscriberContact.lastName, "cbcrId" -> cbcId.value)
)
Expand Down Expand Up @@ -157,7 +157,7 @@ class SubscriptionController @Inject() (
Map(
"firstName" -> subData.names.name1,
"lastName" -> subData.names.name2,
"email" -> subData.contact.email,
"email" -> subData.contact.email.value,
"phoneNumber" -> subData.contact.phoneNumber
)
)
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/cbcrfrontend/model/ETMPGetResponse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object PhoneNumber {
}
}

case class ContactDetails(email: String, phoneNumber: String)
case class ContactDetails(email: EmailAddress, phoneNumber: String)

object ContactDetails {
implicit val emailFormat: Format[EmailAddress] =
Expand Down
6 changes: 4 additions & 2 deletions app/uk/gov/hmrc/cbcrfrontend/model/SubmitterInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ package uk.gov.hmrc.cbcrfrontend.model

import play.api.libs.json._
import uk.gov.hmrc.auth.core.AffinityGroup
import uk.gov.hmrc.cbcrfrontend.emailaddress.EmailAddress
import uk.gov.hmrc.cbcrfrontend.emailaddress.PlayJsonFormats._

case class SubmitterInfo(
fullName: String,
agencyBusinessName: Option[AgencyBusinessName],
contactPhone: String,
email: String,
email: EmailAddress,
affinityGroup: Option[AffinityGroup]
)

Expand All @@ -35,7 +37,7 @@ object SubmitterInfo {
fullName <- m.get("fullName").flatMap(_.asOpt[String])
abn <- m.get("agencyBusinessName").map(_.asOpt[String])
cp <- m.get("contactPhone").flatMap(_.asOpt[String])
email <- m.get("email").flatMap(_.asOpt[String])
email <- m.get("email").flatMap(_.asOpt[EmailAddress])
ag <- m.get("affinityGroup").map(_.asOpt[AffinityGroup])
} yield JsSuccess(SubmitterInfo(fullName, abn.map(AgencyBusinessName(_)), cp, email, ag))
result.getOrElse(JsError(s"Unable to serialise $json as a SubmitterInfo"))
Expand Down