{-# 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.FraudDetector.Types.IngestedEventsTimeWindow
-- 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.FraudDetector.Types.IngestedEventsTimeWindow where

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

-- | The start and stop time of the ingested events.
--
-- /See:/ 'newIngestedEventsTimeWindow' smart constructor.
data IngestedEventsTimeWindow = IngestedEventsTimeWindow'
  { -- | Timestamp of the first ingensted event.
    IngestedEventsTimeWindow -> Text
startTime :: Prelude.Text,
    -- | Timestamp of the final ingested event.
    IngestedEventsTimeWindow -> Text
endTime :: Prelude.Text
  }
  deriving (IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool
(IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool)
-> (IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool)
-> Eq IngestedEventsTimeWindow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool
$c/= :: IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool
== :: IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool
$c== :: IngestedEventsTimeWindow -> IngestedEventsTimeWindow -> Bool
Prelude.Eq, ReadPrec [IngestedEventsTimeWindow]
ReadPrec IngestedEventsTimeWindow
Int -> ReadS IngestedEventsTimeWindow
ReadS [IngestedEventsTimeWindow]
(Int -> ReadS IngestedEventsTimeWindow)
-> ReadS [IngestedEventsTimeWindow]
-> ReadPrec IngestedEventsTimeWindow
-> ReadPrec [IngestedEventsTimeWindow]
-> Read IngestedEventsTimeWindow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IngestedEventsTimeWindow]
$creadListPrec :: ReadPrec [IngestedEventsTimeWindow]
readPrec :: ReadPrec IngestedEventsTimeWindow
$creadPrec :: ReadPrec IngestedEventsTimeWindow
readList :: ReadS [IngestedEventsTimeWindow]
$creadList :: ReadS [IngestedEventsTimeWindow]
readsPrec :: Int -> ReadS IngestedEventsTimeWindow
$creadsPrec :: Int -> ReadS IngestedEventsTimeWindow
Prelude.Read, Int -> IngestedEventsTimeWindow -> ShowS
[IngestedEventsTimeWindow] -> ShowS
IngestedEventsTimeWindow -> String
(Int -> IngestedEventsTimeWindow -> ShowS)
-> (IngestedEventsTimeWindow -> String)
-> ([IngestedEventsTimeWindow] -> ShowS)
-> Show IngestedEventsTimeWindow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IngestedEventsTimeWindow] -> ShowS
$cshowList :: [IngestedEventsTimeWindow] -> ShowS
show :: IngestedEventsTimeWindow -> String
$cshow :: IngestedEventsTimeWindow -> String
showsPrec :: Int -> IngestedEventsTimeWindow -> ShowS
$cshowsPrec :: Int -> IngestedEventsTimeWindow -> ShowS
Prelude.Show, (forall x.
 IngestedEventsTimeWindow -> Rep IngestedEventsTimeWindow x)
-> (forall x.
    Rep IngestedEventsTimeWindow x -> IngestedEventsTimeWindow)
-> Generic IngestedEventsTimeWindow
forall x.
Rep IngestedEventsTimeWindow x -> IngestedEventsTimeWindow
forall x.
IngestedEventsTimeWindow -> Rep IngestedEventsTimeWindow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IngestedEventsTimeWindow x -> IngestedEventsTimeWindow
$cfrom :: forall x.
IngestedEventsTimeWindow -> Rep IngestedEventsTimeWindow x
Prelude.Generic)

-- |
-- Create a value of 'IngestedEventsTimeWindow' 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:
--
-- 'startTime', 'ingestedEventsTimeWindow_startTime' - Timestamp of the first ingensted event.
--
-- 'endTime', 'ingestedEventsTimeWindow_endTime' - Timestamp of the final ingested event.
newIngestedEventsTimeWindow ::
  -- | 'startTime'
  Prelude.Text ->
  -- | 'endTime'
  Prelude.Text ->
  IngestedEventsTimeWindow
