Skip to content

Commit

Permalink
chore: mock a send email operation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Oct 21, 2022
1 parent 487ba31 commit cac1d72
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions alerts-manager/src/main/scala/dev/atedeg/mdm/api/Handlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def handlePhOutOfRangeEvent[M[_]: Monad: LiftIO: CanRaise[String]](event: PhOutO
r <- validate(event)
message = managePhAlarm(PhFailure(LocalTime.now(), r.ph, r.device))
_ <- IO.println("Sending an e-mail to the admin...").liftIO[M]
_ <- IO.println(message).liftIO[M]
_ <- sendEmail(message)
yield ()

def handlePackagingMachineFailureEvent[M[_]: Monad: LiftIO: CanRaise[String]](
Expand All @@ -54,15 +54,15 @@ def handlePackagingMachineFailureEvent[M[_]: Monad: LiftIO: CanRaise[String]](
r <- validate(event)
message = managePackagingMachineFailure(PackagingMachineFailure(LocalTime.now(), r.batchID, r.cutterTemperature))
_ <- IO.println("Sending an e-mail to the admin...").liftIO[M]
_ <- IO.println(message).liftIO[M]
_ <- sendEmail(message)
yield ()

def handlePackageDamagedEvent[M[_]: Monad: LiftIO: CanRaise[String]](event: PackageDamagedDTO): M[Unit] =
for
r <- validate(event)
message = managePackageDamage(PackageDamageFailure(LocalTime.now(), r.batchID, r.cutterTemperature))
_ <- IO.println("Sending an e-mail to the admin...").liftIO[M]
_ <- IO.println(message).liftIO[M]
_ <- sendEmail(message)
yield ()

def handlePackagingMachineMaintenanceEvent[M[_]: Monad: LiftIO: CanRaise[String]](
Expand All @@ -72,5 +72,7 @@ def handlePackagingMachineMaintenanceEvent[M[_]: Monad: LiftIO: CanRaise[String]
r <- validate(event)
message = managePackagingMachineMaintenance(r.maintenance)
_ <- IO.println("Sending an e-mail to the admin...").liftIO[M]
_ <- IO.println(message).liftIO[M]
_ <- sendEmail(message)
yield ()

private def sendEmail[M[_]: Monad: LiftIO](content: String): M[Unit] = ???

0 comments on commit cac1d72

Please sign in to comment.