module TD.Query.SetInactiveSessionTtl
  (SetInactiveSessionTtl(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Changes the period of inactivity after which sessions will automatically be terminated. Returns 'TD.Data.Ok.Ok'
data SetInactiveSessionTtl
  = SetInactiveSessionTtl
    { SetInactiveSessionTtl -> Maybe Int
inactive_session_ttl_days :: Maybe Int -- ^ New number of days of inactivity before sessions will be automatically terminated; 1-366 days
    }
  deriving (SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool
(SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool)
-> (SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool)
-> Eq SetInactiveSessionTtl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool
== :: SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool
$c/= :: SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool
/= :: SetInactiveSessionTtl -> SetInactiveSessionTtl -> Bool
Eq, Int -> SetInactiveSessionTtl -> ShowS
[SetInactiveSessionTtl] -> ShowS
SetInactiveSessionTtl -> String
(Int -> SetInactiveSessionTtl -> ShowS)
-> (SetInactiveSessionTtl -> String)
-> ([SetInactiveSessionTtl] -> ShowS)
-> Show SetInactiveSessionTtl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetInactiveSessionTtl -> ShowS
showsPrec :: Int -> SetInactiveSessionTtl -> ShowS
$cshow :: SetInactiveSessionTtl -> String
show :: SetInactiveSessionTtl -> String
$cshowList :: [SetInactiveSessionTtl] -> ShowS
showList :: [SetInactiveSessionTtl] -> ShowS
Show)

instance I.ShortShow SetInactiveSessionTtl where
  shortShow :: SetInactiveSessionTtl -> String
shortShow
    SetInactiveSessionTtl
      { inactive_session_ttl_days :: SetInactiveSessionTtl -> Maybe Int
inactive_session_ttl_days = Maybe Int
inactive_session_ttl_days_
      }
        = String
"SetInactiveSessionTtl"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"inactive_session_ttl_days" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
inactive_session_ttl_days_
          ]

instance AT.ToJSON SetInactiveSessionTtl where
  toJSON :: SetInactiveSessionTtl -> Value
toJSON
    SetInactiveSessionTtl
      { inactive_session_ttl_days :: SetInactiveSessionTtl -> Maybe Int
inactive_session_ttl_days = Maybe Int
inactive_session_ttl_days_
      }
        = [Pair] -> Value
A.object
          [ Key
"@type"                     Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"setInactiveSessionTtl"
          , Key
"inactive_session_ttl_days" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
inactive_session_ttl_days_
          ]