{-# 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.Pinpoint.Types.Session where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data Session = Session'
{
Session -> Maybe Int
duration :: Prelude.Maybe Prelude.Int,
Session -> Maybe Text
stopTimestamp :: Prelude.Maybe Prelude.Text,
Session -> Text
startTimestamp :: Prelude.Text,
Session -> Text
id :: Prelude.Text
}
deriving (Session -> Session -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Session -> Session -> Bool
$c/= :: Session -> Session -> Bool
== :: Session -> Session -> Bool
$c== :: Session -> Session -> Bool
Prelude.Eq, ReadPrec [Session]
ReadPrec Session
Int -> ReadS Session
ReadS [Session]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Session]
$creadListPrec :: ReadPrec [Session]
readPrec :: ReadPrec Session
$creadPrec :: ReadPrec Session
readList :: ReadS [Session]
$creadList :: ReadS [Session]
readsPrec :: Int -> ReadS Session
$creadsPrec :: Int -> ReadS Session
Prelude.Read, Int -> Session -> ShowS
[Session] -> ShowS
Session -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Session] -> ShowS
$cshowList :: [Session] -> ShowS
show :: Session -> String
$cshow :: Session -> String
showsPrec :: Int -> Session -> ShowS
$cshowsPrec :: Int -> Session -> ShowS
Prelude.Show, forall x. Rep Session x -> Session
forall x. Session -> Rep Session x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Session x -> Session
$cfrom :: forall x. Session -> Rep Session x
Prelude.Generic)
newSession ::
Prelude.Text ->
Prelude.Text ->
Session
newSession :: Text -> Text -> Session
newSession Text
pStartTimestamp_ Text
pId_ =
Session'
{ $sel:duration:Session' :: Maybe Int
duration = forall a. Maybe a
Prelude.Nothing,
$sel:stopTimestamp:Session' :: Maybe Text
stopTimestamp = forall a. Maybe a
Prelude.Nothing,
$sel:startTimestamp:Session' :: Text
startTimestamp = Text
pStartTimestamp_,
$sel:id:Session' :: Text
id = Text
pId_
}
session_duration :: Lens.Lens' Session (Prelude.Maybe Prelude.Int)
session_duration :: Lens' Session (Maybe Int)
session_duration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Int
duration :: Maybe Int
$sel:duration:Session' :: Session -> Maybe Int
duration} -> Maybe Int
duration) (\s :: Session
s@Session' {} Maybe Int
a -> Session
s {$sel:duration:Session' :: Maybe Int
duration = Maybe Int
a} :: Session)
session_stopTimestamp :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_stopTimestamp :: Lens' Session (Maybe Text)
session_stopTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
stopTimestamp :: Maybe Text
$sel:stopTimestamp:Session' :: Session -> Maybe Text
stopTimestamp} -> Maybe Text
stopTimestamp) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:stopTimestamp:Session' :: Maybe Text
stopTimestamp = Maybe Text
a} :: Session)
session_startTimestamp :: Lens.Lens' Session Prelude.Text
session_startTimestamp :: Lens' Session Text
session_startTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Text
startTimestamp :: Text
$sel:startTimestamp:Session' :: Session -> Text
startTimestamp} -> Text
startTimestamp) (\s :: Session
s@Session' {} Text
a -> Session
s {$sel:startTimestamp:Session' :: Text
startTimestamp = Text
a} :: Session)
session_id :: Lens.Lens' Session Prelude.Text
session_id :: Lens' Session Text
session_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Text
id :: Text
$sel:id:Session' :: Session -> Text
id} -> Text
id) (\s :: Session
s@Session' {} Text
a -> Session
s {$sel:id:Session' :: Text
id = Text
a} :: Session)
instance Prelude.Hashable Session where
hashWithSalt :: Int -> Session -> Int
hashWithSalt Int
_salt Session' {Maybe Int
Maybe Text
Text
id :: Text
startTimestamp :: Text
stopTimestamp :: Maybe Text
duration :: Maybe Int
$sel:id:Session' :: Session -> Text
$sel:startTimestamp:Session' :: Session -> Text
$sel:stopTimestamp:Session' :: Session -> Maybe Text
$sel:duration:Session' :: Session -> Maybe Int
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
duration
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stopTimestamp
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
startTimestamp
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
instance Prelude.NFData Session where
rnf :: Session -> ()
rnf Session' {Maybe Int
Maybe Text
Text
id :: Text
startTimestamp :: Text
stopTimestamp :: Maybe Text
duration :: Maybe Int
$sel:id:Session' :: Session -> Text
$sel:startTimestamp:Session' :: Session -> Text
$sel:stopTimestamp:Session' :: Session -> Maybe Text
$sel:duration:Session' :: Session -> Maybe Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
duration
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stopTimestamp
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
startTimestamp
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
instance Data.ToJSON Session where
toJSON :: Session -> Value
toJSON Session' {Maybe Int
Maybe Text
Text
id :: Text
startTimestamp :: Text
stopTimestamp :: Maybe Text
duration :: Maybe Int
$sel:id:Session' :: Session -> Text
$sel:startTimestamp:Session' :: Session -> Text
$sel:stopTimestamp:Session' :: Session -> Maybe Text
$sel:duration:Session' :: Session -> Maybe Int
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Duration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
duration,
(Key
"StopTimestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
stopTimestamp,
forall a. a -> Maybe a
Prelude.Just
(Key
"StartTimestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
startTimestamp),
forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
]
)