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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.PinpointEmail.Types.DomainIspPlacement
import Amazonka.PinpointEmail.Types.VolumeStatistics
import qualified Amazonka.Prelude as Prelude

-- | An object that contains information about the volume of email sent on
-- each day of the analysis period.
--
-- /See:/ 'newDailyVolume' smart constructor.
data DailyVolume = DailyVolume'
  { -- | An object that contains inbox placement metrics for a specified day in
    -- the analysis period, broken out by the recipient\'s email provider.
    DailyVolume -> Maybe [DomainIspPlacement]
domainIspPlacements :: Prelude.Maybe [DomainIspPlacement],
    -- | The date that the DailyVolume metrics apply to, in Unix time.
    DailyVolume -> Maybe POSIX
startDate :: Prelude.Maybe Core.POSIX,
    -- | An object that contains inbox placement metrics for a specific day in
    -- the analysis period.
    DailyVolume -> Maybe VolumeStatistics
volumeStatistics :: Prelude.Maybe VolumeStatistics
  }
  deriving (DailyVolume -> DailyVolume -> Bool
(DailyVolume -> DailyVolume -> Bool)
-> (DailyVolume -> DailyVolume -> Bool) -> Eq DailyVolume
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DailyVolume -> DailyVolume -> Bool
$c/= :: DailyVolume -> DailyVolume -> Bool
== :: DailyVolume -> DailyVolume -> Bool
$c== :: DailyVolume -> DailyVolume -> Bool
Prelude.Eq, ReadPrec [DailyVolume]
ReadPrec DailyVolume
Int -> ReadS DailyVolume
ReadS [DailyVolume]
(Int -> ReadS DailyVolume)
-> ReadS [DailyVolume]
-> ReadPrec DailyVolume
-> ReadPrec [DailyVolume]
-> Read DailyVolume
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DailyVolume]
$creadListPrec :: ReadPrec [DailyVolume]
readPrec :: ReadPrec DailyVolume
$creadPrec :: ReadPrec DailyVolume
readList :: ReadS [DailyVolume]
$creadList :: ReadS [DailyVolume]
readsPrec :: Int -> ReadS DailyVolume
$creadsPrec :: Int -> ReadS DailyVolume
Prelude.Read, Int -> DailyVolume -> ShowS
[DailyVolume] -> ShowS
DailyVolume -> String
(Int -> DailyVolume -> ShowS)
-> (DailyVolume -> String)
-> ([DailyVolume] -> ShowS)
-> Show DailyVolume
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DailyVolume] -> ShowS
$cshowList :: [DailyVolume] -> ShowS
show :: DailyVolume -> String
$cshow :: DailyVolume -> String
showsPrec :: Int -> DailyVolume -> ShowS
$cshowsPrec :: Int -> DailyVolume -> ShowS
Prelude.Show, (forall x. DailyVolume -> Rep DailyVolume x)
-> (forall x. Rep DailyVolume x -> DailyVolume)
-> Generic DailyVolume
forall x. Rep DailyVolume x -> DailyVolume
forall x. DailyVolume -> Rep DailyVolume x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DailyVolume x -> DailyVolume
$cfrom :: forall x. DailyVolume -> Rep DailyVolume x
Prelude.Generic)

-- |
-- Create a value of 'DailyVolume' 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:
--
-- 'domainIspPlacements', 'dailyVolume_domainIspPlacements' - An object that contains inbox placement metrics for a specified day in
-- the analysis period, broken out by the recipient\'s email provider.
--
-- 'startDate', 'dailyVolume_startDate' - The date that the DailyVolume metrics apply to, in Unix time.
--
-- 'volumeStatistics', 'dailyVolume_volumeStatistics' - An object that contains inbox placement metrics for a specific day in
-- the analysis period.
newDailyVolume ::
  DailyVolume
newDailyVolume :: DailyVolume
newDailyVolume =
  DailyVolume' :: Maybe [DomainIspPlacement]
-> Maybe POSIX -> Maybe VolumeStatistics -> DailyVolume
DailyVolume'
    { $sel:domainIspPlacements:DailyVolume' :: Maybe [DomainIspPlacement]
domainIspPlacements = Maybe [DomainIspPlacement]
forall a. Maybe a
Prelude.Nothing,
      $sel:startDate:DailyVolume' :: Maybe POSIX
startDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:volumeStatistics:DailyVolume' :: Maybe VolumeStatistics
volumeStatistics = Maybe VolumeStatistics
forall a. Maybe a
Prelude.Nothing
    }

-- | An object that contains inbox placement metrics for a specified day in
-- the analysis period, broken out by the recipient\'s email provider.
dailyVolume_domainIspPlacements :: Lens.Lens' DailyVolume (Prelude.Maybe [DomainIspPlacement])
dailyVolume_domainIspPlacements :: (Maybe [DomainIspPlacement] -> f (Maybe [DomainIspPlacement]))
-> DailyVolume -> f DailyVolume
dailyVolume_domainIspPlacements = (DailyVolume -> Maybe [DomainIspPlacement])
-> (DailyVolume -> Maybe [DomainIspPlacement] -> DailyVolume)
-> Lens
     DailyVolume
     DailyVolume
     (Maybe [DomainIspPlacement])
     (Maybe [DomainIspPlacement])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DailyVolume' {Maybe [DomainIspPlacement]
