in lambda/src/main/scala/pricemigrationengine/handlers/NotificationHandler.scala [96:122]
def sendNotification(cohortSpec: CohortSpec)(
cohortItem: CohortItem,
today: LocalDate
): ZIO[EmailSender with SalesforceClient with CohortTable with Logging with Zuora, Failure, Unit] = {
for {
_ <-
if (thereIsEnoughNotificationLeadTime(cohortSpec, today, cohortItem)) {
ZIO.succeed(())
} else {
ZIO.fail(
NotificationNotEnoughLeadTimeFailure(
s"[notification] The start date of item ${cohortItem.subscriptionName} (startDate: ${cohortItem.startDate}) is too close to today ${today}"
)
)
}
_ <- cohortItemRatePlansChecks(cohortSpec, cohortItem)
sfSubscription <-
SalesforceClient
.getSubscriptionByName(cohortItem.subscriptionName)
_ <-
if (sfSubscription.Status__c != Cancelled_Status) {
sendNotification(cohortSpec, cohortItem, sfSubscription)
} else {
putSubIntoCancelledStatus(cohortSpec, cohortItem, Some("Item has been cancelled in Zuora"))
}
} yield ()
}