module TD.Query.DeleteCommunity
  (DeleteCommunity(..)
  ) where

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

-- | Deletes a community; requires owner privileges. Returns 'TD.Data.Ok.Ok'
data DeleteCommunity
  = DeleteCommunity
    { DeleteCommunity -> Maybe Int
community_id :: Maybe Int -- ^ Identifier of the community
    }
  deriving (DeleteCommunity -> DeleteCommunity -> Bool
(DeleteCommunity -> DeleteCommunity -> Bool)
-> (DeleteCommunity -> DeleteCommunity -> Bool)
-> Eq DeleteCommunity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteCommunity -> DeleteCommunity -> Bool
== :: DeleteCommunity -> DeleteCommunity -> Bool
$c/= :: DeleteCommunity -> DeleteCommunity -> Bool
/= :: DeleteCommunity -> DeleteCommunity -> Bool
Eq, Int -> DeleteCommunity -> ShowS
[DeleteCommunity] -> ShowS
DeleteCommunity -> String
(Int -> DeleteCommunity -> ShowS)
-> (DeleteCommunity -> String)
-> ([DeleteCommunity] -> ShowS)
-> Show DeleteCommunity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteCommunity -> ShowS
showsPrec :: Int -> DeleteCommunity -> ShowS
$cshow :: DeleteCommunity -> String
show :: DeleteCommunity -> String
$cshowList :: [DeleteCommunity] -> ShowS
showList :: [DeleteCommunity] -> ShowS
Show)

instance I.ShortShow DeleteCommunity where
  shortShow :: DeleteCommunity -> String
shortShow
    DeleteCommunity
      { community_id :: DeleteCommunity -> Maybe Int
community_id = Maybe Int
community_id_
      }
        = String
"DeleteCommunity"
          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_
          ]

instance AT.ToJSON DeleteCommunity where
  toJSON :: DeleteCommunity -> Value
toJSON
    DeleteCommunity
      { community_id :: DeleteCommunity -> Maybe Int
community_id = Maybe Int
community_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
"deleteCommunity"
          , 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_
          ]