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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TrackingOptions -> TrackingOptions -> Bool)
-> (TrackingOptions -> TrackingOptions -> Bool)
-> Eq TrackingOptions
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]
(Int -> ReadS TrackingOptions)
-> ReadS [TrackingOptions]
-> ReadPrec TrackingOptions
-> ReadPrec [TrackingOptions]
-> Read 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
(Int -> TrackingOptions -> ShowS)
-> (TrackingOptions -> String)
-> ([TrackingOptions] -> ShowS)
-> Show TrackingOptions
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. TrackingOptions -> Rep TrackingOptions x)
-> (forall x. Rep TrackingOptions x -> TrackingOptions)
-> Generic TrackingOptions
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' :: Maybe Text -> TrackingOptions
TrackingOptions'
    { $sel:customRedirectDomain:TrackingOptions' :: Maybe Text
customRedirectDomain =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> TrackingOptions -> f TrackingOptions
trackingOptions_customRedirectDomain = (TrackingOptions -> Maybe Text)
-> (TrackingOptions -> Maybe Text -> TrackingOptions)
-> Lens TrackingOptions TrackingOptions (Maybe Text) (Maybe Text)
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 Core.FromXML TrackingOptions where
  parseXML :: [Node] -> Either String TrackingOptions
parseXML [Node]
x =
    Maybe Text -> TrackingOptions
TrackingOptions'
      (Maybe Text -> TrackingOptions)
-> Either String (Maybe Text) -> Either String TrackingOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CustomRedirectDomain")

instance Prelude.Hashable TrackingOptions

instance Prelude.NFData TrackingOptions

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