module TD.Query.CreateTextCompositionStyle
  (CreateTextCompositionStyle(..)
  , defaultCreateTextCompositionStyle
  ) 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

-- | Creates a custom text composition style. May return an error with a message "TONES_SAVED_TOO_MANY" if the maximum number of added custom styles has been reached. Returns 'TD.Data.TextCompositionStyle.TextCompositionStyle'
data CreateTextCompositionStyle
  = CreateTextCompositionStyle
    { CreateTextCompositionStyle -> Maybe Text
title           :: Maybe T.Text -- ^ Title of the style; 1-getOption("text_composition_style_title_length_max") characters
    , CreateTextCompositionStyle -> Maybe Int
custom_emoji_id :: Maybe Int    -- ^ Identifier of the custom emoji corresponding to the style
    , CreateTextCompositionStyle -> Maybe Text
prompt          :: Maybe T.Text -- ^ Prompt that will be used for text composition; 1-getOption("text_composition_style_prompt_length_max") characters
    , CreateTextCompositionStyle -> Maybe Bool
show_creator    :: Maybe Bool   -- ^ Pass true if the current user must be shown as the creator of the style
    }
  deriving (CreateTextCompositionStyle -> CreateTextCompositionStyle -> Bool
(CreateTextCompositionStyle -> CreateTextCompositionStyle -> Bool)
-> (CreateTextCompositionStyle
    -> CreateTextCompositionStyle -> Bool)
-> Eq CreateTextCompositionStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateTextCompositionStyle -> CreateTextCompositionStyle -> Bool
== :: CreateTextCompositionStyle -> CreateTextCompositionStyle -> Bool
$c/= :: CreateTextCompositionStyle -> CreateTextCompositionStyle -> Bool
/= :: CreateTextCompositionStyle -> CreateTextCompositionStyle -> Bool
Eq, Int -> CreateTextCompositionStyle -> ShowS
[CreateTextCompositionStyle] -> ShowS
CreateTextCompositionStyle -> String
(Int -> CreateTextCompositionStyle -> ShowS)
-> (CreateTextCompositionStyle -> String)
-> ([CreateTextCompositionStyle] -> ShowS)
-> Show CreateTextCompositionStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateTextCompositionStyle -> ShowS
showsPrec :: Int -> CreateTextCompositionStyle -> ShowS
$cshow :: CreateTextCompositionStyle -> String
show :: CreateTextCompositionStyle -> String
$cshowList :: [CreateTextCompositionStyle] -> ShowS
showList :: [CreateTextCompositionStyle] -> ShowS
Show)

instance I.ShortShow CreateTextCompositionStyle where
  shortShow :: CreateTextCompositionStyle -> String
shortShow
    CreateTextCompositionStyle
      { title :: CreateTextCompositionStyle -> Maybe Text
title           = Maybe Text
title_
      , custom_emoji_id :: CreateTextCompositionStyle -> Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
      , prompt :: CreateTextCompositionStyle -> Maybe Text
prompt          = Maybe Text
prompt_
      , show_creator :: CreateTextCompositionStyle -> Maybe Bool
show_creator    = Maybe Bool
show_creator_
      }
        = String
"CreateTextCompositionStyle"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"title"           String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
          , String
"custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
custom_emoji_id_
          , String
"prompt"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
prompt_
          , String
"show_creator"    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
show_creator_
          ]

instance AT.ToJSON CreateTextCompositionStyle where
  toJSON :: CreateTextCompositionStyle -> Value
toJSON
    CreateTextCompositionStyle
      { title :: CreateTextCompositionStyle -> Maybe Text
title           = Maybe Text
title_
      , custom_emoji_id :: CreateTextCompositionStyle -> Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
      , prompt :: CreateTextCompositionStyle -> Maybe Text
prompt          = Maybe Text
prompt_
      , show_creator :: CreateTextCompositionStyle -> Maybe Bool
show_creator    = Maybe Bool
show_creator_
      }
        = [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
"createTextCompositionStyle"
          , Key
"title"           Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
title_
          , 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_
          , Key
"prompt"          Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
prompt_
          , Key
"show_creator"    Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
show_creator_
          ]

defaultCreateTextCompositionStyle :: CreateTextCompositionStyle
defaultCreateTextCompositionStyle :: CreateTextCompositionStyle
defaultCreateTextCompositionStyle =
  CreateTextCompositionStyle
    { title :: Maybe Text
title           = Maybe Text
forall a. Maybe a
Nothing
    , custom_emoji_id :: Maybe Int
custom_emoji_id = Maybe Int
forall a. Maybe a
Nothing
    , prompt :: Maybe Text
prompt          = Maybe Text
forall a. Maybe a
Nothing
    , show_creator :: Maybe Bool
show_creator    = Maybe Bool
forall a. Maybe a
Nothing
    }