{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Network.Mail.Newsletter.Class where

import qualified Data.Aeson as JS
import           Data.Machine
import           Network.Mail.Mime

class Newsletter p where
  -- | Adds users with specific data to the Newsletter recipient list.
  subscribe :: ProcessT p (Address, JS.Value) ()
  -- | Removes users from the Newsletter recipient list.
  unsubscribe :: ProcessT p Address ()
  -- | Gets a list of subscribers and all their associated data.
  subscribers :: SourceT p (Address, JS.Value)
  -- | Send an email to the mailing list.
  --   Takes as From Address for correctness.
  sendEmail :: (Address -> Mail) -> p ()
  -- | Sends a subscription email to just the person signing up.
  --   Takes the From Address to create the mail for correctness.
  sendSubscribe :: Address -> (Address -> Mail) -> p ()