{-# 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.SES.Types.SendDataPoint
-- 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.SES.Types.SendDataPoint where

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

-- | Represents sending statistics data. Each @SendDataPoint@ contains
-- statistics for a 15-minute period of sending activity.
--
-- /See:/ 'newSendDataPoint' smart constructor.
data SendDataPoint = SendDataPoint'
  { -- | Number of emails rejected by Amazon SES.
    SendDataPoint -> Maybe Integer
rejects :: Prelude.Maybe Prelude.Integer,
    -- | Number of unwanted emails that were rejected by recipients.
    SendDataPoint -> Maybe Integer
complaints :: Prelude.Maybe Prelude.Integer,
    -- | Number of emails that have been sent.
    SendDataPoint -> Maybe Integer
deliveryAttempts :: Prelude.Maybe Prelude.Integer,
    -- | Number of emails that have bounced.
    SendDataPoint -> Maybe Integer
bounces :: Prelude.Maybe Prelude.Integer,
    -- | Time of the data point.
    SendDataPoint -> Maybe ISO8601
timestamp :: Prelude.Maybe Core.ISO8601
  }
  deriving (SendDataPoint -> SendDataPoint -> Bool
(SendDataPoint -> SendDataPoint -> Bool)
-> (SendDataPoint -> SendDataPoint -> Bool) -> Eq SendDataPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendDataPoint -> SendDataPoint -> Bool
$c/= :: SendDataPoint -> SendDataPoint -> Bool
== :: SendDataPoint -> SendDataPoint -> Bool
$c== :: SendDataPoint -> SendDataPoint -> Bool
Prelude.Eq, ReadPrec [SendDataPoint]
ReadPrec SendDataPoint
Int -> ReadS SendDataPoint
ReadS [SendDataPoint]
(Int -> ReadS SendDataPoint)
-> ReadS [SendDataPoint]
-> ReadPrec SendDataPoint
-> ReadPrec [SendDataPoint]
-> Read SendDataPoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendDataPoint]
$creadListPrec :: ReadPrec [SendDataPoint]
readPrec :: ReadPrec SendDataPoint
$creadPrec :: ReadPrec SendDataPoint
readList :: ReadS [SendDataPoint]
$creadList :: ReadS [SendDataPoint]
readsPrec :: Int -> ReadS SendDataPoint
$creadsPrec :: Int -> ReadS SendDataPoint
Prelude.Read, Int -> SendDataPoint -> ShowS
[SendDataPoint] -> ShowS
SendDataPoint -> String
(Int -> SendDataPoint -> ShowS)
-> (SendDataPoint -> String)
-> ([SendDataPoint] -> ShowS)
-> Show SendDataPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendDataPoint] -> ShowS
$cshowList :: [SendDataPoint] -> ShowS
show :: SendDataPoint -> String
$cshow :: SendDataPoint -> String
showsPrec :: Int -> SendDataPoint -> ShowS
$cshowsPrec :: Int -> SendDataPoint -> ShowS
Prelude.Show, (forall x. SendDataPoint -> Rep SendDataPoint x)
-> (forall x. Rep SendDataPoint x -> SendDataPoint)
-> Generic SendDataPoint
forall x. Rep SendDataPoint x -> SendDataPoint
forall x. SendDataPoint -> Rep SendDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendDataPoint x -> SendDataPoint
$cfrom :: forall x. SendDataPoint -> Rep SendDataPoint x
Prelude.Generic)

-- |
-- Create a value of 'SendDataPoint' 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:
--
-- 'rejects', 'sendDataPoint_rejects' - Number of emails rejected by Amazon SES.
--
-- 'complaints', 'sendDataPoint_complaints' - Number of unwanted emails that were rejected by recipients.
--
-- 'deliveryAttempts', 'sendDataPoint_deliveryAttempts' - Number of emails that have been sent.
--
-- 'bounces', 'sendDataPoint_bounces' - Number of emails that have bounced.
--
-- 'timestamp', 'sendDataPoint_timestamp' - Time of the data point.
newSendDataPoint ::
  SendDataPoint
newSendDataPoint :: SendDataPoint
newSendDataPoint =
  SendDataPoint' :: Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> Maybe ISO8601
-> SendDataPoint
SendDataPoint'
    { $sel:rejects:SendDataPoint' :: Maybe Integer
rejects = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:complaints:SendDataPoint' :: Maybe Integer
complaints = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryAttempts:SendDataPoint' :: Maybe Integer
deliveryAttempts = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:bounces:SendDataPoint' :: Maybe Integer
bounces = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:SendDataPoint' :: Maybe ISO8601
timestamp = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | Number of emails rejected by Amazon SES.
sendDataPoint_rejects :: Lens.Lens' SendDataPoint (Prelude.Maybe Prelude.Integer)
sendDataPoint_rejects :: (Maybe Integer -> f (Maybe Integer))
-> SendDataPoint -> f SendDataPoint
sendDataPoint_rejects = (SendDataPoint -> Maybe Integer)
-> (SendDataPoint -> Maybe Integer -> SendDataPoint)
-> Lens SendDataPoint SendDataPoint (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDataPoint' {Maybe Integer
rejects :: Maybe Integer
$sel:rejects:SendDataPoint' :: SendDataPoint -> Maybe Integer
rejects} -> Maybe Integer
rejects) (\s :: SendDataPoint
s@SendDataPoint' {} Maybe Integer
a -> SendDataPoint
s {$sel:rejects:SendDataPoint' :: Maybe Integer
rejects = Maybe Integer
a} :: SendDataPoint)

