module TD.Query.ComposeTextWithAi
  (ComposeTextWithAi(..)
  , defaultComposeTextWithAi
  ) 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

-- | Changes text using an AI model; must not be used in secret chats. May return an error with a message "AICOMPOSE_FLOOD_PREMIUM" if Telegram Premium is required to send further requests. Returns 'TD.Data.FormattedText.FormattedText'
data ComposeTextWithAi
  = ComposeTextWithAi
    { ComposeTextWithAi -> Maybe FormattedText
text                       :: Maybe FormattedText.FormattedText -- ^ The original text
    , ComposeTextWithAi -> Maybe Text
translate_to_language_code :: Maybe T.Text                      -- ^ Pass a language code to which the text will be translated; pass an empty string if translation isn't needed. See translateText.to_language_code for the list of supported values
    , ComposeTextWithAi -> Maybe Text
style_name                 :: Maybe T.Text                      -- ^ Name of the style of the resulted text; handle updateTextCompositionStyles to get the list of supported styles; pass an empty string to keep the current style of the text
    , ComposeTextWithAi -> Maybe Bool
add_emojis                 :: Maybe Bool                        -- ^ Pass true to add emoji to the text
    }
  deriving (ComposeTextWithAi -> ComposeTextWithAi -> Bool
(ComposeTextWithAi -> ComposeTextWithAi -> Bool)
-> (ComposeTextWithAi -> ComposeTextWithAi -> Bool)
-> Eq ComposeTextWithAi
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ComposeTextWithAi -> ComposeTextWithAi -> Bool
== :: ComposeTextWithAi -> ComposeTextWithAi -> Bool
$c/= :: ComposeTextWithAi -> ComposeTextWithAi -> Bool
/= :: ComposeTextWithAi -> ComposeTextWithAi -> Bool
Eq, Int -> ComposeTextWithAi -> ShowS
[ComposeTextWithAi] -> ShowS
ComposeTextWithAi -> String
(Int -> ComposeTextWithAi -> ShowS)
-> (ComposeTextWithAi -> String)
-> ([ComposeTextWithAi] -> ShowS)
-> Show ComposeTextWithAi
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ComposeTextWithAi -> ShowS
showsPrec :: Int -> ComposeTextWithAi -> ShowS
$cshow :: ComposeTextWithAi -> String
show :: ComposeTextWithAi -> String
$cshowList :: [ComposeTextWithAi] -> ShowS
showList :: [ComposeTextWithAi] -> ShowS
Show)

instance I.ShortShow ComposeTextWithAi where
  shortShow :: ComposeTextWithAi -> String
shortShow
    ComposeTextWithAi
      { text :: ComposeTextWithAi -> Maybe FormattedText
text                       = Maybe FormattedText
text_
      , translate_to_language_code :: ComposeTextWithAi -> Maybe Text
translate_to_language_code = Maybe Text
translate_to_language_code_
      , style_name :: ComposeTextWithAi -> Maybe Text
style_name                 = Maybe Text
style_name_
      , add_emojis :: ComposeTextWithAi -> Maybe Bool
add_emojis                 = Maybe Bool
add_emojis_
      }
        = String
"ComposeTextWithAi"
          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
"translate_to_language_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
translate_to_language_code_
          , String
"style_name"                 String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
style_name_
          , String
"add_emojis"                 String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
add_emojis_
          ]

instance AT.ToJSON ComposeTextWithAi where
  toJSON :: ComposeTextWithAi -> Value
toJSON
    ComposeTextWithAi
      { text :: ComposeTextWithAi -> Maybe FormattedText
text                       = Maybe FormattedText
text_
      , translate_to_language_code :: ComposeTextWithAi -> Maybe Text
translate_to_language_code = Maybe Text
translate_to_language_code_
      , style_name :: ComposeTextWithAi -> Maybe Text
style_name                 = Maybe Text
style_name_
      , add_emojis :: ComposeTextWithAi -> Maybe Bool
add_emojis                 = Maybe Bool
add_emojis_
      }
        = [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
"composeTextWithAi"
          , 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
"translate_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
translate_to_language_code_
          , Key
"style_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
style_name_
          , Key
"add_emojis"                 Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
add_emojis_
          ]

defaultComposeTextWithAi :: ComposeTextWithAi
defaultComposeTextWithAi :: ComposeTextWithAi
defaultComposeTextWithAi =
  ComposeTextWithAi
    { text :: Maybe FormattedText
text                       = Maybe FormattedText
forall a. Maybe a
Nothing
    , translate_to_language_code :: Maybe Text
translate_to_language_code = Maybe Text
forall a. Maybe a
Nothing
    , style_name :: Maybe Text
style_name                 = Maybe Text
forall a. Maybe a
Nothing
    , add_emojis :: Maybe Bool
add_emojis                 = Maybe Bool
forall a. Maybe a
Nothing
    }