module TD.Query.GetCommunityMemberChats
  (GetCommunityMemberChats(..)
  , defaultGetCommunityMemberChats
  ) where

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

-- | Returns chats in a community, which were joined by a member of the community; requires can_ban_members administrator right in the community. Can be used to show chats that will be affected by the member ban. Returns 'TD.Data.CommunityMemberChats.CommunityMemberChats'
data GetCommunityMemberChats
  = GetCommunityMemberChats
    { GetCommunityMemberChats -> Maybe Int
community_id :: Maybe Int                         -- ^ Identifier of the community
    , GetCommunityMemberChats -> Maybe MessageSender
member_id    :: Maybe MessageSender.MessageSender -- ^ Identifier of the member
    }
  deriving (GetCommunityMemberChats -> GetCommunityMemberChats -> Bool
(GetCommunityMemberChats -> GetCommunityMemberChats -> Bool)
-> (GetCommunityMemberChats -> GetCommunityMemberChats -> Bool)
-> Eq GetCommunityMemberChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetCommunityMemberChats -> GetCommunityMemberChats -> Bool
== :: GetCommunityMemberChats -> GetCommunityMemberChats -> Bool
$c/= :: GetCommunityMemberChats -> GetCommunityMemberChats -> Bool
/= :: GetCommunityMemberChats -> GetCommunityMemberChats -> Bool
Eq, Int -> GetCommunityMemberChats -> ShowS
[GetCommunityMemberChats] -> ShowS
GetCommunityMemberChats -> String
(Int -> GetCommunityMemberChats -> ShowS)
-> (GetCommunityMemberChats -> String)
-> ([GetCommunityMemberChats] -> ShowS)
-> Show GetCommunityMemberChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetCommunityMemberChats -> ShowS
showsPrec :: Int -> GetCommunityMemberChats -> ShowS
$cshow :: GetCommunityMemberChats -> String
show :: GetCommunityMemberChats -> String
$cshowList :: [GetCommunityMemberChats] -> ShowS
showList :: [GetCommunityMemberChats] -> ShowS
Show)

instance I.ShortShow GetCommunityMemberChats where
  shortShow :: GetCommunityMemberChats -> String
shortShow
    GetCommunityMemberChats
      { community_id :: GetCommunityMemberChats -> Maybe Int
community_id = Maybe Int
community_id_
      , member_id :: GetCommunityMemberChats -> Maybe MessageSender
member_id    = Maybe MessageSender
member_id_
      }
        = String
"GetCommunityMemberChats"
          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
"member_id"    String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
member_id_
          ]

instance AT.ToJSON GetCommunityMemberChats where
  toJSON :: GetCommunityMemberChats -> Value
toJSON
    GetCommunityMemberChats
      { community_id :: GetCommunityMemberChats -> Maybe Int
community_id = Maybe Int
community_id_
      , member_id :: GetCommunityMemberChats -> Maybe MessageSender
member_id    = Maybe MessageSender
member_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
"getCommunityMemberChats"
          , 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
"member_id"    Key -> Maybe MessageSender -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSender
member_id_
          ]

defaultGetCommunityMemberChats :: GetCommunityMemberChats
defaultGetCommunityMemberChats :: GetCommunityMemberChats
defaultGetCommunityMemberChats =
  GetCommunityMemberChats
    { community_id :: Maybe Int
community_id = Maybe Int
forall a. Maybe a
Nothing
    , member_id :: Maybe MessageSender
member_id    = Maybe MessageSender
forall a. Maybe a
Nothing
    }