{-# 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.PinpointEmail.Types.ReputationOptions
-- 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.PinpointEmail.Types.ReputationOptions where

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

-- | Enable or disable collection of reputation metrics for emails that you
-- send using this configuration set in the current AWS Region.
--
-- /See:/ 'newReputationOptions' smart constructor.
data ReputationOptions = ReputationOptions'
  { -- | The date and time (in Unix time) when the reputation metrics were last
    -- given a fresh start. When your account is given a fresh start, your
    -- reputation metrics are calculated starting from the date of the fresh
    -- start.
    ReputationOptions -> Maybe POSIX
lastFreshStart :: Prelude.Maybe Core.POSIX,
    -- | If @true@, tracking of reputation metrics is enabled for the
    -- configuration set. If @false@, tracking of reputation metrics is
    -- disabled for the configuration set.
    ReputationOptions -> Maybe Bool
reputationMetricsEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (ReputationOptions -> ReputationOptions -> Bool
(ReputationOptions -> ReputationOptions -> Bool)
-> (ReputationOptions -> ReputationOptions -> Bool)
-> Eq ReputationOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReputationOptions -> ReputationOptions -> Bool
$c/= :: ReputationOptions -> ReputationOptions -> Bool
== :: ReputationOptions -> ReputationOptions -> Bool
$c== :: ReputationOptions -> ReputationOptions -> Bool
Prelude.Eq, ReadPrec [ReputationOptions]
ReadPrec ReputationOptions
Int -> ReadS ReputationOptions
ReadS [ReputationOptions]
(Int -> ReadS ReputationOptions)
-> ReadS [ReputationOptions]
-> ReadPrec ReputationOptions
-> ReadPrec [ReputationOptions]
-> Read ReputationOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReputationOptions]
$creadListPrec :: ReadPrec [ReputationOptions]
readPrec :: ReadPrec ReputationOptions
$creadPrec :: ReadPrec ReputationOptions
readList :: ReadS [ReputationOptions]
$creadList :: ReadS [ReputationOptions]
readsPrec :: Int -> ReadS ReputationOptions
$creadsPrec :: Int -> ReadS ReputationOptions
Prelude.Read, Int -> ReputationOptions -> ShowS
[ReputationOptions] -> ShowS
ReputationOptions -> String
(Int -> ReputationOptions -> ShowS)
-> (ReputationOptions -> String)
-> ([ReputationOptions] -> ShowS)
-> Show ReputationOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReputationOptions] -> ShowS
$cshowList :: [ReputationOptions] -> ShowS
show :: ReputationOptions -> String
$cshow :: ReputationOptions -> String
showsPrec :: Int -> ReputationOptions -> ShowS
$cshowsPrec :: Int -> ReputationOptions -> ShowS
Prelude.Show, (forall x. ReputationOptions -> Rep ReputationOptions x)
-> (forall x. Rep ReputationOptions x -> ReputationOptions)
-> Generic ReputationOptions
forall x. Rep ReputationOptions x -> ReputationOptions
forall x. ReputationOptions -> Rep ReputationOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReputationOptions x -> ReputationOptions
$cfrom :: forall x. ReputationOptions -> Rep ReputationOptions x
Prelude.Generic)

-- |
-- Create a value of 'ReputationOptions' 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:
--
-- 'lastFreshStart', 'reputationOptions_lastFreshStart' - The date and time (in Unix time) when the reputation metrics were last
-- given a fresh start. When your account is given a fresh start, your
-- reputation metrics are calculated starting from the date of the fresh
-- start.
--
-- 'reputationMetricsEnabled', 'reputationOptions_reputationMetricsEnabled' - If @true@, tracking of reputation metrics is enabled for the
-- configuration set. If @false@, tracking of reputation metrics is
-- disabled for the configuration set.
newReputationOptions ::
  ReputationOptions
newReputationOptions :: ReputationOptions
newReputationOptions =
  ReputationOptions' :: Maybe POSIX -> Maybe Bool -> ReputationOptions
