{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.PinpointEmail.Types.DailyVolume where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 Data.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
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]
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
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. 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'
    { $sel:domainIspPlacements:DailyVolume' :: Maybe [DomainIspPlacement]
domainIspPlacements = forall a. Maybe a
Prelude.Nothing,
      $sel:startDate:DailyVolume' :: Maybe POSIX
startDate = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeStatistics:DailyVolume' :: Maybe VolumeStatistics
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 :: Lens' DailyVolume (Maybe [DomainIspPlacement])
dailyVolume_domainIspPlacements = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' DailyVolume (Maybe UTCTime)
dailyVolume_startDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._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 :: Lens' DailyVolume (Maybe VolumeStatistics)
dailyVolume_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 Data.FromJSON DailyVolume where
  parseJSON :: Value -> Parser DailyVolume
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DailyVolume"
      ( \Object
x ->
          Maybe [DomainIspPlacement]
-> Maybe POSIX -> Maybe VolumeStatistics -> DailyVolume
DailyVolume'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DomainIspPlacements"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StartDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VolumeStatistics")
      )

instance Prelude.Hashable DailyVolume where
  hashWithSalt :: Int -> DailyVolume -> Int
hashWithSalt Int
_salt DailyVolume' {Maybe [DomainIspPlacement]
Maybe POSIX
Maybe VolumeStatistics
volumeStatistics :: Maybe VolumeStatistics
startDate :: Maybe POSIX
domainIspPlacements :: Maybe [DomainIspPlacement]
$sel:volumeStatistics:DailyVolume' :: DailyVolume -> Maybe VolumeStatistics
$sel:startDate:DailyVolume' :: DailyVolume -> Maybe POSIX
$sel:domainIspPlacements:DailyVolume' :: DailyVolume -> Maybe [DomainIspPlacement]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DomainIspPlacement]
domainIspPlacements
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VolumeStatistics
volumeStatistics

instance Prelude.NFData DailyVolume where
  rnf :: DailyVolume -> ()
rnf DailyVolume' {Maybe [DomainIspPlacement]
Maybe POSIX
Maybe VolumeStatistics
volumeStatistics :: Maybe VolumeStatistics
startDate :: Maybe POSIX
domainIspPlacements :: Maybe [DomainIspPlacement]
$sel:volumeStatistics:DailyVolume' :: DailyVolume -> Maybe VolumeStatistics
$sel:startDate:DailyVolume' :: DailyVolume -> Maybe POSIX
$sel:domainIspPlacements:DailyVolume' :: DailyVolume -> Maybe [DomainIspPlacement]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DomainIspPlacement]
domainIspPlacements
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VolumeStatistics
volumeStatistics