{-# 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.InboxPlacementTrackingOption
-- 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.InboxPlacementTrackingOption where

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

-- | An object that contains information about the inbox placement data
-- settings for a verified domain that’s associated with your AWS account.
-- This data is available only if you enabled the Deliverability dashboard
-- for the domain (@PutDeliverabilityDashboardOption@ operation).
--
-- /See:/ 'newInboxPlacementTrackingOption' smart constructor.
data InboxPlacementTrackingOption = InboxPlacementTrackingOption'
  { -- | An array of strings, one for each major email provider that the inbox
    -- placement data applies to.
    InboxPlacementTrackingOption -> Maybe [Text]
trackedIsps :: Prelude.Maybe [Prelude.Text],
    -- | Specifies whether inbox placement data is being tracked for the domain.
    InboxPlacementTrackingOption -> Maybe Bool
global :: Prelude.Maybe Prelude.Bool
  }
  deriving (InboxPlacementTrackingOption
-> InboxPlacementTrackingOption -> Bool
(InboxPlacementTrackingOption
 -> InboxPlacementTrackingOption -> Bool)
-> (InboxPlacementTrackingOption
    -> InboxPlacementTrackingOption -> Bool)
-> Eq InboxPlacementTrackingOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InboxPlacementTrackingOption
-> InboxPlacementTrackingOption -> Bool
$c/= :: InboxPlacementTrackingOption
-> InboxPlacementTrackingOption -> Bool
== :: InboxPlacementTrackingOption
-> InboxPlacementTrackingOption -> Bool
$c== :: InboxPlacementTrackingOption
-> InboxPlacementTrackingOption -> Bool
Prelude.Eq, ReadPrec [InboxPlacementTrackingOption]
ReadPrec InboxPlacementTrackingOption
Int -> ReadS InboxPlacementTrackingOption
ReadS [InboxPlacementTrackingOption]
(Int -> ReadS InboxPlacementTrackingOption)
-> ReadS [InboxPlacementTrackingOption]
-> ReadPrec InboxPlacementTrackingOption
-> ReadPrec [InboxPlacementTrackingOption]
-> Read InboxPlacementTrackingOption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InboxPlacementTrackingOption]
$creadListPrec :: ReadPrec [InboxPlacementTrackingOption]
readPrec :: ReadPrec InboxPlacementTrackingOption
$creadPrec :: ReadPrec InboxPlacementTrackingOption
readList :: ReadS [InboxPlacementTrackingOption]
$creadList :: ReadS [InboxPlacementTrackingOption]
readsPrec :: Int -> ReadS InboxPlacementTrackingOption
$creadsPrec :: Int -> ReadS InboxPlacementTrackingOption
Prelude.Read, Int -> InboxPlacementTrackingOption -> ShowS
[InboxPlacementTrackingOption] -> ShowS
InboxPlacementTrackingOption -> String
(Int -> InboxPlacementTrackingOption -> ShowS)
-> (InboxPlacementTrackingOption -> String)
-> ([InboxPlacementTrackingOption] -> ShowS)
-> Show InboxPlacementTrackingOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InboxPlacementTrackingOption] -> ShowS
$cshowList :: [InboxPlacementTrackingOption] -> ShowS
show :: InboxPlacementTrackingOption -> String
$cshow :: InboxPlacementTrackingOption -> String
showsPrec :: Int -> InboxPlacementTrackingOption -> ShowS
$cshowsPrec :: Int -> InboxPlacementTrackingOption -> ShowS
Prelude.Show, (forall x.
 InboxPlacementTrackingOption -> Rep InboxPlacementTrackingOption x)
-> (forall x.
    Rep InboxPlacementTrackingOption x -> InboxPlacementTrackingOption)
-> Generic InboxPlacementTrackingOption
forall x.
Rep InboxPlacementTrackingOption x -> InboxPlacementTrackingOption
forall x.
InboxPlacementTrackingOption -> Rep InboxPlacementTrackingOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InboxPlacementTrackingOption x -> InboxPlacementTrackingOption
$cfrom :: forall x.
InboxPlacementTrackingOption -> Rep InboxPlacementTrackingOption x
Prelude.Generic)

-- |
-- Create a value of 'InboxPlacementTrackingOption' 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:
--
-- 'trackedIsps', 'inboxPlacementTrackingOption_trackedIsps' - An array of strings, one for each major email provider that the inbox
-- placement data applies to.
--
-- 'global', 'inboxPlacementTrackingOption_global' - Specifies whether inbox placement data is being tracked for the domain.
newInboxPlacementTrackingOption ::
  InboxPlacementTrackingOption
newInboxPlacementTrackingOption :: InboxPlacementTrackingOption
newInboxPlacementTrackingOption =
  InboxPlacementTrackingOption' :: Maybe [Text] -> Maybe Bool -> InboxPlacementTrackingOption
