module TD.Query.SetChatTitle
  (SetChatTitle(..)
  , defaultSetChatTitle
  ) 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

-- | Changes the chat title. Supported only for basic groups, supergroups and channels. Requires can_change_info member right. Returns 'TD.Data.Ok.Ok'
data SetChatTitle
  = SetChatTitle
    { SetChatTitle -> Maybe Int
chat_id :: Maybe Int    -- ^ Chat identifier
    , SetChatTitle -> Maybe Text
title   :: Maybe T.Text -- ^ New title of the chat; 1-128 characters
    }
  deriving (SetChatTitle -> SetChatTitle -> Bool
(SetChatTitle -> SetChatTitle -> Bool)
-> (SetChatTitle -> SetChatTitle -> Bool) -> Eq SetChatTitle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatTitle -> SetChatTitle -> Bool
== :: SetChatTitle -> SetChatTitle -> Bool
$c/= :: SetChatTitle -> SetChatTitle -> Bool
/= :: SetChatTitle -> SetChatTitle -> Bool
Eq, Int -> SetChatTitle -> ShowS
[SetChatTitle] -> ShowS
SetChatTitle -> String
(Int -> SetChatTitle -> ShowS)
-> (SetChatTitle -> String)
-> ([SetChatTitle] -> ShowS)
-> Show SetChatTitle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatTitle -> ShowS
showsPrec :: Int -> SetChatTitle -> ShowS
$cshow :: SetChatTitle -> String
show :: SetChatTitle -> String
$cshowList :: [SetChatTitle] -> ShowS
showList :: [SetChatTitle] -> ShowS
Show)

instance I.ShortShow SetChatTitle where
  shortShow :: SetChatTitle -> String
shortShow
    SetChatTitle
      { chat_id :: SetChatTitle -> Maybe Int
chat_id = Maybe Int
chat_id_
      , title :: SetChatTitle -> Maybe Text
title   = Maybe Text
title_
      }
        = String
"SetChatTitle"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"title"   String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
          ]

instance AT.ToJSON SetChatTitle where
  toJSON :: SetChatTitle -> Value
toJSON
    SetChatTitle
      { chat_id :: SetChatTitle -> Maybe Int
chat_id = Maybe Int
chat_id_
      , title :: SetChatTitle -> Maybe Text
title   = Maybe Text
title_
      }
        = [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
"setChatTitle"
          , Key
"chat_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
chat_id_
          , 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_
          ]

defaultSetChatTitle :: SetChatTitle
defaultSetChatTitle :: SetChatTitle
defaultSetChatTitle =
  SetChatTitle
    { chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
    , title :: Maybe Text
title   = Maybe Text
forall a. Maybe a
Nothing
    }