{-# 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-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.SuppressionOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SuppressionOptions -> SuppressionOptions -> Bool)
-> (SuppressionOptions -> SuppressionOptions -> Bool)
-> Eq SuppressionOptions
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]
(Int -> ReadS SuppressionOptions)
-> ReadS [SuppressionOptions]
-> ReadPrec SuppressionOptions
-> ReadPrec [SuppressionOptions]
-> Read 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
(Int -> SuppressionOptions -> ShowS)
-> (SuppressionOptions -> String)
-> ([SuppressionOptions] -> ShowS)
-> Show SuppressionOptions
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. SuppressionOptions -> Rep SuppressionOptions x)
-> (forall x. Rep SuppressionOptions x -> SuppressionOptions)
-> Generic SuppressionOptions
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' :: Maybe [SuppressionListReason] -> SuppressionOptions
SuppressionOptions'
    { $sel:suppressedReasons:SuppressionOptions' :: Maybe [SuppressionListReason]
suppressedReasons =
        Maybe [SuppressionListReason]
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 :: (Maybe [SuppressionListReason]
 -> f (Maybe [SuppressionListReason]))
-> SuppressionOptions -> f SuppressionOptions
suppressionOptions_suppressedReasons = (SuppressionOptions -> Maybe [SuppressionListReason])
-> (SuppressionOptions
    -> Maybe [SuppressionListReason] -> SuppressionOptions)
-> Lens
     SuppressionOptions
     SuppressionOptions
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
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) ((Maybe [SuppressionListReason]
  -> f (Maybe [SuppressionListReason]))
 -> SuppressionOptions -> f SuppressionOptions)
-> ((Maybe [SuppressionListReason]
     -> f (Maybe [SuppressionListReason]))
    -> Maybe [SuppressionListReason]
    -> f (Maybe [SuppressionListReason]))
-> (Maybe [SuppressionListReason]
    -> f (Maybe [SuppressionListReason]))
-> SuppressionOptions
-> f SuppressionOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
-> Iso
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
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 AnIso
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable SuppressionOptions

instance Prelude.NFData SuppressionOptions

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