From 6f8966a408ef3d6e52abb71298b8d4e7b7bb3187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Honor=C3=A9?= Date: Wed, 28 Aug 2024 12:08:01 +0100 Subject: [PATCH] NotificationHandler update for Membership2023 --- .../handlers/NotificationHandler.scala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala b/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala index 854096c1..e1c38983 100644 --- a/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala +++ b/lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala @@ -281,8 +281,22 @@ object NotificationHandler extends CohortHandler { cohortSpec: CohortSpec, contact: SalesforceContact ): Either[NotificationHandlerFailure, SalesforceAddress] = { + def targetAddressMembership2023( + contact: SalesforceContact + ): Either[NotificationHandlerFailure, SalesforceAddress] = { + (for { + billingAddress <- requiredField(contact.OtherAddress, "Contact.OtherAddress") + _ <- requiredField(billingAddress.street, "Contact.OtherAddress.street") + _ <- requiredField(billingAddress.city, "Contact.OtherAddress.city") + } yield billingAddress).left.flatMap(_ => + Right(SalesforceAddress(Some(""), Some(""), Some(""), Some(""), Some(""))) + ) + } + MigrationType(cohortSpec) match { - case DigiSubs2023 => Right(SalesforceAddress(Some(""), Some(""), Some(""), Some(""), Some(""))) + case DigiSubs2023 => Right(SalesforceAddress(Some(""), Some(""), Some(""), Some(""), Some(""))) + case Membership2023Monthlies => targetAddressMembership2023(contact) + case Membership2023Annuals => targetAddressMembership2023(contact) case _ => (for { billingAddress <- requiredField(contact.OtherAddress, "Contact.OtherAddress")