module TD.Query.GetMarkdownText
  (GetMarkdownText(..)
  ) 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

-- | Replaces text entities with Markdown formatting in a human-friendly format. Entities that can't be represented in Markdown unambiguously are kept as is. Can be called synchronously. Returns 'TD.Data.FormattedText.FormattedText'
data GetMarkdownText
  = GetMarkdownText
    { GetMarkdownText -> Maybe FormattedText
text :: Maybe FormattedText.FormattedText -- ^ The text
    }
  deriving (GetMarkdownText -> GetMarkdownText -> Bool
(GetMarkdownText -> GetMarkdownText -> Bool)
-> (GetMarkdownText -> GetMarkdownText -> Bool)
-> Eq GetMarkdownText
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetMarkdownText -> GetMarkdownText -> Bool
== :: GetMarkdownText -> GetMarkdownText -> Bool
$c/= :: GetMarkdownText -> GetMarkdownText -> Bool
/= :: GetMarkdownText -> GetMarkdownText -> Bool
Eq, Int -> GetMarkdownText -> ShowS
[GetMarkdownText] -> ShowS
GetMarkdownText -> String
(Int -> GetMarkdownText -> ShowS)
-> (GetMarkdownText -> String)
-> ([GetMarkdownText] -> ShowS)
-> Show GetMarkdownText
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetMarkdownText -> ShowS
showsPrec :: Int -> GetMarkdownText -> ShowS
$cshow :: GetMarkdownText -> String
show :: GetMarkdownText -> String
$cshowList :: [GetMarkdownText] -> ShowS
showList :: [GetMarkdownText] -> ShowS
Show)

instance I.ShortShow GetMarkdownText where
  shortShow :: GetMarkdownText -> String
shortShow
    GetMarkdownText
      { text :: GetMarkdownText -> Maybe FormattedText
text = Maybe FormattedText
text_
      }
        = String
"GetMarkdownText"
          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_
          ]

instance AT.ToJSON GetMarkdownText where
  toJSON :: GetMarkdownText -> Value
toJSON
    GetMarkdownText
      { text :: GetMarkdownText -> Maybe FormattedText
text = Maybe FormattedText
text_
      }
        = [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
"getMarkdownText"
          , 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_
          ]