module TD.Data.TextEntityType
  (TextEntityType(..)) 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

-- | Represents a part of the text which must be formatted differently
data TextEntityType
  = TextEntityTypeMention -- ^ A mention of a user, a supergroup, or a channel by their username
  | TextEntityTypeHashtag -- ^ A hashtag text, beginning with "#" and optionally containing a chat username at the end
  | TextEntityTypeCashtag -- ^ A cashtag text, beginning with "$", consisting of capital English letters (e.g., "$USD"), and optionally containing a chat username at the end
  | TextEntityTypeBotCommand -- ^ A bot command, beginning with "/"
  | TextEntityTypeUrl -- ^ An HTTP URL
  | TextEntityTypeEmailAddress -- ^ An email address
  | TextEntityTypePhoneNumber -- ^ A phone number
  | TextEntityTypeBankCardNumber -- ^ A bank card number. The getBankCardInfo method can be used to get information about the bank card
  | TextEntityTypeBold -- ^ A bold text
  | TextEntityTypeItalic -- ^ An italic text
  | TextEntityTypeUnderline -- ^ An underlined text
  | TextEntityTypeStrikethrough -- ^ A strikethrough text
  | TextEntityTypeSpoiler -- ^ A spoiler text
  | TextEntityTypeCode -- ^ Text that must be formatted as if inside a code HTML tag
  | TextEntityTypePre -- ^ Text that must be formatted as if inside a pre HTML tag
  | TextEntityTypePreCode -- ^ Text that must be formatted as if inside pre, and code HTML tags
    { TextEntityType -> Maybe Text
language :: Maybe T.Text -- ^ Programming language of the code; as defined by the sender
    }
  | TextEntityTypeBlockQuote -- ^ Text that must be formatted as if inside a blockquote HTML tag; not supported in secret chats
  | TextEntityTypeExpandableBlockQuote -- ^ Text that must be formatted as if inside a blockquote HTML tag and collapsed by default to 3 lines with the ability to show full text; not supported in secret chats
  | TextEntityTypeTextUrl -- ^ A text description shown instead of a raw URL
    { TextEntityType -> Maybe Text
url :: Maybe T.Text -- ^ HTTP or tg:// URL to be opened when the link is clicked
    }
  | TextEntityTypeMentionName -- ^ A text shows instead of a raw mention of the user (e.g., when the user has no username)
    { TextEntityType -> Maybe Int
user_id :: Maybe Int -- ^ Identifier of the mentioned user
    }
  | TextEntityTypeCustomEmoji -- ^ A custom emoji. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji
    { TextEntityType -> Maybe Int
custom_emoji_id :: Maybe Int -- ^ Unique identifier of the custom emoji
    }
  | TextEntityTypeMediaTimestamp -- ^ A media timestamp
    { TextEntityType -> Maybe Int
media_timestamp :: Maybe Int -- ^ Timestamp from which a video/audio/video note/voice note/story playing must start, in seconds. The media can be in the content or the link preview of the current message, or in the same places in the replied message
    }
  deriving (TextEntityType -> TextEntityType -> Bool
(TextEntityType -> TextEntityType -> Bool)
-> (TextEntityType -> TextEntityType -> Bool) -> Eq TextEntityType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TextEntityType -> TextEntityType -> Bool
== :: TextEntityType -> TextEntityType -> Bool
$c/= :: TextEntityType -> TextEntityType -> Bool
/= :: TextEntityType -> TextEntityType -> Bool
Eq, Int -> TextEntityType -> ShowS
[TextEntityType] -> ShowS
TextEntityType -> String
(Int -> TextEntityType -> ShowS)
-> (TextEntityType -> String)
-> ([TextEntityType] -> ShowS)
-> Show TextEntityType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TextEntityType -> ShowS
showsPrec :: Int -> TextEntityType -> ShowS
$cshow :: TextEntityType -> String
show :: TextEntityType -> String
$cshowList :: [TextEntityType] -> ShowS
showList :: [TextEntityType] -> ShowS
Show)