ReputationOptions'
    { $sel:lastFreshStart:ReputationOptions' :: Maybe POSIX
lastFreshStart =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:reputationMetricsEnabled:ReputationOptions' :: Maybe Bool
reputationMetricsEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time (in Unix time) when the reputation metrics were last
-- given a fresh start. When your account is given a fresh start, your
-- reputation metrics are calculated starting from the date of the fresh
-- start.
reputationOptions_lastFreshStart :: Lens.Lens' ReputationOptions (Prelude.Maybe Prelude.UTCTime)
reputationOptions_lastFreshStart :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ReputationOptions -> f ReputationOptions
reputationOptions_lastFreshStart = (ReputationOptions -> Maybe POSIX)
-> (ReputationOptions -> Maybe POSIX -> ReputationOptions)
-> Lens
     ReputationOptions ReputationOptions (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReputationOptions' {Maybe POSIX
lastFreshStart :: Maybe POSIX
$sel:lastFreshStart:ReputationOptions' :: ReputationOptions -> Maybe POSIX
lastFreshStart} -> Maybe POSIX
lastFreshStart) (\s :: ReputationOptions
s@ReputationOptions' {} Maybe POSIX
a -> ReputationOptions
s {$sel:lastFreshStart:ReputationOptions' :: Maybe POSIX
lastFreshStart = Maybe POSIX
a} :: ReputationOptions) ((Maybe POSIX -> f (Maybe POSIX))
 -> ReputationOptions -> f ReputationOptions)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ReputationOptions
-> f ReputationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | If @true@, tracking of reputation metrics is enabled for the
-- configuration set. If @false@, tracking of reputation metrics is
-- disabled for the configuration set.
reputationOptions_reputationMetricsEnabled :: Lens.Lens' ReputationOptions (Prelude.Maybe Prelude.Bool)
reputationOptions_reputationMetricsEnabled :: (Maybe Bool -> f (Maybe Bool))
-> ReputationOptions -> f ReputationOptions
reputationOptions_reputationMetricsEnabled = (ReputationOptions -> Maybe Bool)
-> (ReputationOptions -> Maybe Bool -> ReputationOptions)
-> Lens
     ReputationOptions ReputationOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReputationOptions' {Maybe Bool
reputationMetricsEnabled :: Maybe Bool
$sel:reputationMetricsEnabled:ReputationOptions' :: ReputationOptions -> Maybe Bool
reputationMetricsEnabled} -> Maybe Bool
reputationMetricsEnabled) (\s :: ReputationOptions
s@ReputationOptions' {} Maybe Bool
a -> ReputationOptions
s {$sel:reputationMetricsEnabled:ReputationOptions' :: Maybe Bool
reputationMetricsEnabled = Maybe Bool
a} :: ReputationOptions)

instance Core.FromJSON ReputationOptions where
  parseJSON :: Value -> Parser ReputationOptions
parseJSON =
    String
-> (Object -> Parser ReputationOptions)
-> Value
-> Parser ReputationOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReputationOptions"
      ( \Object
x ->
          Maybe POSIX -> Maybe Bool -> ReputationOptions
ReputationOptions'
            (Maybe POSIX -> Maybe Bool -> ReputationOptions)
-> Parser (Maybe POSIX) -> Parser (Maybe Bool -> ReputationOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastFreshStart")
            Parser (Maybe Bool -> ReputationOptions)
-> Parser (Maybe Bool) -> Parser ReputationOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReputationMetricsEnabled")
      )

instance Prelude.Hashable ReputationOptions

instance Prelude.NFData ReputationOptions

instance Core.ToJSON ReputationOptions where
  toJSON :: ReputationOptions -> Value
toJSON ReputationOptions' {Maybe Bool
Maybe POSIX
reputationMetricsEnabled :: Maybe Bool
lastFreshStart :: Maybe POSIX
$sel:reputationMetricsEnabled:ReputationOptions' :: ReputationOptions -> Maybe Bool
$sel:lastFreshStart:ReputationOptions' :: ReputationOptions -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LastFreshStart" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
lastFreshStart,
            (Text
"ReputationMetricsEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
reputationMetricsEnabled
          ]
      )