-- | Number of unwanted emails that were rejected by recipients.
sendDataPoint_complaints :: Lens.Lens' SendDataPoint (Prelude.Maybe Prelude.Integer)
sendDataPoint_complaints :: (Maybe Integer -> f (Maybe Integer))
-> SendDataPoint -> f SendDataPoint
sendDataPoint_complaints = (SendDataPoint -> Maybe Integer)
-> (SendDataPoint -> Maybe Integer -> SendDataPoint)
-> Lens SendDataPoint SendDataPoint (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDataPoint' {Maybe Integer
complaints :: Maybe Integer
$sel:complaints:SendDataPoint' :: SendDataPoint -> Maybe Integer
complaints} -> Maybe Integer
complaints) (\s :: SendDataPoint
s@SendDataPoint' {} Maybe Integer
a -> SendDataPoint
s {$sel:complaints:SendDataPoint' :: Maybe Integer
complaints = Maybe Integer
a} :: SendDataPoint)

-- | Number of emails that have been sent.
sendDataPoint_deliveryAttempts :: Lens.Lens' SendDataPoint (Prelude.Maybe Prelude.Integer)
sendDataPoint_deliveryAttempts :: (Maybe Integer -> f (Maybe Integer))
-> SendDataPoint -> f SendDataPoint
sendDataPoint_deliveryAttempts = (SendDataPoint -> Maybe Integer)
-> (SendDataPoint -> Maybe Integer -> SendDataPoint)
-> Lens SendDataPoint SendDataPoint (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDataPoint' {Maybe Integer
deliveryAttempts :: Maybe Integer
$sel:deliveryAttempts:SendDataPoint' :: SendDataPoint -> Maybe Integer
deliveryAttempts} -> Maybe Integer
deliveryAttempts) (\s :: SendDataPoint
s@SendDataPoint' {} Maybe Integer
a -> SendDataPoint
s {$sel:deliveryAttempts:SendDataPoint' :: Maybe Integer
deliveryAttempts = Maybe Integer
a} :: SendDataPoint)

-- | Number of emails that have bounced.
sendDataPoint_bounces :: Lens.Lens' SendDataPoint (Prelude.Maybe Prelude.Integer)
sendDataPoint_bounces :: (Maybe Integer -> f (Maybe Integer))
-> SendDataPoint -> f SendDataPoint
sendDataPoint_bounces = (SendDataPoint -> Maybe Integer)
-> (SendDataPoint -> Maybe Integer -> SendDataPoint)
-> Lens SendDataPoint SendDataPoint (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDataPoint' {Maybe Integer
bounces :: Maybe Integer
$sel:bounces:SendDataPoint' :: SendDataPoint -> Maybe Integer
bounces} -> Maybe Integer
bounces) (\s :: SendDataPoint
s@SendDataPoint' {} Maybe Integer
a -> SendDataPoint
s {$sel:bounces:SendDataPoint' :: Maybe Integer
bounces = Maybe Integer
a} :: SendDataPoint)

-- | Time of the data point.
sendDataPoint_timestamp :: Lens.Lens' SendDataPoint (Prelude.Maybe Prelude.UTCTime)
sendDataPoint_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SendDataPoint -> f SendDataPoint
sendDataPoint_timestamp = (SendDataPoint -> Maybe ISO8601)
-> (SendDataPoint -> Maybe ISO8601 -> SendDataPoint)
-> Lens SendDataPoint SendDataPoint (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendDataPoint' {Maybe ISO8601
timestamp :: Maybe ISO8601
$sel:timestamp:SendDataPoint' :: SendDataPoint -> Maybe ISO8601
timestamp} -> Maybe ISO8601
timestamp) (\s :: SendDataPoint
s@SendDataPoint' {} Maybe ISO8601
a -> SendDataPoint
s {$sel:timestamp:SendDataPoint' :: Maybe ISO8601
timestamp = Maybe ISO8601
a} :: SendDataPoint) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> SendDataPoint -> f SendDataPoint)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SendDataPoint
-> f SendDataPoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML SendDataPoint where
  parseXML :: [Node] -> Either String SendDataPoint
parseXML [Node]
x =
    Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> Maybe Integer
-> Maybe ISO8601
-> SendDataPoint
SendDataPoint'
      (Maybe Integer
 -> Maybe Integer
 -> Maybe Integer
 -> Maybe Integer
 -> Maybe ISO8601
 -> SendDataPoint)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe Integer
      -> Maybe Integer
      -> Maybe Integer
      -> Maybe ISO8601
      -> SendDataPoint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Rejects")
      Either
  String
  (Maybe Integer
   -> Maybe Integer
   -> Maybe Integer
   -> Maybe ISO8601
   -> SendDataPoint)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe Integer -> Maybe Integer -> Maybe ISO8601 -> SendDataPoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Complaints")
      Either
  String
  (Maybe Integer -> Maybe Integer -> Maybe ISO8601 -> SendDataPoint)
-> Either String (Maybe Integer)
-> Either String (Maybe Integer -> Maybe ISO8601 -> SendDataPoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DeliveryAttempts")
      Either String (Maybe Integer -> Maybe ISO8601 -> SendDataPoint)
-> Either String (Maybe Integer)
-> Either String (Maybe ISO8601 -> SendDataPoint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Bounces")
      Either String (Maybe ISO8601 -> SendDataPoint)
-> Either String (Maybe ISO8601) -> Either String SendDataPoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Timestamp")

instance Prelude.Hashable SendDataPoint

instance Prelude.NFData SendDataPoint