{-# 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.TopicFilter
-- 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.TopicFilter 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

-- | Used for filtering by a specific topic preference.
--
-- /See:/ 'newTopicFilter' smart constructor.
data TopicFilter = TopicFilter'
  { -- | The name of a topic on which you wish to apply the filter.
    TopicFilter -> Maybe Text
topicName :: Prelude.Maybe Prelude.Text,
    -- | Notes that the default subscription status should be applied to a
    -- contact because the contact has not noted their preference for
    -- subscribing to a topic.
    TopicFilter -> Maybe Bool
useDefaultIfPreferenceUnavailable :: Prelude.Maybe Prelude.Bool
  }
  deriving (TopicFilter -> TopicFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopicFilter -> TopicFilter -> Bool
$c/= :: TopicFilter -> TopicFilter -> Bool
== :: TopicFilter -> TopicFilter -> Bool
$c== :: TopicFilter -> TopicFilter -> Bool
Prelude.Eq, ReadPrec [TopicFilter]
ReadPrec TopicFilter
Int -> ReadS TopicFilter
ReadS [TopicFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopicFilter]
$creadListPrec :: ReadPrec [TopicFilter]
readPrec :: ReadPrec TopicFilter
$creadPrec :: ReadPrec TopicFilter
readList :: ReadS [TopicFilter]
$creadList :: ReadS [TopicFilter]
readsPrec :: Int -> ReadS TopicFilter
$creadsPrec :: Int -> ReadS TopicFilter
Prelude.Read, Int -> TopicFilter -> ShowS
[TopicFilter] -> ShowS
TopicFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopicFilter] -> ShowS
$cshowList :: [TopicFilter] -> ShowS
show :: TopicFilter -> String
$cshow :: TopicFilter -> String
showsPrec :: Int -> TopicFilter -> ShowS
$cshowsPrec :: Int -> TopicFilter -> ShowS
Prelude.Show, forall x. Rep TopicFilter x -> TopicFilter
forall x. TopicFilter -> Rep TopicFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TopicFilter x -> TopicFilter
$cfrom :: forall x. TopicFilter -> Rep TopicFilter x
Prelude.Generic)

-- |
-- Create a value of 'TopicFilter' 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', 'topicFilter_topicName' - The name of a topic on which you wish to apply the filter.
--
-- 'useDefaultIfPreferenceUnavailable', 'topicFilter_useDefaultIfPreferenceUnavailable' - Notes that the default subscription status should be applied to a
-- contact because the contact has not noted their preference for
-- subscribing to a topic.
newTopicFilter ::
  TopicFilter
newTopicFilter :: TopicFilter
newTopicFilter =
  TopicFilter'
    { $sel:topicName:TopicFilter' :: Maybe Text
topicName = forall a. Maybe a
Prelude.Nothing,
      $sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: Maybe Bool
useDefaultIfPreferenceUnavailable = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a topic on which you wish to apply the filter.
topicFilter_topicName :: Lens.Lens' TopicFilter (Prelude.Maybe Prelude.Text)
topicFilter_topicName :: Lens' TopicFilter (Maybe Text)
topicFilter_topicName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicFilter' {Maybe Text
topicName :: Maybe Text
$sel:topicName:TopicFilter' :: TopicFilter -> Maybe Text
topicName} -> Maybe Text
topicName) (\s :: TopicFilter
s@TopicFilter' {} Maybe Text
a -> TopicFilter
s {$sel:topicName:TopicFilter' :: Maybe Text
topicName = Maybe Text
a} :: TopicFilter)

-- | Notes that the default subscription status should be applied to a
-- contact because the contact has not noted their preference for
-- subscribing to a topic.
topicFilter_useDefaultIfPreferenceUnavailable :: Lens.Lens' TopicFilter (Prelude.Maybe Prelude.Bool)
topicFilter_useDefaultIfPreferenceUnavailable :: Lens' TopicFilter (Maybe Bool)
topicFilter_useDefaultIfPreferenceUnavailable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicFilter' {Maybe Bool
useDefaultIfPreferenceUnavailable :: Maybe Bool
$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: TopicFilter -> Maybe Bool
useDefaultIfPreferenceUnavailable} -> Maybe Bool
useDefaultIfPreferenceUnavailable) (\s :: TopicFilter
s@TopicFilter' {} Maybe Bool
a -> TopicFilter
s {$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: Maybe Bool
useDefaultIfPreferenceUnavailable = Maybe Bool
a} :: TopicFilter)

instance Prelude.Hashable TopicFilter where
  hashWithSalt :: Int -> TopicFilter -> Int
hashWithSalt Int
_salt TopicFilter' {Maybe Bool
Maybe Text
useDefaultIfPreferenceUnavailable :: Maybe Bool
topicName :: Maybe Text
$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: TopicFilter -> Maybe Bool
$sel:topicName:TopicFilter' :: TopicFilter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
topicName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
useDefaultIfPreferenceUnavailable

instance Prelude.NFData TopicFilter where
  rnf :: TopicFilter -> ()
rnf TopicFilter' {Maybe Bool
Maybe Text
useDefaultIfPreferenceUnavailable :: Maybe Bool
topicName :: Maybe Text
$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: TopicFilter -> Maybe Bool
$sel:topicName:TopicFilter' :: TopicFilter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
topicName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
useDefaultIfPreferenceUnavailable

instance Data.ToJSON TopicFilter where
  toJSON :: TopicFilter -> Value
toJSON TopicFilter' {Maybe Bool
Maybe Text
useDefaultIfPreferenceUnavailable :: Maybe Bool
topicName :: Maybe Text
$sel:useDefaultIfPreferenceUnavailable:TopicFilter' :: TopicFilter -> Maybe Bool
$sel:topicName:TopicFilter' :: TopicFilter -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TopicName" 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 Text
topicName,
            (Key
"UseDefaultIfPreferenceUnavailable" 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 Bool
useDefaultIfPreferenceUnavailable
          ]
      )