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

-- | Returns all entities (mentions, hashtags, cashtags, bot commands, bank card numbers, URLs, and email addresses) found in the text. Can be called synchronously. Returns 'TD.Data.TextEntities.TextEntities'
data GetTextEntities
  = GetTextEntities
    { GetTextEntities -> Maybe Text
text :: Maybe T.Text -- ^ The text in which to look for entities
    }
  deriving (GetTextEntities -> GetTextEntities -> Bool
(GetTextEntities -> GetTextEntities -> Bool)
-> (GetTextEntities -> GetTextEntities -> Bool)
-> Eq GetTextEntities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTextEntities -> GetTextEntities -> Bool
== :: GetTextEntities -> GetTextEntities -> Bool
$c/= :: GetTextEntities -> GetTextEntities -> Bool
/= :: GetTextEntities -> GetTextEntities -> Bool
Eq, Int -> GetTextEntities -> ShowS
[GetTextEntities] -> ShowS
GetTextEntities -> String
(Int -> GetTextEntities -> ShowS)
-> (GetTextEntities -> String)
-> ([GetTextEntities] -> ShowS)
-> Show GetTextEntities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTextEntities -> ShowS
showsPrec :: Int -> GetTextEntities -> ShowS
$cshow :: GetTextEntities -> String
show :: GetTextEntities -> String
$cshowList :: [GetTextEntities] -> ShowS
showList :: [GetTextEntities] -> ShowS
Show)

instance I.ShortShow GetTextEntities where
  shortShow :: GetTextEntities -> String
shortShow
    GetTextEntities
      { text :: GetTextEntities -> Maybe Text
text = Maybe Text
text_
      }
        = String
"GetTextEntities"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"text" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
text_
          ]

instance AT.ToJSON GetTextEntities where
  toJSON :: GetTextEntities -> Value
toJSON
    GetTextEntities
      { text :: GetTextEntities -> Maybe Text
text = Maybe Text
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
"getTextEntities"
          , Key
"text"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
text_
          ]