module TD.Query.RemoveCommunityChat
  (RemoveCommunityChat(..)
  , defaultRemoveCommunityChat
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Removes a chat from a community. Members of the chat, which aren't members of other chats in the community, will be removed from the community. Requires owner privileges in the supergroup or channel chat, or ownership of the bot for chats with bots, or can_edit_chat_list administrator right in the community. Returns 'TD.Data.Ok.Ok'
data RemoveCommunityChat
  = RemoveCommunityChat
    { RemoveCommunityChat -> Maybe Int
community_id :: Maybe Int -- ^ Identifier of the community
    , RemoveCommunityChat -> Maybe Int
chat_id      :: Maybe Int -- ^ Identifier of the chat to remove
    }
  deriving (RemoveCommunityChat -> RemoveCommunityChat -> Bool
(RemoveCommunityChat -> RemoveCommunityChat -> Bool)
-> (RemoveCommunityChat -> RemoveCommunityChat -> Bool)
-> Eq RemoveCommunityChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveCommunityChat -> RemoveCommunityChat -> Bool
== :: RemoveCommunityChat -> RemoveCommunityChat -> Bool
$c/= :: RemoveCommunityChat -> RemoveCommunityChat -> Bool
/= :: RemoveCommunityChat -> RemoveCommunityChat -> Bool
Eq, Int -> RemoveCommunityChat -> ShowS
[RemoveCommunityChat] -> ShowS
RemoveCommunityChat -> String
(Int -> RemoveCommunityChat -> ShowS)
-> (RemoveCommunityChat -> String)
-> ([RemoveCommunityChat] -> ShowS)
-> Show RemoveCommunityChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveCommunityChat -> ShowS
showsPrec :: Int -> RemoveCommunityChat -> ShowS
$cshow :: RemoveCommunityChat -> String
show :: RemoveCommunityChat -> String
$cshowList :: [RemoveCommunityChat] -> ShowS
showList :: [RemoveCommunityChat] -> ShowS
Show)

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

instance AT.ToJSON RemoveCommunityChat where
  toJSON :: RemoveCommunityChat -> Value
toJSON
    RemoveCommunityChat
      { community_id :: RemoveCommunityChat -> Maybe Int
community_id = Maybe Int
community_id_
      , chat_id :: RemoveCommunityChat -> Maybe Int
chat_id      = Maybe Int
chat_id_
      }
        = [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
"removeCommunityChat"
          , Key
"community_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
community_id_
          , 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_
          ]

defaultRemoveCommunityChat :: RemoveCommunityChat
defaultRemoveCommunityChat :: RemoveCommunityChat
defaultRemoveCommunityChat =
  RemoveCommunityChat
    { community_id :: Maybe Int
community_id = Maybe Int
forall a. Maybe a
Nothing
    , chat_id :: Maybe Int
chat_id      = Maybe Int
forall a. Maybe a
Nothing
    }