module TD.Query.SetAccountTtl
  (SetAccountTtl(..)
  ) where

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

-- | Changes the period of inactivity after which the account of the current user will automatically be deleted. Returns 'TD.Data.Ok.Ok'
data SetAccountTtl
  = SetAccountTtl
    { SetAccountTtl -> Maybe AccountTtl
ttl :: Maybe AccountTtl.AccountTtl -- ^ New account TTL
    }
  deriving (SetAccountTtl -> SetAccountTtl -> Bool
(SetAccountTtl -> SetAccountTtl -> Bool)
-> (SetAccountTtl -> SetAccountTtl -> Bool) -> Eq SetAccountTtl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetAccountTtl -> SetAccountTtl -> Bool
== :: SetAccountTtl -> SetAccountTtl -> Bool
$c/= :: SetAccountTtl -> SetAccountTtl -> Bool
/= :: SetAccountTtl -> SetAccountTtl -> Bool
Eq, Int -> SetAccountTtl -> ShowS
[SetAccountTtl] -> ShowS
SetAccountTtl -> String
(Int -> SetAccountTtl -> ShowS)
-> (SetAccountTtl -> String)
-> ([SetAccountTtl] -> ShowS)
-> Show SetAccountTtl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetAccountTtl -> ShowS
showsPrec :: Int -> SetAccountTtl -> ShowS
$cshow :: SetAccountTtl -> String
show :: SetAccountTtl -> String
$cshowList :: [SetAccountTtl] -> ShowS
showList :: [SetAccountTtl] -> ShowS
Show)

instance I.ShortShow SetAccountTtl where
  shortShow :: SetAccountTtl -> String
shortShow
    SetAccountTtl
      { ttl :: SetAccountTtl -> Maybe AccountTtl
ttl = Maybe AccountTtl
ttl_
      }
        = String
"SetAccountTtl"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"ttl" String -> Maybe AccountTtl -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AccountTtl
ttl_
          ]

instance AT.ToJSON SetAccountTtl where
  toJSON :: SetAccountTtl -> Value
toJSON
    SetAccountTtl
      { ttl :: SetAccountTtl -> Maybe AccountTtl
ttl = Maybe AccountTtl
ttl_
      }
        = [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
"setAccountTtl"
          , Key
"ttl"   Key -> Maybe AccountTtl -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe AccountTtl
ttl_
          ]