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

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

-- | An object that defines the tracking options for a configuration set.
-- When you use the Amazon SES API v2 to send an email, it contains an
-- invisible image that\'s used to track when recipients open your email.
-- If your email contains links, those links are changed slightly in order
-- to track when recipients click them.
--
-- These images and links include references to a domain operated by Amazon
-- Web Services. You can optionally configure the Amazon SES to use a
-- domain that you operate for these images and links.
--
-- /See:/ 'newTrackingOptions' smart constructor.
data TrackingOptions = TrackingOptions'
  { -- | The domain to use for tracking open and click events.
    TrackingOptions -> Text
customRedirectDomain :: 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 domain to use for tracking open and click events.
newTrackingOptions ::
  -- | 'customRedirectDomain'
  Prelude.Text ->
  TrackingOptions
newTrackingOptions :: Text -> TrackingOptions
newTrackingOptions Text
pCustomRedirectDomain_ =
  TrackingOptions' :: Text -> TrackingOptions
TrackingOptions'
    { $sel:customRedirectDomain:TrackingOptions' :: Text
customRedirectDomain =
        Text
pCustomRedirectDomain_
    }

-- | The domain to use for tracking open and click events.
trackingOptions_customRedirectDomain :: Lens.Lens' TrackingOptions Prelude.Text
trackingOptions_customRedirectDomain :: (Text -> f Text) -> TrackingOptions -> f TrackingOptions
trackingOptions_customRedirectDomain = (TrackingOptions -> Text)
-> (TrackingOptions -> Text -> TrackingOptions)
-> Lens TrackingOptions TrackingOptions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrackingOptions' {Text
customRedirectDomain :: Text
$sel:customRedirectDomain:TrackingOptions' :: TrackingOptions -> Text
customRedirectDomain} -> Text
customRedirectDomain) (\s :: TrackingOptions
s@TrackingOptions' {} Text
a -> TrackingOptions
s {$sel:customRedirectDomain:TrackingOptions' :: Text
customRedirectDomain = Text
a} :: TrackingOptions)

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

instance Prelude.Hashable TrackingOptions

instance Prelude.NFData TrackingOptions

instance Core.ToJSON TrackingOptions where
  toJSON :: TrackingOptions -> Value
toJSON TrackingOptions' {Text
customRedirectDomain :: Text
$sel:customRedirectDomain:TrackingOptions' :: TrackingOptions -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CustomRedirectDomain"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
customRedirectDomain
              )
          ]
      )