{-# 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.SES.Types.TrackingOptions
-- 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.SES.Types.TrackingOptions 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

-- | A domain that is used to redirect email recipients to an Amazon
-- SES-operated domain. This domain captures open and click events
-- generated by Amazon SES emails.
--
-- For more information, see
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/configure-custom-open-click-domains.html Configuring Custom Domains to Handle Open and Click Tracking>
-- in the /Amazon SES Developer Guide/.
--
-- /See:/ 'newTrackingOptions' smart constructor.
data TrackingOptions = TrackingOptions'
  { -- | The custom subdomain that will be used to redirect email recipients to
    -- the Amazon SES event tracking domain.
    TrackingOptions -> Maybe Text
customRedirectDomain :: Prelude.Maybe Prelude.Text
  }
  deriving (TrackingOptions -> TrackingOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrackingOptions -> TrackingOptions -> Bool
$c/= :: TrackingOptions -> TrackingOptions -> Bool
== :: TrackingOptions -> TrackingOptions -> Bool
$c== :: TrackingOptions -> TrackingOptions -> Bool
Prelude.Eq, ReadPrec [TrackingOptions]
ReadPrec TrackingOptions
Int -> ReadS TrackingOptions
ReadS [TrackingOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrackingOptions]
$creadListPrec :: ReadPrec [TrackingOptions]
readPrec :: ReadPrec TrackingOptions
$creadPrec :: ReadPrec TrackingOptions
readList :: ReadS [TrackingOptions]
$creadList :: ReadS [TrackingOptions]
readsPrec :: Int -> ReadS TrackingOptions
$creadsPrec :: Int -> ReadS TrackingOptions
Prelude.Read, Int -> TrackingOptions -> ShowS
[TrackingOptions] -> ShowS
TrackingOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrackingOptions] -> ShowS
$cshowList :: [TrackingOptions] -> ShowS
show :: TrackingOptions -> String
$cshow :: TrackingOptions -> String
showsPrec :: Int -> TrackingOptions -> ShowS
$cshowsPrec :: Int -> TrackingOptions -> ShowS
Prelude.Show, forall x. Rep TrackingOptions x -> TrackingOptions
forall x. TrackingOptions -> Rep TrackingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrackingOptions x -> TrackingOptions
$cfrom :: forall x. TrackingOptions -> Rep TrackingOptions x
Prelude.Generic)

-- |
-- Create a value of 'TrackingOptions' 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:
--
-- 'customRedirectDomain', 'trackingOptions_customRedirectDomain' - The custom subdomain that will be used to redirect email recipients to
-- the Amazon SES event tracking domain.
newTrackingOptions ::
  TrackingOptions
newTrackingOptions :: TrackingOptions
newTrackingOptions =
  TrackingOptions'
    { $sel:customRedirectDomain:TrackingOptions' :: Maybe Text
customRedirectDomain =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The custom subdomain that will be used to redirect email recipients to
-- the Amazon SES event tracking domain.
trackingOptions_customRedirectDomain :: Lens.Lens' TrackingOptions (Prelude.Maybe Prelude.Text)
trackingOptions_customRedirectDomain :: Lens' TrackingOptions (Maybe Text)
trackingOptions_customRedirectDomain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackingOptions' {Maybe Text
customRedirectDomain :: Maybe Text
$sel:customRedirectDomain:TrackingOptions' :: TrackingOptions -> Maybe Text
customRedirectDomain} -> Maybe Text
customRedirectDomain) (\s :: TrackingOptions
s@TrackingOptions' {} Maybe Text
a -> TrackingOptions
s {$sel:customRedirectDomain:TrackingOptions' :: Maybe Text
customRedirectDomain = Maybe Text
a} :: TrackingOptions)

instance Data.FromXML TrackingOptions where
  parseXML :: [Node] -> Either String TrackingOptions
parseXML [Node]
x =
    Maybe Text -> TrackingOptions
TrackingOptions'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CustomRedirectDomain")

instance Prelude.Hashable TrackingOptions where
  hashWithSalt :: Int -> TrackingOptions -> Int
hashWithSalt Int
_salt TrackingOptions' {Maybe Text
customRedirectDomain :: Maybe Text
$sel:customRedirectDomain:TrackingOptions' :: TrackingOptions -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customRedirectDomain

instance Prelude.NFData TrackingOptions where
  rnf :: TrackingOptions -> ()
rnf TrackingOptions' {Maybe Text
customRedirectDomain :: Maybe Text
$sel:customRedirectDomain:TrackingOptions' :: TrackingOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customRedirectDomain

instance Data.ToQuery TrackingOptions where
  toQuery :: TrackingOptions -> QueryString
toQuery TrackingOptions' {Maybe Text
customRedirectDomain :: Maybe Text
$sel:customRedirectDomain:TrackingOptions' :: TrackingOptions -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"CustomRedirectDomain" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
customRedirectDomain]