module TD.Query.SetChatDescription
  (SetChatDescription(..)
  , defaultSetChatDescription
  ) 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 information about a chat. Available for basic groups, supergroups, and channels. Requires can_change_info member right. Returns 'TD.Data.Ok.Ok'
data SetChatDescription
  = SetChatDescription
    { SetChatDescription -> Maybe Int
chat_id     :: Maybe Int    -- ^ Identifier of the chat
    , SetChatDescription -> Maybe Text
description :: Maybe T.Text -- ^ New chat description; 0-255 characters
    }
  deriving (SetChatDescription -> SetChatDescription -> Bool
(SetChatDescription -> SetChatDescription -> Bool)
-> (SetChatDescription -> SetChatDescription -> Bool)
-> Eq SetChatDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatDescription -> SetChatDescription -> Bool
== :: SetChatDescription -> SetChatDescription -> Bool
$c/= :: SetChatDescription -> SetChatDescription -> Bool
/= :: SetChatDescription -> SetChatDescription -> Bool
Eq, Int -> SetChatDescription -> ShowS
[SetChatDescription] -> ShowS
SetChatDescription -> String
(Int -> SetChatDescription -> ShowS)
-> (SetChatDescription -> String)
-> ([SetChatDescription] -> ShowS)
-> Show SetChatDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatDescription -> ShowS
showsPrec :: Int -> SetChatDescription -> ShowS
$cshow :: SetChatDescription -> String
show :: SetChatDescription -> String
$cshowList :: [SetChatDescription] -> ShowS
showList :: [SetChatDescription] -> ShowS
Show)

instance I.ShortShow SetChatDescription where
  shortShow :: SetChatDescription -> String
shortShow
    SetChatDescription
      { chat_id :: SetChatDescription -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , description :: SetChatDescription -> Maybe Text
description = Maybe Text
description_
      }
        = String
"SetChatDescription"
          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
"description" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
description_
          ]

instance AT.ToJSON SetChatDescription where
  toJSON :: SetChatDescription -> Value
toJSON
    SetChatDescription
      { chat_id :: SetChatDescription -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , description :: SetChatDescription -> Maybe Text
description = Maybe Text
description_
      }
        = [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
"setChatDescription"
          , 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
"description" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
description_
          ]

defaultSetChatDescription :: SetChatDescription
defaultSetChatDescription :: SetChatDescription
defaultSetChatDescription =
  SetChatDescription
    { chat_id :: Maybe Int
chat_id     = Maybe Int
forall a. Maybe a
Nothing
    , description :: Maybe Text
description = Maybe Text
forall a. Maybe a
Nothing
    }