module TD.Query.SetOption
(SetOption(..)
, defaultSetOption
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.OptionValue as OptionValue
data SetOption
= SetOption
{ SetOption -> Maybe Text
name :: Maybe T.Text
, SetOption -> Maybe OptionValue
value :: Maybe OptionValue.OptionValue
}
deriving (SetOption -> SetOption -> Bool
(SetOption -> SetOption -> Bool)
-> (SetOption -> SetOption -> Bool) -> Eq SetOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetOption -> SetOption -> Bool
== :: SetOption -> SetOption -> Bool
$c/= :: SetOption -> SetOption -> Bool
/= :: SetOption -> SetOption -> Bool
Eq, Int -> SetOption -> ShowS
[SetOption] -> ShowS
SetOption -> String
(Int -> SetOption -> ShowS)
-> (SetOption -> String)
-> ([SetOption] -> ShowS)
-> Show SetOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetOption -> ShowS
showsPrec :: Int -> SetOption -> ShowS
$cshow :: SetOption -> String
show :: SetOption -> String
$cshowList :: [SetOption] -> ShowS
showList :: [SetOption] -> ShowS
Show)
instance I.ShortShow SetOption where
shortShow :: SetOption -> String
shortShow
SetOption
{ name :: SetOption -> Maybe Text
name = Maybe Text
name_
, value :: SetOption -> Maybe OptionValue
value = Maybe OptionValue
value_
}
= String
"SetOption"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
, String
"value" String -> Maybe OptionValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe OptionValue
value_
]
instance AT.ToJSON SetOption where
toJSON :: SetOption -> Value
toJSON
SetOption
{ name :: SetOption -> Maybe Text
name = Maybe Text
name_
, value :: SetOption -> Maybe OptionValue
value = Maybe OptionValue
value_
}
= [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
"setOption"
, Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
, Key
"value" Key -> Maybe OptionValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe OptionValue
value_
]
defaultSetOption :: SetOption
defaultSetOption :: SetOption
defaultSetOption =
SetOption
{ name :: Maybe Text
name = Maybe Text
forall a. Maybe a
Nothing
, value :: Maybe OptionValue
value = Maybe OptionValue
forall a. Maybe a
Nothing
}