instance I.ShortShow TextEntityType where
  shortShow :: TextEntityType -> String
shortShow TextEntityType
TextEntityTypeMention
      = String
"TextEntityTypeMention"
  shortShow TextEntityType
TextEntityTypeHashtag
      = String
"TextEntityTypeHashtag"
  shortShow TextEntityType
TextEntityTypeCashtag
      = String
"TextEntityTypeCashtag"
  shortShow TextEntityType
TextEntityTypeBotCommand
      = String
"TextEntityTypeBotCommand"
  shortShow TextEntityType
TextEntityTypeUrl
      = String
"TextEntityTypeUrl"
  shortShow TextEntityType
TextEntityTypeEmailAddress
      = String
"TextEntityTypeEmailAddress"
  shortShow TextEntityType
TextEntityTypePhoneNumber
      = String
"TextEntityTypePhoneNumber"
  shortShow TextEntityType
TextEntityTypeBankCardNumber
      = String
"TextEntityTypeBankCardNumber"
  shortShow TextEntityType
TextEntityTypeBold
      = String
"TextEntityTypeBold"
  shortShow TextEntityType
TextEntityTypeItalic
      = String
"TextEntityTypeItalic"
  shortShow TextEntityType
TextEntityTypeUnderline
      = String
"TextEntityTypeUnderline"
  shortShow TextEntityType
TextEntityTypeStrikethrough
      = String
"TextEntityTypeStrikethrough"
  shortShow TextEntityType
TextEntityTypeSpoiler
      = String
"TextEntityTypeSpoiler"
  shortShow TextEntityType
TextEntityTypeCode
      = String
"TextEntityTypeCode"
  shortShow TextEntityType
TextEntityTypePre
      = String
"TextEntityTypePre"
  shortShow TextEntityTypePreCode
    { language :: TextEntityType -> Maybe Text
language = Maybe Text
language_
    }
      = String
"TextEntityTypePreCode"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"language" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_
        ]
  shortShow TextEntityType
TextEntityTypeBlockQuote
      = String
"TextEntityTypeBlockQuote"
  shortShow TextEntityType
TextEntityTypeExpandableBlockQuote
      = String
"TextEntityTypeExpandableBlockQuote"
  shortShow TextEntityTypeTextUrl
    { url :: TextEntityType -> Maybe Text
url = Maybe Text
url_
    }
      = String
"TextEntityTypeTextUrl"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
        ]
  shortShow TextEntityTypeMentionName
    { user_id :: TextEntityType -> Maybe Int
user_id = Maybe Int
user_id_
    }
      = String
"TextEntityTypeMentionName"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
        ]
  shortShow TextEntityTypeCustomEmoji
    { custom_emoji_id :: TextEntityType -> Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
    }
      = String
"TextEntityTypeCustomEmoji"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
custom_emoji_id_
        ]
  shortShow TextEntityTypeMediaTimestamp
    { media_timestamp :: TextEntityType -> Maybe Int
media_timestamp = Maybe Int
media_timestamp_
    }
      = String
"TextEntityTypeMediaTimestamp"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"media_timestamp" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
media_timestamp_
        ]

instance AT.FromJSON TextEntityType where
  parseJSON :: Value -> Parser TextEntityType
parseJSON v :: Value
v@(AT.Object Object
obj) = do
    String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String

    case String
t of
      String
"textEntityTypeMention"              -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeMention
      String
"textEntityTypeHashtag"              -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeHashtag
      String
"textEntityTypeCashtag"              -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeCashtag
      String
"textEntityTypeBotCommand"           -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeBotCommand
      String
"textEntityTypeUrl"                  -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeUrl
      String
"textEntityTypeEmailAddress"         -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeEmailAddress
      String
"textEntityTypePhoneNumber"          -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypePhoneNumber
      String
"textEntityTypeBankCardNumber"       -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeBankCardNumber
      String
"textEntityTypeBold"                 -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeBold
      String
