{-# 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.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Session = Session'
{
Session -> Maybe Text
stopTimestamp :: Prelude.Maybe Prelude.Text,
Session -> Maybe Int
duration :: Prelude.Maybe Prelude.Int,
Session -> Text
startTimestamp :: Prelude.Text,
Session -> Text
id :: Prelude.Text
}
deriving (Session -> Session -> Bool
(Session -> Session -> Bool)
-> (Session -> Session -> Bool) -> Eq Session
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]
(Int -> ReadS Session)
-> ReadS [Session]
-> ReadPrec Session
-> ReadPrec [Session]
-> Read 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
(Int -> Session -> ShowS)
-> (Session -> String) -> ([Session] -> ShowS) -> Show Session
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. Session -> Rep Session x)
-> (forall x. Rep Session x -> Session) -> Generic Session
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' :: Maybe Text -> Maybe Int -> Text -> Text -> Session
Session'
{ $sel:stopTimestamp:Session' :: Maybe Text
stopTimestamp = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:duration:Session' :: Maybe Int
duration = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:startTimestamp:Session' :: Text
startTimestamp = Text
pStartTimestamp_,
$sel:id:Session' :: Text
id = Text
pId_
}
session_stopTimestamp :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_stopTimestamp :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_stopTimestamp = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
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_duration :: Lens.Lens' Session (Prelude.Maybe Prelude.Int)
session_duration :: (Maybe Int -> f (Maybe Int)) -> Session -> f Session
session_duration = (Session -> Maybe Int)
-> (Session -> Maybe Int -> Session)
-> Lens Session Session (Maybe Int) (Maybe Int)
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_startTimestamp :: Lens.Lens' Session Prelude.Text
session_startTimestamp :: (Text -> f Text) -> Session -> f Session
session_startTimestamp = (Session -> Text)
-> (Session -> Text -> Session) -> Lens Session Session Text Text
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 :: (Text -> f Text) -> Session -> f Session
session_id = (Session -> Text)
-> (Session -> Text -> Session) -> Lens Session Session Text Text
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
instance Prelude.NFData Session
instance Core.ToJSON Session where
toJSON :: Session -> Value
toJSON Session' {Maybe Int
Maybe Text
Text
id :: Text
startTimestamp :: Text
duration :: Maybe Int
stopTimestamp :: Maybe Text
$sel:id:Session' :: Session -> Text
$sel:startTimestamp:Session' :: Session -> Text
$sel:duration:Session' :: Session -> Maybe Int
$sel:stopTimestamp:Session' :: Session -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"StopTimestamp" 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
stopTimestamp,
(Text
"Duration" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
duration,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"StartTimestamp" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
startTimestamp),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
]
)