module TD.Query.GetCreatedPublicChats
  (GetCreatedPublicChats(..)
  ) 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.PublicChatType as PublicChatType

-- | Returns a list of public chats of the specified type, owned by the user. Returns 'TD.Data.Chats.Chats'
data GetCreatedPublicChats
  = GetCreatedPublicChats
    { GetCreatedPublicChats -> Maybe PublicChatType
_type :: Maybe PublicChatType.PublicChatType -- ^ Type of the public chats to return
    }
  deriving (GetCreatedPublicChats -> GetCreatedPublicChats -> Bool
(GetCreatedPublicChats -> GetCreatedPublicChats -> Bool)
-> (GetCreatedPublicChats -> GetCreatedPublicChats -> Bool)
-> Eq GetCreatedPublicChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetCreatedPublicChats -> GetCreatedPublicChats -> Bool
== :: GetCreatedPublicChats -> GetCreatedPublicChats -> Bool
$c/= :: GetCreatedPublicChats -> GetCreatedPublicChats -> Bool
/= :: GetCreatedPublicChats -> GetCreatedPublicChats -> Bool
Eq, Int -> GetCreatedPublicChats -> ShowS
[GetCreatedPublicChats] -> ShowS
GetCreatedPublicChats -> String
(Int -> GetCreatedPublicChats -> ShowS)
-> (GetCreatedPublicChats -> String)
-> ([GetCreatedPublicChats] -> ShowS)
-> Show GetCreatedPublicChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetCreatedPublicChats -> ShowS
showsPrec :: Int -> GetCreatedPublicChats -> ShowS
$cshow :: GetCreatedPublicChats -> String
show :: GetCreatedPublicChats -> String
$cshowList :: [GetCreatedPublicChats] -> ShowS
showList :: [GetCreatedPublicChats] -> ShowS
Show)

instance I.ShortShow GetCreatedPublicChats where
  shortShow :: GetCreatedPublicChats -> String
shortShow
    GetCreatedPublicChats
      { _type :: GetCreatedPublicChats -> Maybe PublicChatType
_type = Maybe PublicChatType
_type_
      }
        = String
"GetCreatedPublicChats"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"_type" String -> Maybe PublicChatType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe PublicChatType
_type_
          ]

instance AT.ToJSON GetCreatedPublicChats where
  toJSON :: GetCreatedPublicChats -> Value
toJSON
    GetCreatedPublicChats
      { _type :: GetCreatedPublicChats -> Maybe PublicChatType
_type = Maybe PublicChatType
_type_
      }
        = [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
"getCreatedPublicChats"
          , Key
"type"  Key -> Maybe PublicChatType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe PublicChatType
_type_
          ]