module TD.Query.EditTextCompositionStyle
  (EditTextCompositionStyle(..)
  , defaultEditTextCompositionStyle
  ) 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

-- | Edits a custom text composition style that was created by the current user. Returns 'TD.Data.TextCompositionStyle.TextCompositionStyle'
data EditTextCompositionStyle
  = EditTextCompositionStyle
    { EditTextCompositionStyle -> Maybe Text
name            :: Maybe T.Text -- ^ Name of the style
    , EditTextCompositionStyle -> Maybe Text
title           :: Maybe T.Text -- ^ Title of the style; 1-getOption("text_composition_style_title_length_max") characters
    , EditTextCompositionStyle -> Maybe Int
custom_emoji_id :: Maybe Int    -- ^ Identifier of the custom emoji corresponding to the style
    , EditTextCompositionStyle -> Maybe Text
prompt          :: Maybe T.Text -- ^ Prompt that will be used for text composition; 1-getOption("text_composition_style_prompt_length_max") characters
    , EditTextCompositionStyle -> Maybe Bool
show_creator    :: Maybe Bool   -- ^ Pass true if the current user must be shown as the creator of the style
    }
  deriving (EditTextCompositionStyle -> EditTextCompositionStyle -> Bool
(EditTextCompositionStyle -> EditTextCompositionStyle -> Bool)
-> (EditTextCompositionStyle -> EditTextCompositionStyle -> Bool)
-> Eq EditTextCompositionStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditTextCompositionStyle -> EditTextCompositionStyle -> Bool
== :: EditTextCompositionStyle -> EditTextCompositionStyle -> Bool
$c/= :: EditTextCompositionStyle -> EditTextCompositionStyle -> Bool
/= :: EditTextCompositionStyle -> EditTextCompositionStyle -> Bool
Eq, Int -> EditTextCompositionStyle -> ShowS
[EditTextCompositionStyle] -> ShowS
EditTextCompositionStyle -> String
(Int -> EditTextCompositionStyle -> ShowS)
-> (EditTextCompositionStyle -> String)
-> ([EditTextCompositionStyle] -> ShowS)
-> Show EditTextCompositionStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditTextCompositionStyle -> ShowS
showsPrec :: Int -> EditTextCompositionStyle -> ShowS
$cshow :: EditTextCompositionStyle -> String
show :: EditTextCompositionStyle -> String
$cshowList :: [EditTextCompositionStyle] -> ShowS
showList :: [EditTextCompositionStyle] -> ShowS
Show)

instance I.ShortShow EditTextCompositionStyle where
  shortShow :: EditTextCompositionStyle -> String
shortShow
    EditTextCompositionStyle
      { name :: EditTextCompositionStyle -> Maybe Text
name            = Maybe Text
name_
      , title :: EditTextCompositionStyle -> Maybe Text
title           = Maybe Text
title_
      , custom_emoji_id :: EditTextCompositionStyle -> Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
      , prompt :: EditTextCompositionStyle -> Maybe Text
prompt          = Maybe Text
prompt_
      , show_creator :: EditTextCompositionStyle -> Maybe Bool
show_creator    = Maybe Bool
show_creator_
      }
        = String
"EditTextCompositionStyle"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"name"            String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , 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 EditTextCompositionStyle where
  toJSON :: EditTextCompositionStyle -> Value
toJSON
    EditTextCompositionStyle
      { name :: EditTextCompositionStyle -> Maybe Text
name            = Maybe Text
name_
      , title :: EditTextCompositionStyle -> Maybe Text
title           = Maybe Text
title_
      , custom_emoji_id :: EditTextCompositionStyle -> Maybe Int
custom_emoji_id = Maybe Int
custom_emoji_id_
      , prompt :: EditTextCompositionStyle -> Maybe Text
prompt          = Maybe Text
prompt_
      , show_creator :: EditTextCompositionStyle -> 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
"editTextCompositionStyle"
          , Key
"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
name_
          , 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_
          ]

defaultEditTextCompositionStyle :: EditTextCompositionStyle
defaultEditTextCompositionStyle :: EditTextCompositionStyle
defaultEditTextCompositionStyle =
  EditTextCompositionStyle
    { name :: Maybe Text
name            = Maybe Text
forall a. Maybe a
Nothing
    , 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
    }