"textEntityTypeItalic"               -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeItalic
      String
"textEntityTypeUnderline"            -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeUnderline
      String
"textEntityTypeStrikethrough"        -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeStrikethrough
      String
"textEntityTypeSpoiler"              -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeSpoiler
      String
"textEntityTypeCode"                 -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeCode
      String
"textEntityTypePre"                  -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypePre
      String
"textEntityTypePreCode"              -> Value -> Parser TextEntityType
parseTextEntityTypePreCode Value
v
      String
"textEntityTypeBlockQuote"           -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeBlockQuote
      String
"textEntityTypeExpandableBlockQuote" -> TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TextEntityType
TextEntityTypeExpandableBlockQuote
      String
"textEntityTypeTextUrl"              -> Value -> Parser TextEntityType
parseTextEntityTypeTextUrl Value
v
      String
"textEntityTypeMentionName"          -> Value -> Parser TextEntityType
parseTextEntityTypeMentionName Value
v
      String
"textEntityTypeCustomEmoji"          -> Value -> Parser TextEntityType
parseTextEntityTypeCustomEmoji Value
v
      String
"textEntityTypeMediaTimestamp"       -> Value -> Parser TextEntityType
parseTextEntityTypeMediaTimestamp Value
v
      String
_                                    -> Parser TextEntityType
forall a. Monoid a => a
mempty
    
    where
      parseTextEntityTypePreCode :: A.Value -> AT.Parser TextEntityType
      parseTextEntityTypePreCode :: Value -> Parser TextEntityType
parseTextEntityTypePreCode = String
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TextEntityTypePreCode" ((Object -> Parser TextEntityType)
 -> Value -> Parser TextEntityType)
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
language_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"language"
        TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TextEntityType -> Parser TextEntityType)
-> TextEntityType -> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ TextEntityTypePreCode
          { language :: Maybe Text
language = Maybe Text
language_
          }
      parseTextEntityTypeTextUrl :: A.Value -> AT.Parser TextEntityType
      parseTextEntityTypeTextUrl :: Value -> Parser TextEntityType
parseTextEntityTypeTextUrl = String
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TextEntityTypeTextUrl" ((Object -> Parser TextEntityType)
 -> Value -> Parser TextEntityType)
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"url"
        TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TextEntityType -> Parser TextEntityType)
-> TextEntityType -> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ TextEntityTypeTextUrl
          { url :: Maybe Text
url = Maybe Text
url_
          }
      parseTextEntityTypeMentionName :: A.Value -> AT.Parser TextEntityType
      parseTextEntityTypeMentionName :: Value -> Parser TextEntityType
parseTextEntityTypeMentionName = String
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TextEntityTypeMentionName" ((Object -> Parser TextEntityType)
 -> Value -> Parser TextEntityType)
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"user_id"
        TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TextEntityType -> Parser TextEntityType)
-> TextEntityType -> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ TextEntityTypeMentionName
          { user_id :: Maybe Int
user_id = Maybe Int
user_id_
          }
      parseTextEntityTypeCustomEmoji :: A.Value -> AT.Parser TextEntityType
      parseTextEntityTypeCustomEmoji :: Value -> Parser TextEntityType
parseTextEntityTypeCustomEmoji = String
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TextEntityTypeCustomEmoji" ((Object -> Parser TextEntityType)
 -> Value -> Parser TextEntityType)
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
custom_emoji_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"custom_emoji_id"
        TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TextEntityType -> Parser TextEntityType)
-> TextEntityType -> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ TextEntityTypeCustomEmoji
          { custom_emoji_id :: Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
          }
      parseTextEntityTypeMediaTimestamp :: A.Value -> AT.Parser TextEntityType
      parseTextEntityTypeMediaTimestamp :: Value -> Parser TextEntityType
parseTextEntityTypeMediaTimestamp = String
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TextEntityTypeMediaTimestamp" ((Object -> Parser TextEntityType)
 -> Value -> Parser TextEntityType)
