diff --git a/lib/inmana/supplies/expiration_notification.ex b/lib/inmana/supplies/expiration_notification.ex new file mode 100644 index 0000000..004dde0 --- /dev/null +++ b/lib/inmana/supplies/expiration_notification.ex @@ -0,0 +1,14 @@ +defmodule Inmana.Supplies.ExpirationNotification do + alias Inmana.Mailer + alias Inmana.Supplies.{ExpirationEmail, GetByExpiration} + + def send do + data = GetByExpiration.call() + + Enum.each(data, fn {to_email, supplies} -> + to_email + |> ExpirationEmail.create(supplies) + |> Mailer.deliver_later!() + end) + end +end