module TD.Query.TranslateText
(TranslateText(..)
, defaultTranslateText
) 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.FormattedText as FormattedText
import qualified Data.Text as T
data TranslateText
= TranslateText
{ TranslateText -> Maybe FormattedText
text :: Maybe FormattedText.FormattedText
, TranslateText -> Maybe Text
to_language_code :: Maybe T.Text
}
deriving (TranslateText -> TranslateText -> Bool
(TranslateText -> TranslateText -> Bool)
-> (TranslateText -> TranslateText -> Bool) -> Eq TranslateText
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TranslateText -> TranslateText -> Bool
== :: TranslateText -> TranslateText -> Bool
$c/= :: TranslateText -> TranslateText -> Bool
/= :: TranslateText -> TranslateText -> Bool
Eq, Int -> TranslateText -> ShowS
[TranslateText] -> ShowS
TranslateText -> String
(Int -> TranslateText -> ShowS)
-> (TranslateText -> String)
-> ([TranslateText] -> ShowS)
-> Show TranslateText
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TranslateText -> ShowS
showsPrec :: Int -> TranslateText -> ShowS
$cshow :: TranslateText -> String
show :: TranslateText -> String
$cshowList :: [TranslateText] -> ShowS
showList :: [TranslateText] -> ShowS
Show)
instance I.ShortShow TranslateText where
shortShow :: TranslateText -> String
shortShow
TranslateText
{ text :: TranslateText -> Maybe FormattedText
text = Maybe FormattedText
text_
, to_language_code :: TranslateText -> Maybe Text
to_language_code = Maybe Text
to_language_code_
}
= String
"TranslateText"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"text" String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
text_
, String
"to_language_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
to_language_code_
]
instance AT.ToJSON TranslateText where
toJSON :: TranslateText -> Value
toJSON
TranslateText
{ text :: TranslateText -> Maybe FormattedText
text = Maybe FormattedText
text_
, to_language_code :: TranslateText -> Maybe Text
to_language_code = Maybe Text
to_language_code_
}
= [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
"translateText"
, Key
"text" Key -> Maybe FormattedText -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe FormattedText
text_
, Key
"to_language_code" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
to_language_code_
]
defaultTranslateText :: TranslateText
defaultTranslateText :: TranslateText
defaultTranslateText =
TranslateText
{ text :: Maybe FormattedText
text = Maybe FormattedText
forall a. Maybe a
Nothing
, to_language_code :: Maybe Text
to_language_code = Maybe Text
forall a. Maybe a
Nothing
}