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

import qualified Amazonka.Core as Core
import Amazonka.FraudDetector.Types.Entity
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The event details.
--
-- /See:/ 'newEvent' smart constructor.
data Event = Event'
  { -- | The timestamp that defines when the event under evaluation occurred. The
    -- timestamp must be specified using ISO 8601 standard in UTC.
    Event -> Maybe Text
eventTimestamp :: Prelude.Maybe Prelude.Text,
    -- | The event entities.
    Event -> Maybe [Sensitive Entity]
entities :: Prelude.Maybe [Core.Sensitive Entity],
    -- | The timestamp associated with the label to update. The timestamp must be
    -- specified using ISO 8601 standard in UTC.
    Event -> Maybe Text
labelTimestamp :: Prelude.Maybe Prelude.Text,
    -- | The event type.
    Event -> Maybe Text
eventTypeName :: Prelude.Maybe Prelude.Text,
    -- | Names of the event type\'s variables you defined in Amazon Fraud
    -- Detector to represent data elements and their corresponding values for
    -- the event you are sending for evaluation.
    Event -> Maybe (HashMap Text (Sensitive Text))
eventVariables :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Core.Sensitive Prelude.Text)),
    -- | The label associated with the event.
    Event -> Maybe Text
currentLabel :: Prelude.Maybe Prelude.Text,
    -- | The event ID.
    Event -> Maybe Text
eventId :: Prelude.Maybe Prelude.Text
  }
  deriving (Event -> Event -> Bool
(Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Event -> Event -> Bool
$c/= :: Event -> Event -> Bool
== :: Event -> Event -> Bool
$c== :: Event -> Event -> Bool
Prelude.Eq, Int -> Event -> ShowS
[Event] -> ShowS
Event -> String
(Int -> Event -> ShowS)
-> (Event -> String) -> ([Event] -> ShowS) -> Show Event
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> String
$cshow :: Event -> String
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
Prelude.Show, (forall x. Event -> Rep Event x)
-> (forall x. Rep Event x -> Event) -> Generic Event
forall x. Rep Event x -> Event
forall x. Event -> Rep Event x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Event x -> Event
$cfrom :: forall x. Event -> Rep Event x
Prelude.Generic)

-- |
-- Create a value of 'Event' 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:
--
-- 'eventTimestamp', 'event_eventTimestamp' - The timestamp that defines when the event under evaluation occurred. The
-- timestamp must be specified using ISO 8601 standard in UTC.
--
-- 'entities', 'event_entities' - The event entities.
--
-- 'labelTimestamp', 'event_labelTimestamp' - The timestamp associated with the label to update. The timestamp must be
-- specified using ISO 8601 standard in UTC.
--
-- 'eventTypeName', 'event_eventTypeName' - The event type.
--
-- 'eventVariables', 'event_eventVariables' - Names of the event type\'s variables you defined in Amazon Fraud
-- Detector to represent data elements and their corresponding values for
-- the event you are sending for evaluation.
--
-- 'currentLabel', 'event_currentLabel' - The label associated with the event.
--
-- 'eventId', 'event_eventId' - The event ID.
newEvent ::
  Event
newEvent :: Event
newEvent =
  Event' :: Maybe Text
-> Maybe [Sensitive Entity]
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text (Sensitive Text))
-> Maybe Text
-> Maybe Text
-> Event
Event'
    { $sel:eventTimestamp:Event' :: Maybe Text
eventTimestamp = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:entities:Event' :: Maybe [Sensitive Entity]
entities = Maybe [Sensitive Entity]
forall a. Maybe a
Prelude.Nothing,
      $sel:labelTimestamp:Event' :: Maybe Text
labelTimestamp = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventTypeName:Event' :: Maybe Text
eventTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventVariables:Event' :: Maybe (HashMap Text (Sensitive Text))
eventVariables = Maybe (HashMap Text (Sensitive Text))
forall a. Maybe a
Prelude.Nothing,
      $sel:currentLabel:Event' :: Maybe Text
currentLabel = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventId:Event' :: Maybe Text
eventId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp that defines when the event under evaluation occurred. The
-- timestamp must be specified using ISO 8601 standard in UTC.
event_eventTimestamp :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_eventTimestamp :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_eventTimestamp = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
eventTimestamp :: Maybe Text
$sel:eventTimestamp:Event' :: Event -> Maybe Text
eventTimestamp} -> Maybe Text
eventTimestamp) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:eventTimestamp:Event' :: Maybe Text
eventTimestamp = Maybe Text
a} :: Event)

-- | The event entities.
event_entities :: Lens.Lens' Event (Prelude.Maybe [Entity])
event_entities :: (Maybe [Entity] -> f (Maybe [Entity])) -> Event -> f Event
event_entities = (Event -> Maybe [Sensitive Entity])
-> (Event -> Maybe [Sensitive Entity] -> Event)
-> Lens
     Event Event (Maybe [Sensitive Entity]) (Maybe [Sensitive Entity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe [Sensitive Entity]
entities :: Maybe [Sensitive Entity]
$sel:entities:Event' :: Event -> Maybe [Sensitive Entity]
entities} -> Maybe [Sensitive Entity]
entities) (\s :: Event
s@Event' {} Maybe [Sensitive Entity]
a -> Event
s {$sel:entities:Event' :: Maybe [Sensitive Entity]
entities = Maybe [Sensitive Entity]
a} :: Event) ((Maybe [Sensitive Entity] -> f (Maybe [Sensitive Entity]))
 -> Event -> f Event)
-> ((Maybe [Entity] -> f (Maybe [Entity]))
    -> Maybe [Sensitive Entity] -> f (Maybe [Sensitive Entity]))