-> (Object -> Parser TextEntityType)
-> Value
-> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
media_timestamp_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"media_timestamp"
        TextEntityType -> Parser TextEntityType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TextEntityType -> Parser TextEntityType)
-> TextEntityType -> Parser TextEntityType
forall a b. (a -> b) -> a -> b
$ TextEntityTypeMediaTimestamp
          { media_timestamp :: Maybe Int
media_timestamp = Maybe Int
media_timestamp_
          }
  parseJSON Value
_ = Parser TextEntityType
forall a. Monoid a => a
mempty

instance AT.ToJSON TextEntityType where
  toJSON :: TextEntityType -> Value
toJSON TextEntityType
TextEntityTypeMention
      = [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
"textEntityTypeMention"
        ]
  toJSON TextEntityType
TextEntityTypeHashtag
      = [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
"textEntityTypeHashtag"
        ]
  toJSON TextEntityType
TextEntityTypeCashtag
      = [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
"textEntityTypeCashtag"
        ]
  toJSON TextEntityType
TextEntityTypeBotCommand
      = [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
"textEntityTypeBotCommand"
        ]
  toJSON TextEntityType
TextEntityTypeUrl
      = [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
"textEntityTypeUrl"
        ]
  toJSON TextEntityType
TextEntityTypeEmailAddress
      = [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
"textEntityTypeEmailAddress"
        ]
  toJSON TextEntityType
TextEntityTypePhoneNumber
      = [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
"textEntityTypePhoneNumber"
        ]
  toJSON TextEntityType
TextEntityTypeBankCardNumber
      = [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
"textEntityTypeBankCardNumber"
        ]
  toJSON TextEntityType
TextEntityTypeBold
      = [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
"textEntityTypeBold"
        ]
  toJSON TextEntityType
TextEntityTypeItalic
      = [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
"textEntityTypeItalic"
        ]
  toJSON TextEntityType
TextEntityTypeUnderline
      = [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
"textEntityTypeUnderline"
        ]
  toJSON TextEntityType
TextEntityTypeStrikethrough
      = [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
"textEntityTypeStrikethrough"
        ]
  toJSON TextEntityType
TextEntityTypeSpoiler
      = [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
"textEntityTypeSpoiler"
        ]
  toJSON TextEntityType
TextEntityTypeCode
      = [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
"textEntityTypeCode"
        ]
  toJSON TextEntityType
TextEntityTypePre
      = [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
"textEntityTypePre"
        ]
  toJSON TextEntityTypePreCode
    { language :: TextEntityType -> Maybe Text
language = Maybe Text
language_
    }
      = [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
"textEntityTypePreCode"
        , Key
"language" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
language_
        ]
  toJSON TextEntityType
TextEntityTypeBlockQuote
      = [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
"textEntityTypeBlockQuote"
        ]
  toJSON TextEntityType
TextEntityTypeExpandableBlockQuote
      = [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
"textEntityTypeExpandableBlockQuote"
        ]
  toJSON TextEntityTypeTextUrl
    { url :: TextEntityType -> Maybe Text
url = Maybe Text
url_
    }
      = [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
"textEntityTypeTextUrl"
        , Key
"url"   Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
url_
        ]
  toJSON TextEntityTypeMentionName
    { user_id :: TextEntityType -> Maybe Int
user_id = Maybe Int
user_id_
    }
      = [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
"textEntityTypeMentionName"
        , Key
"user_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
user_id_
        ]
  toJSON TextEntityTypeCustomEmoji
    { custom_emoji_id :: TextEntityType -> Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
    }
      = [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
"textEntityTypeCustomEmoji"
        , Key
"custom_emoji_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
custom_emoji_id_
        ]
  toJSON TextEntityTypeMediaTimestamp
    { media_timestamp :: TextEntityType -> Maybe Int
media_timestamp = Maybe Int
media_timestamp_
    }
      = [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
"textEntityTypeMediaTimestamp"
        , Key
"media_timestamp" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
media_timestamp_
        ]