{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SESV2.Types.SuppressedDestination
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SESV2.Types.SuppressedDestination where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.SuppressedDestinationAttributes
import Amazonka.SESV2.Types.SuppressionListReason

-- | An object that contains information about an email address that is on
-- the suppression list for your account.
--
-- /See:/ 'newSuppressedDestination' smart constructor.
data SuppressedDestination = SuppressedDestination'
  { -- | An optional value that can contain additional information about the
    -- reasons that the address was added to the suppression list for your
    -- account.
    SuppressedDestination -> Maybe SuppressedDestinationAttributes
attributes :: Prelude.Maybe SuppressedDestinationAttributes,
    -- | The email address that is on the suppression list for your account.
    SuppressedDestination -> Text
emailAddress :: Prelude.Text,
    -- | The reason that the address was added to the suppression list for your
    -- account.
    SuppressedDestination -> SuppressionListReason
reason :: SuppressionListReason,
    -- | The date and time when the suppressed destination was last updated,
    -- shown in Unix time format.
    SuppressedDestination -> POSIX
lastUpdateTime :: Core.POSIX
  }
  deriving (SuppressedDestination -> SuppressedDestination -> Bool
(SuppressedDestination -> SuppressedDestination -> Bool)
-> (SuppressedDestination -> SuppressedDestination -> Bool)
-> Eq SuppressedDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuppressedDestination -> SuppressedDestination -> Bool
$c/= :: SuppressedDestination -> SuppressedDestination -> Bool
== :: SuppressedDestination -> SuppressedDestination -> Bool
$c== :: SuppressedDestination -> SuppressedDestination -> Bool
Prelude.Eq, ReadPrec [SuppressedDestination]
ReadPrec SuppressedDestination
Int -> ReadS SuppressedDestination
ReadS [SuppressedDestination]
(Int -> ReadS SuppressedDestination)
-> ReadS [SuppressedDestination]
-> ReadPrec SuppressedDestination
-> ReadPrec [SuppressedDestination]
-> Read SuppressedDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuppressedDestination]
$creadListPrec :: ReadPrec [SuppressedDestination]
readPrec :: ReadPrec SuppressedDestination
$creadPrec :: ReadPrec SuppressedDestination
readList :: ReadS [SuppressedDestination]
$creadList :: ReadS [SuppressedDestination]
readsPrec :: Int -> ReadS SuppressedDestination
$creadsPrec :: Int -> ReadS SuppressedDestination
Prelude.Read, Int -> SuppressedDestination -> ShowS
[SuppressedDestination] -> ShowS
SuppressedDestination -> String
(Int -> SuppressedDestination -> ShowS)
-> (SuppressedDestination -> String)
-> ([SuppressedDestination] -> ShowS)
-> Show SuppressedDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuppressedDestination] -> ShowS
$cshowList :: [SuppressedDestination] -> ShowS
show :: SuppressedDestination -> String
$cshow :: SuppressedDestination -> String
showsPrec :: Int -> SuppressedDestination -> ShowS
$cshowsPrec :: Int -> SuppressedDestination -> ShowS
Prelude.Show, (forall x. SuppressedDestination -> Rep SuppressedDestination x)
-> (forall x. Rep SuppressedDestination x -> SuppressedDestination)
-> Generic SuppressedDestination
forall x. Rep SuppressedDestination x -> SuppressedDestination
forall x. SuppressedDestination -> Rep SuppressedDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuppressedDestination x -> SuppressedDestination
$cfrom :: forall x. SuppressedDestination -> Rep SuppressedDestination x
Prelude.Generic)

-- |
-- Create a value of 'SuppressedDestination' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'attributes', 'suppressedDestination_attributes' - An optional value that can contain additional information about the
-- reasons that the address was added to the suppression list for your
-- account.
--
-- 'emailAddress', 'suppressedDestination_emailAddress' - The email address that is on the suppression list for your account.
--
-- 'reason', 'suppressedDestination_reason' - The reason that the address was added to the suppression list for your
-- account.
--
-- 'lastUpdateTime', 'suppressedDestination_lastUpdateTime' - The date and time when the suppressed destination was last updated,
-- shown in Unix time format.
newSuppressedDestination ::
  -- | 'emailAddress'
  Prelude.Text ->
  -- | 'reason'
  SuppressionListReason ->
  -- | 'lastUpdateTime'
  Prelude.UTCTime ->
  SuppressedDestination
newSuppressedDestination :: Text -> SuppressionListReason -> UTCTime -> SuppressedDestination
newSuppressedDestination
  Text
pEmailAddress_
  SuppressionListReason
pReason_
  UTCTime
pLastUpdateTime_ =
    SuppressedDestination' :: Maybe SuppressedDestinationAttributes
-> Text -> SuppressionListReason -> POSIX -> SuppressedDestination
SuppressedDestination'
      { $sel:attributes:SuppressedDestination' :: Maybe SuppressedDestinationAttributes
attributes =
          Maybe SuppressedDestinationAttributes
forall a. Maybe a
Prelude.Nothing,
        $sel:emailAddress:SuppressedDestination' :: Text
emailAddress = Text
pEmailAddress_,
        $sel:reason:SuppressedDestination' :: SuppressionListReason
reason = SuppressionListReason
pReason_,
        $sel:lastUpdateTime:SuppressedDestination' :: POSIX
lastUpdateTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastUpdateTime_
      }

-- | An optional value that can contain additional information about the
-- reasons that the address was added to the suppression list for your
-- account.
suppressedDestination_attributes :: Lens.Lens' SuppressedDestination (Prelude.Maybe SuppressedDestinationAttributes)
suppressedDestination_attributes :: (Maybe SuppressedDestinationAttributes
 -> f (Maybe SuppressedDestinationAttributes))
