module TD.Query.SetAlarm
  (SetAlarm(..)
  ) where

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

-- | Succeeds after a specified amount of time has passed. Can be called before initialization. Returns 'TD.Data.Ok.Ok'
data SetAlarm
  = SetAlarm
    { SetAlarm -> Maybe Double
seconds :: Maybe Double -- ^ Number of seconds before the function returns
    }
  deriving (SetAlarm -> SetAlarm -> Bool
(SetAlarm -> SetAlarm -> Bool)
-> (SetAlarm -> SetAlarm -> Bool) -> Eq SetAlarm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetAlarm -> SetAlarm -> Bool
== :: SetAlarm -> SetAlarm -> Bool
$c/= :: SetAlarm -> SetAlarm -> Bool
/= :: SetAlarm -> SetAlarm -> Bool
Eq, Int -> SetAlarm -> ShowS
[SetAlarm] -> ShowS
SetAlarm -> String
(Int -> SetAlarm -> ShowS)
-> (SetAlarm -> String) -> ([SetAlarm] -> ShowS) -> Show SetAlarm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetAlarm -> ShowS
showsPrec :: Int -> SetAlarm -> ShowS
$cshow :: SetAlarm -> String
show :: SetAlarm -> String
$cshowList :: [SetAlarm] -> ShowS
showList :: [SetAlarm] -> ShowS
Show)

instance I.ShortShow SetAlarm where
  shortShow :: SetAlarm -> String
shortShow
    SetAlarm
      { seconds :: SetAlarm -> Maybe Double
seconds = Maybe Double
seconds_
      }
        = String
"SetAlarm"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"seconds" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
seconds_
          ]

instance AT.ToJSON SetAlarm where
  toJSON :: SetAlarm -> Value
toJSON
    SetAlarm
      { seconds :: SetAlarm -> Maybe Double
seconds = Maybe Double
seconds_
      }
        = [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
"setAlarm"
          , Key
"seconds" Key -> Maybe Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Double
seconds_
          ]