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

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

-- | An object used to specify a list or topic to which an email belongs,
-- which will be used when a contact chooses to unsubscribe.
--
-- /See:/ 'newListManagementOptions' smart constructor.
data ListManagementOptions = ListManagementOptions'
  { -- | The name of the topic.
    ListManagementOptions -> Maybe Text
topicName :: Prelude.Maybe Prelude.Text,
    -- | The name of the contact list.
    ListManagementOptions -> Text
contactListName :: Prelude.Text
  }
  deriving (ListManagementOptions -> ListManagementOptions -> Bool
(ListManagementOptions -> ListManagementOptions -> Bool)
-> (ListManagementOptions -> ListManagementOptions -> Bool)
-> Eq ListManagementOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListManagementOptions -> ListManagementOptions -> Bool
$c/= :: ListManagementOptions -> ListManagementOptions -> Bool
== :: ListManagementOptions -> ListManagementOptions -> Bool
$c== :: ListManagementOptions -> ListManagementOptions -> Bool
Prelude.Eq, ReadPrec [ListManagementOptions]
ReadPrec ListManagementOptions
Int -> ReadS ListManagementOptions
ReadS [ListManagementOptions]
(Int -> ReadS ListManagementOptions)
-> ReadS [ListManagementOptions]
-> ReadPrec ListManagementOptions
-> ReadPrec [ListManagementOptions]
-> Read ListManagementOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListManagementOptions]
$creadListPrec :: ReadPrec [ListManagementOptions]
readPrec :: ReadPrec ListManagementOptions
$creadPrec :: ReadPrec ListManagementOptions
readList :: ReadS [ListManagementOptions]
$creadList :: ReadS [ListManagementOptions]
readsPrec :: Int -> ReadS ListManagementOptions
$creadsPrec :: Int -> ReadS ListManagementOptions
Prelude.Read, Int -> ListManagementOptions -> ShowS
[ListManagementOptions] -> ShowS
ListManagementOptions -> String
(Int -> ListManagementOptions -> ShowS)
-> (ListManagementOptions -> String)
-> ([ListManagementOptions] -> ShowS)
-> Show ListManagementOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListManagementOptions] -> ShowS
$cshowList :: [ListManagementOptions] -> ShowS
show :: ListManagementOptions -> String
$cshow :: ListManagementOptions -> String
showsPrec :: Int -> ListManagementOptions -> ShowS
$cshowsPrec :: Int -> ListManagementOptions -> ShowS
Prelude.Show, (forall x. ListManagementOptions -> Rep ListManagementOptions x)
-> (forall x. Rep ListManagementOptions x -> ListManagementOptions)
-> Generic ListManagementOptions
forall x. Rep ListManagementOptions x -> ListManagementOptions
forall x. ListManagementOptions -> Rep ListManagementOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListManagementOptions x -> ListManagementOptions
$cfrom :: forall x. ListManagementOptions -> Rep ListManagementOptions x
Prelude.Generic)

-- |
-- Create a value of 'ListManagementOptions' 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:
--
-- 'topicName', 'listManagementOptions_topicName' - The name of the topic.
--
-- 'contactListName', 'listManagementOptions_contactListName' - The name of the contact list.
newListManagementOptions ::
  -- | 'contactListName'
  Prelude.Text ->
  ListManagementOptions
newListManagementOptions :: Text -> ListManagementOptions
newListManagementOptions Text
pContactListName_ =
  ListManagementOptions' :: Maybe Text -> Text -> ListManagementOptions
ListManagementOptions'
    { $sel:topicName:ListManagementOptions' :: Maybe Text
topicName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contactListName:ListManagementOptions' :: Text
contactListName = Text
pContactListName_
    }

-- | The name of the topic.
listManagementOptions_topicName :: Lens.Lens' ListManagementOptions (Prelude.Maybe Prelude.Text)
listManagementOptions_topicName :: (Maybe Text -> f (Maybe Text))
-> ListManagementOptions -> f ListManagementOptions
listManagementOptions_topicName = (ListManagementOptions -> Maybe Text)
-> (ListManagementOptions -> Maybe Text -> ListManagementOptions)
-> Lens
     ListManagementOptions
     ListManagementOptions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListManagementOptions' {Maybe Text
topicName :: Maybe Text
$sel:topicName:ListManagementOptions' :: ListManagementOptions -> Maybe Text
topicName} -> Maybe Text
topicName) (\s :: ListManagementOptions
s@ListManagementOptions' {} Maybe Text
a -> ListManagementOptions
s {$sel:topicName:ListManagementOptions' :: Maybe Text
topicName = Maybe Text
a} :: ListManagementOptions)

-- | The name of the contact list.
listManagementOptions_contactListName :: Lens.Lens' ListManagementOptions Prelude.Text
listManagementOptions_contactListName :: (Text -> f Text)
-> ListManagementOptions -> f ListManagementOptions
listManagementOptions_contactListName = (ListManagementOptions -> Text)
-> (ListManagementOptions -> Text -> ListManagementOptions)
-> Lens ListManagementOptions ListManagementOptions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListManagementOptions' {Text
contactListName :: Text
$sel:contactListName:ListManagementOptions' :: ListManagementOptions -> Text
contactListName} -> Text
contactListName) (\s :: ListManagementOptions
s@ListManagementOptions' {} Text
a -> ListManagementOptions
s {$sel:contactListName:ListManagementOptions' :: Text
contactListName = Text
a} :: ListManagementOptions)

instance Prelude.Hashable ListManagementOptions

instance Prelude.NFData ListManagementOptions

instance Core.ToJSON ListManagementOptions where
  toJSON :: ListManagementOptions -> Value
toJSON ListManagementOptions' {Maybe Text
Text
contactListName :: Text
topicName :: Maybe Text
$sel:contactListName:ListManagementOptions' :: ListManagementOptions -> Text
$sel:topicName:ListManagementOptions' :: ListManagementOptions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TopicName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
topicName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContactListName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactListName)
          ]
      )