newIngestedEventsTimeWindow :: Text -> Text -> IngestedEventsTimeWindow
newIngestedEventsTimeWindow Text
pStartTime_ Text
pEndTime_ =
  IngestedEventsTimeWindow' :: Text -> Text -> IngestedEventsTimeWindow
IngestedEventsTimeWindow'
    { $sel:startTime:IngestedEventsTimeWindow' :: Text
startTime = Text
pStartTime_,
      $sel:endTime:IngestedEventsTimeWindow' :: Text
endTime = Text
pEndTime_
    }

-- | Timestamp of the first ingensted event.
ingestedEventsTimeWindow_startTime :: Lens.Lens' IngestedEventsTimeWindow Prelude.Text
ingestedEventsTimeWindow_startTime :: (Text -> f Text)
-> IngestedEventsTimeWindow -> f IngestedEventsTimeWindow
ingestedEventsTimeWindow_startTime = (IngestedEventsTimeWindow -> Text)
-> (IngestedEventsTimeWindow -> Text -> IngestedEventsTimeWindow)
-> Lens IngestedEventsTimeWindow IngestedEventsTimeWindow Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngestedEventsTimeWindow' {Text
startTime :: Text
$sel:startTime:IngestedEventsTimeWindow' :: IngestedEventsTimeWindow -> Text
startTime} -> Text
startTime) (\s :: IngestedEventsTimeWindow
s@IngestedEventsTimeWindow' {} Text
a -> IngestedEventsTimeWindow
s {$sel:startTime:IngestedEventsTimeWindow' :: Text
startTime = Text
a} :: IngestedEventsTimeWindow)

-- | Timestamp of the final ingested event.
ingestedEventsTimeWindow_endTime :: Lens.Lens' IngestedEventsTimeWindow Prelude.Text
ingestedEventsTimeWindow_endTime :: (Text -> f Text)
-> IngestedEventsTimeWindow -> f IngestedEventsTimeWindow
ingestedEventsTimeWindow_endTime = (IngestedEventsTimeWindow -> Text)
-> (IngestedEventsTimeWindow -> Text -> IngestedEventsTimeWindow)
-> Lens IngestedEventsTimeWindow IngestedEventsTimeWindow Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IngestedEventsTimeWindow' {Text
endTime :: Text
$sel:endTime:IngestedEventsTimeWindow' :: IngestedEventsTimeWindow -> Text
endTime} -> Text
endTime) (\s :: IngestedEventsTimeWindow
s@IngestedEventsTimeWindow' {} Text
a -> IngestedEventsTimeWindow
s {$sel:endTime:IngestedEventsTimeWindow' :: Text
endTime = Text
a} :: IngestedEventsTimeWindow)

instance Core.FromJSON IngestedEventsTimeWindow where
  parseJSON :: Value -> Parser IngestedEventsTimeWindow
parseJSON =
    String
-> (Object -> Parser IngestedEventsTimeWindow)
-> Value
-> Parser IngestedEventsTimeWindow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IngestedEventsTimeWindow"
      ( \Object
x ->
          Text -> Text -> IngestedEventsTimeWindow
IngestedEventsTimeWindow'
            (Text -> Text -> IngestedEventsTimeWindow)
-> Parser Text -> Parser (Text -> IngestedEventsTimeWindow)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"startTime")
            Parser (Text -> IngestedEventsTimeWindow)
-> Parser Text -> Parser IngestedEventsTimeWindow
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"endTime")
      )

instance Prelude.Hashable IngestedEventsTimeWindow

instance Prelude.NFData IngestedEventsTimeWindow

instance Core.ToJSON IngestedEventsTimeWindow where
  toJSON :: IngestedEventsTimeWindow -> Value
toJSON IngestedEventsTimeWindow' {Text
endTime :: Text
startTime :: Text
$sel:endTime:IngestedEventsTimeWindow' :: IngestedEventsTimeWindow -> Text
$sel:startTime:IngestedEventsTimeWindow' :: IngestedEventsTimeWindow -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startTime" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
startTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"endTime" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endTime)
          ]
      )