module TD.Query.ProcessCommunityAddChatRequests
  (ProcessCommunityAddChatRequests(..)
  , defaultProcessCommunityAddChatRequests
  ) where

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

-- | Handles all pending requests to add chats to a community; requires can_edit_chat_list administrator right in the community. Returns 'TD.Data.Ok.Ok'
data ProcessCommunityAddChatRequests
  = ProcessCommunityAddChatRequests
    { ProcessCommunityAddChatRequests -> Maybe Int
community_id :: Maybe Int  -- ^ Identifier of the community
    , ProcessCommunityAddChatRequests -> Maybe Bool
approve      :: Maybe Bool -- ^ Pass true to approve all requests and add the chats to the community; pass false to decline them
    }
  deriving (ProcessCommunityAddChatRequests
-> ProcessCommunityAddChatRequests -> Bool
(ProcessCommunityAddChatRequests
 -> ProcessCommunityAddChatRequests -> Bool)
-> (ProcessCommunityAddChatRequests
    -> ProcessCommunityAddChatRequests -> Bool)
-> Eq ProcessCommunityAddChatRequests
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProcessCommunityAddChatRequests
-> ProcessCommunityAddChatRequests -> Bool
== :: ProcessCommunityAddChatRequests
-> ProcessCommunityAddChatRequests -> Bool
$c/= :: ProcessCommunityAddChatRequests
-> ProcessCommunityAddChatRequests -> Bool
/= :: ProcessCommunityAddChatRequests
-> ProcessCommunityAddChatRequests -> Bool
Eq, Int -> ProcessCommunityAddChatRequests -> ShowS
[ProcessCommunityAddChatRequests] -> ShowS
ProcessCommunityAddChatRequests -> String
(Int -> ProcessCommunityAddChatRequests -> ShowS)
-> (ProcessCommunityAddChatRequests -> String)
-> ([ProcessCommunityAddChatRequests] -> ShowS)
-> Show ProcessCommunityAddChatRequests
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProcessCommunityAddChatRequests -> ShowS
showsPrec :: Int -> ProcessCommunityAddChatRequests -> ShowS
$cshow :: ProcessCommunityAddChatRequests -> String
show :: ProcessCommunityAddChatRequests -> String
$cshowList :: [ProcessCommunityAddChatRequests] -> ShowS
showList :: [ProcessCommunityAddChatRequests] -> ShowS
Show)

instance I.ShortShow ProcessCommunityAddChatRequests where
  shortShow :: ProcessCommunityAddChatRequests -> String
shortShow
    ProcessCommunityAddChatRequests
      { community_id :: ProcessCommunityAddChatRequests -> Maybe Int
community_id = Maybe Int
community_id_
      , approve :: ProcessCommunityAddChatRequests -> Maybe Bool
approve      = Maybe Bool
approve_
      }
        = String
"ProcessCommunityAddChatRequests"
          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
"approve"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
approve_
          ]

instance AT.ToJSON ProcessCommunityAddChatRequests where
  toJSON :: ProcessCommunityAddChatRequests -> Value
toJSON
    ProcessCommunityAddChatRequests
      { community_id :: ProcessCommunityAddChatRequests -> Maybe Int
community_id = Maybe Int
community_id_
      , approve :: ProcessCommunityAddChatRequests -> Maybe Bool
approve      = Maybe Bool
approve_
      }
        = [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
"processCommunityAddChatRequests"
          , 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
"approve"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
approve_
          ]

defaultProcessCommunityAddChatRequests :: ProcessCommunityAddChatRequests
defaultProcessCommunityAddChatRequests :: ProcessCommunityAddChatRequests
defaultProcessCommunityAddChatRequests =
  ProcessCommunityAddChatRequests
    { community_id :: Maybe Int
community_id = Maybe Int
forall a. Maybe a
Nothing
    , approve :: Maybe Bool
approve      = Maybe Bool
forall a. Maybe a
Nothing
    }