module TD.Query.GetCommunityAddChatRequests
  (GetCommunityAddChatRequests(..)
  , defaultGetCommunityAddChatRequests
  ) 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

-- | Returns pending requests to add chats to a community. Administrators of the community with can_edit_chat_list right receive all requests; other users receive only requests sent by them. Returns 'TD.Data.CommunityAddChatRequests.CommunityAddChatRequests'
data GetCommunityAddChatRequests
  = GetCommunityAddChatRequests
    { GetCommunityAddChatRequests -> Maybe Int
community_id :: Maybe Int    -- ^ Identifier of the community
    , GetCommunityAddChatRequests -> Maybe Text
offset       :: Maybe T.Text -- ^ Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
    , GetCommunityAddChatRequests -> Maybe Int
limit        :: Maybe Int    -- ^ The maximum number of requests to return
    }
  deriving (GetCommunityAddChatRequests -> GetCommunityAddChatRequests -> Bool
(GetCommunityAddChatRequests
 -> GetCommunityAddChatRequests -> Bool)
-> (GetCommunityAddChatRequests
    -> GetCommunityAddChatRequests -> Bool)
-> Eq GetCommunityAddChatRequests
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetCommunityAddChatRequests -> GetCommunityAddChatRequests -> Bool
== :: GetCommunityAddChatRequests -> GetCommunityAddChatRequests -> Bool
$c/= :: GetCommunityAddChatRequests -> GetCommunityAddChatRequests -> Bool
/= :: GetCommunityAddChatRequests -> GetCommunityAddChatRequests -> Bool
Eq, Int -> GetCommunityAddChatRequests -> ShowS
[GetCommunityAddChatRequests] -> ShowS
GetCommunityAddChatRequests -> String
(Int -> GetCommunityAddChatRequests -> ShowS)
-> (GetCommunityAddChatRequests -> String)
-> ([GetCommunityAddChatRequests] -> ShowS)
-> Show GetCommunityAddChatRequests
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetCommunityAddChatRequests -> ShowS
showsPrec :: Int -> GetCommunityAddChatRequests -> ShowS
$cshow :: GetCommunityAddChatRequests -> String
show :: GetCommunityAddChatRequests -> String
$cshowList :: [GetCommunityAddChatRequests] -> ShowS
showList :: [GetCommunityAddChatRequests] -> ShowS
Show)

instance I.ShortShow GetCommunityAddChatRequests where
  shortShow :: GetCommunityAddChatRequests -> String
shortShow
    GetCommunityAddChatRequests
      { community_id :: GetCommunityAddChatRequests -> Maybe Int
community_id = Maybe Int
community_id_
      , offset :: GetCommunityAddChatRequests -> Maybe Text
offset       = Maybe Text
offset_
      , limit :: GetCommunityAddChatRequests -> Maybe Int
limit        = Maybe Int
limit_
      }
        = String
"GetCommunityAddChatRequests"
          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
"offset"       String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_
          , String
"limit"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetCommunityAddChatRequests where
  toJSON :: GetCommunityAddChatRequests -> Value
toJSON
    GetCommunityAddChatRequests
      { community_id :: GetCommunityAddChatRequests -> Maybe Int
community_id = Maybe Int
community_id_
      , offset :: GetCommunityAddChatRequests -> Maybe Text
offset       = Maybe Text
offset_
      , limit :: GetCommunityAddChatRequests -> Maybe Int
limit        = Maybe Int
limit_
      }
        = [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
"getCommunityAddChatRequests"
          , 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
"offset"       Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
offset_
          , Key
"limit"        Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetCommunityAddChatRequests :: GetCommunityAddChatRequests
defaultGetCommunityAddChatRequests :: GetCommunityAddChatRequests
defaultGetCommunityAddChatRequests =
  GetCommunityAddChatRequests
    { community_id :: Maybe Int
community_id = Maybe Int
forall a. Maybe a
Nothing
    , offset :: Maybe Text
offset       = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit        = Maybe Int
forall a. Maybe a
Nothing
    }