{-# 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.SuppressionOptions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SESV2.Types.SuppressionOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.SuppressionListReason

-- | An object that contains information about the suppression list
-- preferences for your account.
--
-- /See:/ 'newSuppressionOptions' smart constructor.
data SuppressionOptions = SuppressionOptions'
  { -- | A list that contains the reasons that email addresses are automatically
    -- added to the suppression list for your account. This list can contain
    -- any or all of the following:
    --
    -- -   @COMPLAINT@ – Amazon SES adds an email address to the suppression
    --     list for your account when a message sent to that address results in
    --     a complaint.
    --
    -- -   @BOUNCE@ – Amazon SES adds an email address to the suppression list
    --     for your account when a message sent to that address results in a
    --     hard bounce.
    SuppressionOptions -> Maybe [SuppressionListReason]
suppressedReasons :: Prelude.Maybe [SuppressionListReason]
  }
  deriving (SuppressionOptions -> SuppressionOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuppressionOptions -> SuppressionOptions -> Bool
$c/= :: SuppressionOptions -> SuppressionOptions -> Bool
== :: SuppressionOptions -> SuppressionOptions -> Bool
$c== :: SuppressionOptions -> SuppressionOptions -> Bool
Prelude.Eq, ReadPrec [SuppressionOptions]
ReadPrec SuppressionOptions
Int -> ReadS SuppressionOptions
ReadS [SuppressionOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuppressionOptions]
$creadListPrec :: ReadPrec [SuppressionOptions]
readPrec :: ReadPrec SuppressionOptions
$creadPrec :: ReadPrec SuppressionOptions
readList :: ReadS [SuppressionOptions]
$creadList :: ReadS [SuppressionOptions]
readsPrec :: Int -> ReadS SuppressionOptions
$creadsPrec :: Int -> ReadS SuppressionOptions
Prelude.Read, Int -> SuppressionOptions -> ShowS
[SuppressionOptions] -> ShowS
SuppressionOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuppressionOptions] -> ShowS
$cshowList :: [SuppressionOptions] -> ShowS
show :: SuppressionOptions -> String
$cshow :: SuppressionOptions -> String
showsPrec :: Int -> SuppressionOptions -> ShowS
$cshowsPrec :: Int -> SuppressionOptions -> ShowS
Prelude.Show, forall x. Rep SuppressionOptions x -> SuppressionOptions
forall x. SuppressionOptions -> Rep SuppressionOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuppressionOptions x -> SuppressionOptions
$cfrom :: forall x. SuppressionOptions -> Rep SuppressionOptions x
Prelude.Generic)

-- |
-- Create a value of 'SuppressionOptions' 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:
--
-- 'suppressedReasons', 'suppressionOptions_suppressedReasons' - A list that contains the reasons that email addresses are automatically
-- added to the suppression list for your account. This list can contain
-- any or all of the following:
--
-- -   @COMPLAINT@ – Amazon SES adds an email address to the suppression
--     list for your account when a message sent to that address results in
--     a complaint.
--
-- -   @BOUNCE@ – Amazon SES adds an email address to the suppression list
--     for your account when a message sent to that address results in a
--     hard bounce.
newSuppressionOptions ::
  SuppressionOptions
newSuppressionOptions :: SuppressionOptions
newSuppressionOptions =
  SuppressionOptions'
    { $sel:suppressedReasons:SuppressionOptions' :: Maybe [SuppressionListReason]
suppressedReasons =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A list that contains the reasons that email addresses are automatically
-- added to the suppression list for your account. This list can contain
-- any or all of the following:
--
-- -   @COMPLAINT@ – Amazon SES adds an email address to the suppression
--     list for your account when a message sent to that address results in
--     a complaint.
--
-- -   @BOUNCE@ – Amazon SES adds an email address to the suppression list
--     for your account when a message sent to that address results in a
--     hard bounce.
suppressionOptions_suppressedReasons :: Lens.Lens' SuppressionOptions (Prelude.Maybe [SuppressionListReason])
suppressionOptions_suppressedReasons :: Lens' SuppressionOptions (Maybe [SuppressionListReason])
suppressionOptions_suppressedReasons = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuppressionOptions' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:SuppressionOptions' :: SuppressionOptions -> Maybe [SuppressionListReason]
suppressedReasons} -> Maybe [SuppressionListReason]
suppressedReasons) (\s :: SuppressionOptions
s@SuppressionOptions' {} Maybe [SuppressionListReason]
a -> SuppressionOptions
s {$sel:suppressedReasons:SuppressionOptions' :: Maybe [SuppressionListReason]
suppressedReasons = Maybe [SuppressionListReason]
a} :: SuppressionOptions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SuppressionOptions where
  parseJSON :: Value -> Parser SuppressionOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SuppressionOptions"
      ( \Object
x ->
          Maybe [SuppressionListReason] -> SuppressionOptions
SuppressionOptions'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SuppressedReasons"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable SuppressionOptions where
  hashWithSalt :: Int -> SuppressionOptions -> Int
hashWithSalt Int
_salt SuppressionOptions' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:SuppressionOptions' :: SuppressionOptions -> Maybe [SuppressionListReason]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SuppressionListReason]
suppressedReasons

instance Prelude.NFData SuppressionOptions where
  rnf :: SuppressionOptions -> ()
rnf SuppressionOptions' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:SuppressionOptions' :: SuppressionOptions -> Maybe [SuppressionListReason]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [SuppressionListReason]
suppressedReasons

instance Data.ToJSON SuppressionOptions where
  toJSON :: SuppressionOptions -> Value
toJSON SuppressionOptions' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:SuppressionOptions' :: SuppressionOptions -> Maybe [SuppressionListReason]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SuppressedReasons" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [SuppressionListReason]
suppressedReasons
          ]
      )