-> SuppressedDestination -> f SuppressedDestination
suppressedDestination_attributes = (SuppressedDestination -> Maybe SuppressedDestinationAttributes)
-> (SuppressedDestination
    -> Maybe SuppressedDestinationAttributes -> SuppressedDestination)
-> Lens
     SuppressedDestination
     SuppressedDestination
     (Maybe SuppressedDestinationAttributes)
     (Maybe SuppressedDestinationAttributes)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuppressedDestination' {Maybe SuppressedDestinationAttributes
attributes :: Maybe SuppressedDestinationAttributes
$sel:attributes:SuppressedDestination' :: SuppressedDestination -> Maybe SuppressedDestinationAttributes
attributes} -> Maybe SuppressedDestinationAttributes
attributes) (\s :: SuppressedDestination
s@SuppressedDestination' {} Maybe SuppressedDestinationAttributes
a -> SuppressedDestination
s {$sel:attributes:SuppressedDestination' :: Maybe SuppressedDestinationAttributes
attributes = Maybe SuppressedDestinationAttributes
a} :: SuppressedDestination)

-- | The email address that is on the suppression list for your account.
suppressedDestination_emailAddress :: Lens.Lens' SuppressedDestination Prelude.Text
suppressedDestination_emailAddress :: (Text -> f Text)
-> SuppressedDestination -> f SuppressedDestination
suppressedDestination_emailAddress = (SuppressedDestination -> Text)
-> (SuppressedDestination -> Text -> SuppressedDestination)
-> Lens SuppressedDestination SuppressedDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuppressedDestination' {Text
emailAddress :: Text
$sel:emailAddress:SuppressedDestination' :: SuppressedDestination -> Text
emailAddress} -> Text
emailAddress) (\s :: SuppressedDestination
s@SuppressedDestination' {} Text
a -> SuppressedDestination
s {$sel:emailAddress:SuppressedDestination' :: Text
emailAddress = Text
a} :: SuppressedDestination)

-- | The reason that the address was added to the suppression list for your
-- account.
suppressedDestination_reason :: Lens.Lens' SuppressedDestination SuppressionListReason
suppressedDestination_reason :: (SuppressionListReason -> f SuppressionListReason)
-> SuppressedDestination -> f SuppressedDestination
suppressedDestination_reason = (SuppressedDestination -> SuppressionListReason)
-> (SuppressedDestination
    -> SuppressionListReason -> SuppressedDestination)
-> Lens
     SuppressedDestination
     SuppressedDestination
     SuppressionListReason
     SuppressionListReason
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuppressedDestination' {SuppressionListReason
reason :: SuppressionListReason
$sel:reason:SuppressedDestination' :: SuppressedDestination -> SuppressionListReason
reason} -> SuppressionListReason
reason) (\s :: SuppressedDestination
s@SuppressedDestination' {} SuppressionListReason
a -> SuppressedDestination
s {$sel:reason:SuppressedDestination' :: SuppressionListReason
reason = SuppressionListReason
a} :: SuppressedDestination)

-- | The date and time when the suppressed destination was last updated,
-- shown in Unix time format.
suppressedDestination_lastUpdateTime :: Lens.Lens' SuppressedDestination Prelude.UTCTime
suppressedDestination_lastUpdateTime :: (UTCTime -> f UTCTime)
-> SuppressedDestination -> f SuppressedDestination
suppressedDestination_lastUpdateTime = (SuppressedDestination -> POSIX)
-> (SuppressedDestination -> POSIX -> SuppressedDestination)
-> Lens SuppressedDestination SuppressedDestination POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuppressedDestination' {POSIX
lastUpdateTime :: POSIX
$sel:lastUpdateTime:SuppressedDestination' :: SuppressedDestination -> POSIX
lastUpdateTime} -> POSIX
lastUpdateTime) (\s :: SuppressedDestination
s@SuppressedDestination' {} POSIX
a -> SuppressedDestination
s {$sel:lastUpdateTime:SuppressedDestination' :: POSIX
lastUpdateTime = POSIX
a} :: SuppressedDestination) ((POSIX -> f POSIX)
 -> SuppressedDestination -> f SuppressedDestination)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> SuppressedDestination
-> f SuppressedDestination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON SuppressedDestination where
  parseJSON :: Value -> Parser SuppressedDestination
parseJSON =
    String
-> (Object -> Parser SuppressedDestination)
-> Value
-> Parser SuppressedDestination
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SuppressedDestination"
      ( \Object
x ->
          Maybe SuppressedDestinationAttributes
-> Text -> SuppressionListReason -> POSIX -> SuppressedDestination
SuppressedDestination'
            (Maybe SuppressedDestinationAttributes
 -> Text -> SuppressionListReason -> POSIX -> SuppressedDestination)
-> Parser (Maybe SuppressedDestinationAttributes)
-> Parser
     (Text -> SuppressionListReason -> POSIX -> SuppressedDestination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SuppressedDestinationAttributes)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attributes")
            Parser
  (Text -> SuppressionListReason -> POSIX -> SuppressedDestination)
-> Parser Text
-> Parser (SuppressionListReason -> POSIX -> SuppressedDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EmailAddress")
            Parser (SuppressionListReason -> POSIX -> SuppressedDestination)
-> Parser SuppressionListReason
-> Parser (POSIX -> SuppressedDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser SuppressionListReason
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Reason")
            Parser (POSIX -> SuppressedDestination)
-> Parser POSIX -> Parser SuppressedDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LastUpdateTime")
      )

instance Prelude.Hashable SuppressedDestination

instance Prelude.NFData SuppressedDestination