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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Used to enable or disable email sending for messages that use this
-- configuration set in the current Amazon Web Services Region.
--
-- /See:/ 'newSendingOptions' smart constructor.
data SendingOptions = SendingOptions'
  { -- | If @true@, email sending is enabled for the configuration set. If
    -- @false@, email sending is disabled for the configuration set.
    SendingOptions -> Maybe Bool
sendingEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (SendingOptions -> SendingOptions -> Bool
(SendingOptions -> SendingOptions -> Bool)
-> (SendingOptions -> SendingOptions -> Bool) -> Eq SendingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendingOptions -> SendingOptions -> Bool
$c/= :: SendingOptions -> SendingOptions -> Bool
== :: SendingOptions -> SendingOptions -> Bool
$c== :: SendingOptions -> SendingOptions -> Bool
Prelude.Eq, ReadPrec [SendingOptions]
ReadPrec SendingOptions
Int -> ReadS SendingOptions
ReadS [SendingOptions]
(Int -> ReadS SendingOptions)
-> ReadS [SendingOptions]
-> ReadPrec SendingOptions
-> ReadPrec [SendingOptions]
-> Read SendingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendingOptions]
$creadListPrec :: ReadPrec [SendingOptions]
readPrec :: ReadPrec SendingOptions
$creadPrec :: ReadPrec SendingOptions
readList :: ReadS [SendingOptions]
$creadList :: ReadS [SendingOptions]
readsPrec :: Int -> ReadS SendingOptions
$creadsPrec :: Int -> ReadS SendingOptions
Prelude.Read, Int -> SendingOptions -> ShowS
[SendingOptions] -> ShowS
SendingOptions -> String
(Int -> SendingOptions -> ShowS)
-> (SendingOptions -> String)
-> ([SendingOptions] -> ShowS)
-> Show SendingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendingOptions] -> ShowS
$cshowList :: [SendingOptions] -> ShowS
show :: SendingOptions -> String
$cshow :: SendingOptions -> String
showsPrec :: Int -> SendingOptions -> ShowS
$cshowsPrec :: Int -> SendingOptions -> ShowS
Prelude.Show, (forall x. SendingOptions -> Rep SendingOptions x)
-> (forall x. Rep SendingOptions x -> SendingOptions)
-> Generic SendingOptions
forall x. Rep SendingOptions x -> SendingOptions
forall x. SendingOptions -> Rep SendingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendingOptions x -> SendingOptions
$cfrom :: forall x. SendingOptions -> Rep SendingOptions x
Prelude.Generic)

-- |
-- Create a value of 'SendingOptions' 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:
--
-- 'sendingEnabled', 'sendingOptions_sendingEnabled' - If @true@, email sending is enabled for the configuration set. If
-- @false@, email sending is disabled for the configuration set.
newSendingOptions ::
  SendingOptions
newSendingOptions :: SendingOptions
newSendingOptions =
  SendingOptions' :: Maybe Bool -> SendingOptions
SendingOptions' {$sel:sendingEnabled:SendingOptions' :: Maybe Bool
sendingEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | If @true@, email sending is enabled for the configuration set. If
-- @false@, email sending is disabled for the configuration set.
sendingOptions_sendingEnabled :: Lens.Lens' SendingOptions (Prelude.Maybe Prelude.Bool)
sendingOptions_sendingEnabled :: (Maybe Bool -> f (Maybe Bool))
-> SendingOptions -> f SendingOptions
sendingOptions_sendingEnabled = (SendingOptions -> Maybe Bool)
-> (SendingOptions -> Maybe Bool -> SendingOptions)
-> Lens SendingOptions SendingOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendingOptions' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:SendingOptions' :: SendingOptions -> Maybe Bool
sendingEnabled} -> Maybe Bool
sendingEnabled) (\s :: SendingOptions
s@SendingOptions' {} Maybe Bool
a -> SendingOptions
s {$sel:sendingEnabled:SendingOptions' :: Maybe Bool
sendingEnabled = Maybe Bool
a} :: SendingOptions)

instance Core.FromJSON SendingOptions where
  parseJSON :: Value -> Parser SendingOptions
parseJSON =
    String
-> (Object -> Parser SendingOptions)
-> Value
-> Parser SendingOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SendingOptions"
      ( \Object
x ->
          Maybe Bool -> SendingOptions
SendingOptions'
            (Maybe Bool -> SendingOptions)
-> Parser (Maybe Bool) -> Parser SendingOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SendingEnabled")
      )

instance Prelude.Hashable SendingOptions

instance Prelude.NFData SendingOptions

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