module TD.Query.ToggleCommunityAreChatsCollapsed
  (ToggleCommunityAreChatsCollapsed(..)
  , defaultToggleCommunityAreChatsCollapsed
  ) where

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

-- | Changes whether all chats of a community are collapsed into one entry in the chat list. If the chats are expanded, then the community is removed from all chat folders. Returns 'TD.Data.Ok.Ok'
data ToggleCommunityAreChatsCollapsed
  = ToggleCommunityAreChatsCollapsed
    { ToggleCommunityAreChatsCollapsed -> Maybe Int
community_id        :: Maybe Int  -- ^ Identifier of the community
    , ToggleCommunityAreChatsCollapsed -> Maybe Bool
are_chats_collapsed :: Maybe Bool -- ^ Pass true to collapse all chats of the community into one entry in the chat list
    }
  deriving (ToggleCommunityAreChatsCollapsed
-> ToggleCommunityAreChatsCollapsed -> Bool
(ToggleCommunityAreChatsCollapsed
 -> ToggleCommunityAreChatsCollapsed -> Bool)
-> (ToggleCommunityAreChatsCollapsed
    -> ToggleCommunityAreChatsCollapsed -> Bool)
-> Eq ToggleCommunityAreChatsCollapsed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleCommunityAreChatsCollapsed
-> ToggleCommunityAreChatsCollapsed -> Bool
== :: ToggleCommunityAreChatsCollapsed
-> ToggleCommunityAreChatsCollapsed -> Bool
$c/= :: ToggleCommunityAreChatsCollapsed
-> ToggleCommunityAreChatsCollapsed -> Bool
/= :: ToggleCommunityAreChatsCollapsed
-> ToggleCommunityAreChatsCollapsed -> Bool
Eq, Int -> ToggleCommunityAreChatsCollapsed -> ShowS
[ToggleCommunityAreChatsCollapsed] -> ShowS
ToggleCommunityAreChatsCollapsed -> String
(Int -> ToggleCommunityAreChatsCollapsed -> ShowS)
-> (ToggleCommunityAreChatsCollapsed -> String)
-> ([ToggleCommunityAreChatsCollapsed] -> ShowS)
-> Show ToggleCommunityAreChatsCollapsed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleCommunityAreChatsCollapsed -> ShowS
showsPrec :: Int -> ToggleCommunityAreChatsCollapsed -> ShowS
$cshow :: ToggleCommunityAreChatsCollapsed -> String
show :: ToggleCommunityAreChatsCollapsed -> String
$cshowList :: [ToggleCommunityAreChatsCollapsed] -> ShowS
showList :: [ToggleCommunityAreChatsCollapsed] -> ShowS
Show)

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

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

defaultToggleCommunityAreChatsCollapsed :: ToggleCommunityAreChatsCollapsed
defaultToggleCommunityAreChatsCollapsed :: ToggleCommunityAreChatsCollapsed
defaultToggleCommunityAreChatsCollapsed =
  ToggleCommunityAreChatsCollapsed
    { community_id :: Maybe Int
community_id        = Maybe Int
forall a. Maybe a
Nothing
    , are_chats_collapsed :: Maybe Bool
are_chats_collapsed = Maybe Bool
forall a. Maybe a
Nothing
    }