-> (Maybe [Entity] -> f (Maybe [Entity]))
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Sensitive Entity] [Sensitive Entity] [Entity] [Entity]
-> Iso
     (Maybe [Sensitive Entity])
     (Maybe [Sensitive Entity])
     (Maybe [Entity])
     (Maybe [Entity])
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 [Sensitive Entity] [Sensitive Entity] [Entity] [Entity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The timestamp associated with the label to update. The timestamp must be
-- specified using ISO 8601 standard in UTC.
event_labelTimestamp :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_labelTimestamp :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_labelTimestamp = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
labelTimestamp :: Maybe Text
$sel:labelTimestamp:Event' :: Event -> Maybe Text
labelTimestamp} -> Maybe Text
labelTimestamp) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:labelTimestamp:Event' :: Maybe Text
labelTimestamp = Maybe Text
a} :: Event)

-- | The event type.
event_eventTypeName :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_eventTypeName :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_eventTypeName = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
eventTypeName :: Maybe Text
$sel:eventTypeName:Event' :: Event -> Maybe Text
eventTypeName} -> Maybe Text
eventTypeName) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:eventTypeName:Event' :: Maybe Text
eventTypeName = Maybe Text
a} :: Event)

-- | Names of the event type\'s variables you defined in Amazon Fraud
-- Detector to represent data elements and their corresponding values for
-- the event you are sending for evaluation.
event_eventVariables :: Lens.Lens' Event (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
event_eventVariables :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Event -> f Event
event_eventVariables = (Event -> Maybe (HashMap Text (Sensitive Text)))
-> (Event -> Maybe (HashMap Text (Sensitive Text)) -> Event)
-> Lens
     Event
     Event
     (Maybe (HashMap Text (Sensitive Text)))
     (Maybe (HashMap Text (Sensitive Text)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe (HashMap Text (Sensitive Text))
eventVariables :: Maybe (HashMap Text (Sensitive Text))
$sel:eventVariables:Event' :: Event -> Maybe (HashMap Text (Sensitive Text))
eventVariables} -> Maybe (HashMap Text (Sensitive Text))
eventVariables) (\s :: Event
s@Event' {} Maybe (HashMap Text (Sensitive Text))
a -> Event
s {$sel:eventVariables:Event' :: Maybe (HashMap Text (Sensitive Text))
eventVariables = Maybe (HashMap Text (Sensitive Text))
a} :: Event) ((Maybe (HashMap Text (Sensitive Text))
  -> f (Maybe (HashMap Text (Sensitive Text))))
 -> Event -> f Event)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text (Sensitive Text))
    -> f (Maybe (HashMap Text (Sensitive Text))))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text (Sensitive Text))
  (HashMap Text (Sensitive Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text (Sensitive Text)))
     (Maybe (HashMap Text (Sensitive Text)))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text (Sensitive Text))
  (HashMap Text (Sensitive Text))
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The label associated with the event.
event_currentLabel :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_currentLabel :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_currentLabel = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
currentLabel :: Maybe Text
$sel:currentLabel:Event' :: Event -> Maybe Text
currentLabel} -> Maybe Text
currentLabel) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:currentLabel:Event' :: Maybe Text
currentLabel = Maybe Text
a} :: Event)

-- | The event ID.
event_eventId :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_eventId :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_eventId = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
eventId :: Maybe Text
$sel:eventId:Event' :: Event -> Maybe Text
eventId} -> Maybe Text
eventId) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:eventId:Event' :: Maybe Text
eventId = Maybe Text
a} :: Event)

instance Core.FromJSON Event where
  parseJSON :: Value -> Parser Event
parseJSON =
    String -> (Object -> Parser Event) -> Value -> Parser Event
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Event"
      ( \Object
x ->
          Maybe Text
-> Maybe [Sensitive Entity]
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text (Sensitive Text))
-> Maybe Text
-> Maybe Text
-> Event
Event'
            (Maybe Text
 -> Maybe [Sensitive Entity]
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text (Sensitive Text))
 -> Maybe Text
 -> Maybe Text
 -> Event)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Sensitive Entity]
      -> Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text (Sensitive Text))
      -> Maybe Text
      -> Maybe Text
      -> Event)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventTimestamp")
            Parser
  (Maybe [Sensitive Entity]
   -> Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text (Sensitive Text))
   -> Maybe Text
   -> Maybe Text
   -> Event)
-> Parser (Maybe [Sensitive Entity])
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text (Sensitive Text))
      -> Maybe Text
      -> Maybe Text
      -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Sensitive Entity]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"entities" Parser (Maybe (Maybe [Sensitive Entity]))
-> Maybe [Sensitive Entity] -> Parser (Maybe [Sensitive Entity])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Sensitive Entity]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text (Sensitive Text))
   -> Maybe Text
   -> Maybe Text
   -> Event)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text (Sensitive Text))
      -> Maybe Text
      -> Maybe Text
      -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"labelTimestamp")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text (Sensitive Text))
   -> Maybe Text
   -> Maybe Text
   -> Event)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text (Sensitive Text))
      -> Maybe Text -> Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventTypeName")
            Parser
  (Maybe (HashMap Text (Sensitive Text))
   -> Maybe Text -> Maybe Text -> Event)
-> Parser (Maybe (HashMap Text (Sensitive Text)))
-> Parser (Maybe Text -> Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text (Sensitive Text))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventVariables" Parser (Maybe (Maybe (HashMap Text (Sensitive Text))))
-> Maybe (HashMap Text (Sensitive Text))
-> Parser (Maybe (HashMap Text (Sensitive Text)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text (Sensitive Text))
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> Event)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"currentLabel")
            Parser (Maybe Text -> Event) -> Parser (Maybe Text) -> Parser Event
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventId")
      )

instance Prelude.Hashable Event

instance Prelude.NFData Event