InboxPlacementTrackingOption'
    { $sel:trackedIsps:InboxPlacementTrackingOption' :: Maybe [Text]
trackedIsps =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:global:InboxPlacementTrackingOption' :: Maybe Bool
global = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of strings, one for each major email provider that the inbox
-- placement data applies to.
inboxPlacementTrackingOption_trackedIsps :: Lens.Lens' InboxPlacementTrackingOption (Prelude.Maybe [Prelude.Text])
inboxPlacementTrackingOption_trackedIsps :: (Maybe [Text] -> f (Maybe [Text]))
-> InboxPlacementTrackingOption -> f InboxPlacementTrackingOption
inboxPlacementTrackingOption_trackedIsps = (InboxPlacementTrackingOption -> Maybe [Text])
-> (InboxPlacementTrackingOption
    -> Maybe [Text] -> InboxPlacementTrackingOption)
-> Lens
     InboxPlacementTrackingOption
     InboxPlacementTrackingOption
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InboxPlacementTrackingOption' {Maybe [Text]
trackedIsps :: Maybe [Text]
$sel:trackedIsps:InboxPlacementTrackingOption' :: InboxPlacementTrackingOption -> Maybe [Text]
trackedIsps} -> Maybe [Text]
trackedIsps) (\s :: InboxPlacementTrackingOption
s@InboxPlacementTrackingOption' {} Maybe [Text]
a -> InboxPlacementTrackingOption
s {$sel:trackedIsps:InboxPlacementTrackingOption' :: Maybe [Text]
trackedIsps = Maybe [Text]
a} :: InboxPlacementTrackingOption) ((Maybe [Text] -> f (Maybe [Text]))
 -> InboxPlacementTrackingOption -> f InboxPlacementTrackingOption)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> InboxPlacementTrackingOption
-> f InboxPlacementTrackingOption
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies whether inbox placement data is being tracked for the domain.
inboxPlacementTrackingOption_global :: Lens.Lens' InboxPlacementTrackingOption (Prelude.Maybe Prelude.Bool)
inboxPlacementTrackingOption_global :: (Maybe Bool -> f (Maybe Bool))
-> InboxPlacementTrackingOption -> f InboxPlacementTrackingOption
inboxPlacementTrackingOption_global = (InboxPlacementTrackingOption -> Maybe Bool)
-> (InboxPlacementTrackingOption
    -> Maybe Bool -> InboxPlacementTrackingOption)
-> Lens
     InboxPlacementTrackingOption
     InboxPlacementTrackingOption
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InboxPlacementTrackingOption' {Maybe Bool
global :: Maybe Bool
$sel:global:InboxPlacementTrackingOption' :: InboxPlacementTrackingOption -> Maybe Bool
global} -> Maybe Bool
global) (\s :: InboxPlacementTrackingOption
s@InboxPlacementTrackingOption' {} Maybe Bool
a -> InboxPlacementTrackingOption
s {$sel:global:InboxPlacementTrackingOption' :: Maybe Bool
global = Maybe Bool
a} :: InboxPlacementTrackingOption)

instance Core.FromJSON InboxPlacementTrackingOption where
  parseJSON :: Value -> Parser InboxPlacementTrackingOption
parseJSON =
    String
-> (Object -> Parser InboxPlacementTrackingOption)
-> Value
-> Parser InboxPlacementTrackingOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InboxPlacementTrackingOption"
      ( \Object
x ->
          Maybe [Text] -> Maybe Bool -> InboxPlacementTrackingOption
InboxPlacementTrackingOption'
            (Maybe [Text] -> Maybe Bool -> InboxPlacementTrackingOption)
-> Parser (Maybe [Text])
-> Parser (Maybe Bool -> InboxPlacementTrackingOption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TrackedIsps" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Bool -> InboxPlacementTrackingOption)
-> Parser (Maybe Bool) -> Parser InboxPlacementTrackingOption
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
"Global")
      )

instance
  Prelude.Hashable
    InboxPlacementTrackingOption

instance Prelude.NFData InboxPlacementTrackingOption

instance Core.ToJSON InboxPlacementTrackingOption where
  toJSON :: InboxPlacementTrackingOption -> Value
toJSON InboxPlacementTrackingOption' {Maybe Bool
Maybe [Text]
global :: Maybe Bool
trackedIsps :: Maybe [Text]
$sel:global:InboxPlacementTrackingOption' :: InboxPlacementTrackingOption -> Maybe Bool
$sel:trackedIsps:InboxPlacementTrackingOption' :: InboxPlacementTrackingOption -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TrackedIsps" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
trackedIsps,
            (Text
"Global" 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
global
          ]
      )