{-# 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 #-}
module Amazonka.PersonalizeEvents.Types.Event where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Event = Event'
{
Event -> Maybe Text
recommendationId :: Prelude.Maybe Prelude.Text,
Event -> Maybe Double
eventValue :: Prelude.Maybe Prelude.Double,
Event -> Maybe Text
itemId :: Prelude.Maybe Prelude.Text,
Event -> Maybe (NonEmpty Text)
impression :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
Event -> Maybe Text
eventId :: Prelude.Maybe Prelude.Text,
Event -> Maybe Text
properties :: Prelude.Maybe Prelude.Text,
Event -> Text
eventType :: Prelude.Text,
Event -> POSIX
sentAt :: Core.POSIX
}
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, ReadPrec [Event]
ReadPrec Event
Int -> ReadS Event
ReadS [Event]
(Int -> ReadS Event)
-> ReadS [Event]
-> ReadPrec Event
-> ReadPrec [Event]
-> Read Event
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Event]
$creadListPrec :: ReadPrec [Event]
readPrec :: ReadPrec Event
$creadPrec :: ReadPrec Event
readList :: ReadS [Event]
$creadList :: ReadS [Event]
readsPrec :: Int -> ReadS Event
$creadsPrec :: Int -> ReadS Event
Prelude.Read, 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)
newEvent ::
Prelude.Text ->
Prelude.UTCTime ->
Event
newEvent :: Text -> UTCTime -> Event
newEvent Text
pEventType_ UTCTime
pSentAt_ =
Event' :: Maybe Text
-> Maybe Double
-> Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Text
-> POSIX
-> Event
Event'
{ $sel:recommendationId:Event' :: Maybe Text
recommendationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:eventValue:Event' :: Maybe Double
eventValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
$sel:itemId:Event' :: Maybe Text
itemId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:impression:Event' :: Maybe (NonEmpty Text)
impression = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
$sel:eventId:Event' :: Maybe Text
eventId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:properties:Event' :: Maybe Text
properties = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:eventType:Event' :: Text
eventType = Text
pEventType_,
$sel:sentAt:Event' :: POSIX
sentAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
-> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pSentAt_
}
event_recommendationId :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_recommendationId :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_recommendationId = (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
recommendationId :: Maybe Text
$sel:recommendationId:Event' :: Event -> Maybe Text
recommendationId} -> Maybe Text
recommendationId) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:recommendationId:Event' :: Maybe Text
recommendationId = Maybe Text
a} :: Event)
event_eventValue :: Lens.Lens' Event (Prelude.Maybe Prelude.Double)
event_eventValue :: (Maybe Double -> f (Maybe Double)) -> Event -> f Event
event_eventValue = (Event -> Maybe Double)
-> (Event -> Maybe Double -> Event)
-> Lens Event Event (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Double
eventValue :: Maybe Double
$sel:eventValue:Event' :: Event -> Maybe Double
eventValue} -> Maybe Double
eventValue) (\s :: Event
s@Event' {} Maybe Double
a -> Event
s {$sel:eventValue:Event' :: Maybe Double
eventValue = Maybe Double
a} :: Event)
event_itemId :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_itemId :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_itemId = (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
itemId :: Maybe Text
$sel:itemId:Event' :: Event -> Maybe Text
itemId} -> Maybe Text
itemId) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:itemId:Event' :: Maybe Text
itemId = Maybe Text
a} :: Event)
event_impression :: Lens.Lens' Event (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
event_impression :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Event -> f Event
event_impression = (Event -> Maybe (NonEmpty Text))
-> (Event -> Maybe (NonEmpty Text) -> Event)
-> Lens Event Event (Maybe (NonEmpty Text)) (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe (NonEmpty Text)
impression :: Maybe (NonEmpty Text)
$sel:impression:Event' :: Event -> Maybe (NonEmpty Text)
impression} -> Maybe (NonEmpty Text)
impression) (\s :: Event
s@Event' {} Maybe (NonEmpty Text)
a -> Event
s {$sel:impression:Event' :: Maybe (NonEmpty Text)
impression = Maybe (NonEmpty Text)
a} :: Event) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Event -> f Event)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty 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
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
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)
event_properties :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_properties :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_properties = (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
properties :: Maybe Text
$sel:properties:Event' :: Event -> Maybe Text
properties} -> Maybe Text
properties) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:properties:Event' :: Maybe Text
properties = Maybe Text
a} :: Event)
event_eventType :: Lens.Lens' Event Prelude.Text
event_eventType :: (Text -> f Text) -> Event -> f Event
event_eventType = (Event -> Text)
-> (Event -> Text -> Event) -> Lens Event Event Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Text
eventType :: Text
$sel:eventType:Event' :: Event -> Text
eventType} -> Text
eventType) (\s :: Event
s@Event' {} Text
a -> Event
s {$sel:eventType:Event' :: Text
eventType = Text
a} :: Event)
event_sentAt :: Lens.Lens' Event Prelude.UTCTime
event_sentAt :: (UTCTime -> f UTCTime) -> Event -> f Event
event_sentAt = (Event -> POSIX)
-> (Event -> POSIX -> Event) -> Lens Event Event POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {POSIX
sentAt :: POSIX
$sel:sentAt:Event' :: Event -> POSIX
sentAt} -> POSIX
sentAt) (\s :: Event
s@Event' {} POSIX
a -> Event
s {$sel:sentAt:Event' :: POSIX
sentAt = POSIX
a} :: Event) ((POSIX -> f POSIX) -> Event -> f Event)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
instance Prelude.Hashable Event
instance Prelude.NFData Event
instance Core.ToJSON Event where
toJSON :: Event -> Value
toJSON Event' {Maybe Double
Maybe (NonEmpty Text)
Maybe Text
Text
POSIX
sentAt :: POSIX
eventType :: Text
properties :: Maybe Text
eventId :: Maybe Text
impression :: Maybe (NonEmpty Text)
itemId :: Maybe Text
eventValue :: Maybe Double
recommendationId :: Maybe Text
$sel:sentAt:Event' :: Event -> POSIX
$sel:eventType:Event' :: Event -> Text
$sel:properties:Event' :: Event -> Maybe Text
$sel:eventId:Event' :: Event -> Maybe Text
$sel:impression:Event' :: Event -> Maybe (NonEmpty Text)
$sel:itemId:Event' :: Event -> Maybe Text
$sel:eventValue:Event' :: Event -> Maybe Double
$sel:recommendationId:Event' :: Event -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"recommendationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
recommendationId,
(Text
"eventValue" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
eventValue,
(Text
"itemId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
itemId,
(Text
"impression" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
impression,
(Text
"eventId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eventId,
(Text
"properties" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
properties,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"eventType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
eventType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"sentAt" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
sentAt)
]
)