domainIspPlacements :: Maybe [DomainIspPlacement]
$sel:domainIspPlacements:DailyVolume' :: DailyVolume -> Maybe [DomainIspPlacement]
domainIspPlacements} -> Maybe [DomainIspPlacement]
domainIspPlacements) (\s :: DailyVolume
s@DailyVolume' {} Maybe [DomainIspPlacement]
a -> DailyVolume
s {$sel:domainIspPlacements:DailyVolume' :: Maybe [DomainIspPlacement]
domainIspPlacements = Maybe [DomainIspPlacement]
a} :: DailyVolume) ((Maybe [DomainIspPlacement] -> f (Maybe [DomainIspPlacement]))
 -> DailyVolume -> f DailyVolume)
-> ((Maybe [DomainIspPlacement] -> f (Maybe [DomainIspPlacement]))
    -> Maybe [DomainIspPlacement] -> f (Maybe [DomainIspPlacement]))
-> (Maybe [DomainIspPlacement] -> f (Maybe [DomainIspPlacement]))
-> DailyVolume
-> f DailyVolume
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DomainIspPlacement]
  [DomainIspPlacement]
  [DomainIspPlacement]
  [DomainIspPlacement]
-> Iso
     (Maybe [DomainIspPlacement])
     (Maybe [DomainIspPlacement])
     (Maybe [DomainIspPlacement])
     (Maybe [DomainIspPlacement])
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
  [DomainIspPlacement]
  [DomainIspPlacement]
  [DomainIspPlacement]
  [DomainIspPlacement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date that the DailyVolume metrics apply to, in Unix time.
dailyVolume_startDate :: Lens.Lens' DailyVolume (Prelude.Maybe Prelude.UTCTime)
dailyVolume_startDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DailyVolume -> f DailyVolume
dailyVolume_startDate = (DailyVolume -> Maybe POSIX)
-> (DailyVolume -> Maybe POSIX -> DailyVolume)
-> Lens DailyVolume DailyVolume (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DailyVolume' {Maybe POSIX
startDate :: Maybe POSIX
$sel:startDate:DailyVolume' :: DailyVolume -> Maybe POSIX
startDate} -> Maybe POSIX
startDate) (\s :: DailyVolume
s@DailyVolume' {} Maybe POSIX
a -> DailyVolume
s {$sel:startDate:DailyVolume' :: Maybe POSIX
startDate = Maybe POSIX
a} :: DailyVolume) ((Maybe POSIX -> f (Maybe POSIX)) -> DailyVolume -> f DailyVolume)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DailyVolume
-> f DailyVolume
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

-- | An object that contains inbox placement metrics for a specific day in
-- the analysis period.
dailyVolume_volumeStatistics :: Lens.Lens' DailyVolume (Prelude.Maybe VolumeStatistics)
dailyVolume_volumeStatistics :: (Maybe VolumeStatistics -> f (Maybe VolumeStatistics))
-> DailyVolume -> f DailyVolume
dailyVolume_volumeStatistics = (DailyVolume -> Maybe VolumeStatistics)
-> (DailyVolume -> Maybe VolumeStatistics -> DailyVolume)
-> Lens
     DailyVolume
     DailyVolume
     (Maybe VolumeStatistics)
     (Maybe VolumeStatistics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DailyVolume' {Maybe VolumeStatistics
volumeStatistics :: Maybe VolumeStatistics
$sel:volumeStatistics:DailyVolume' :: DailyVolume -> Maybe VolumeStatistics
volumeStatistics} -> Maybe VolumeStatistics
volumeStatistics) (\s :: DailyVolume
s@DailyVolume' {} Maybe VolumeStatistics
a -> DailyVolume
s {$sel:volumeStatistics:DailyVolume' :: Maybe VolumeStatistics
volumeStatistics = Maybe VolumeStatistics
a} :: DailyVolume)

instance Core.FromJSON DailyVolume where
  parseJSON :: Value -> Parser DailyVolume
parseJSON =
    String
-> (Object -> Parser DailyVolume) -> Value -> Parser DailyVolume
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DailyVolume"
      ( \Object
x ->
          Maybe [DomainIspPlacement]
-> Maybe POSIX -> Maybe VolumeStatistics -> DailyVolume
DailyVolume'
            (Maybe [DomainIspPlacement]
 -> Maybe POSIX -> Maybe VolumeStatistics -> DailyVolume)
-> Parser (Maybe [DomainIspPlacement])
-> Parser (Maybe POSIX -> Maybe VolumeStatistics -> DailyVolume)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [DomainIspPlacement]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DomainIspPlacements"
                            Parser (Maybe (Maybe [DomainIspPlacement]))
-> Maybe [DomainIspPlacement]
-> Parser (Maybe [DomainIspPlacement])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DomainIspPlacement]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe POSIX -> Maybe VolumeStatistics -> DailyVolume)
-> Parser (Maybe POSIX)
-> Parser (Maybe VolumeStatistics -> DailyVolume)
forall (f :: * -> *) a b. Applicative f => 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
"StartDate")
            Parser (Maybe VolumeStatistics -> DailyVolume)
-> Parser (Maybe VolumeStatistics) -> Parser DailyVolume
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VolumeStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"VolumeStatistics")
      )

instance Prelude.Hashable DailyVolume

instance Prelude.NFData DailyVolume