module TD.Query.ReportSupergroupSpam
  (ReportSupergroupSpam(..)
  , defaultReportSupergroupSpam
  ) where

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

-- | Reports messages in a supergroup as spam; requires administrator rights in the supergroup. Returns 'TD.Data.Ok.Ok'
data ReportSupergroupSpam
  = ReportSupergroupSpam
    { ReportSupergroupSpam -> Maybe Int
supergroup_id :: Maybe Int   -- ^ Supergroup identifier
    , ReportSupergroupSpam -> Maybe [Int]
message_ids   :: Maybe [Int] -- ^ Identifiers of messages to report. Use messageProperties.can_report_supergroup_spam to check whether the message can be reported
    }
  deriving (ReportSupergroupSpam -> ReportSupergroupSpam -> Bool
(ReportSupergroupSpam -> ReportSupergroupSpam -> Bool)
-> (ReportSupergroupSpam -> ReportSupergroupSpam -> Bool)
-> Eq ReportSupergroupSpam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReportSupergroupSpam -> ReportSupergroupSpam -> Bool
== :: ReportSupergroupSpam -> ReportSupergroupSpam -> Bool
$c/= :: ReportSupergroupSpam -> ReportSupergroupSpam -> Bool
/= :: ReportSupergroupSpam -> ReportSupergroupSpam -> Bool
Eq, Int -> ReportSupergroupSpam -> ShowS
[ReportSupergroupSpam] -> ShowS
ReportSupergroupSpam -> String
(Int -> ReportSupergroupSpam -> ShowS)
-> (ReportSupergroupSpam -> String)
-> ([ReportSupergroupSpam] -> ShowS)
-> Show ReportSupergroupSpam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReportSupergroupSpam -> ShowS
showsPrec :: Int -> ReportSupergroupSpam -> ShowS
$cshow :: ReportSupergroupSpam -> String
show :: ReportSupergroupSpam -> String
$cshowList :: [ReportSupergroupSpam] -> ShowS
showList :: [ReportSupergroupSpam] -> ShowS
Show)

instance I.ShortShow ReportSupergroupSpam where
  shortShow :: ReportSupergroupSpam -> String
shortShow
    ReportSupergroupSpam
      { supergroup_id :: ReportSupergroupSpam -> Maybe Int
supergroup_id = Maybe Int
supergroup_id_
      , message_ids :: ReportSupergroupSpam -> Maybe [Int]
message_ids   = Maybe [Int]
message_ids_
      }
        = String
"ReportSupergroupSpam"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"supergroup_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
supergroup_id_
          , String
"message_ids"   String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
message_ids_
          ]

instance AT.ToJSON ReportSupergroupSpam where
  toJSON :: ReportSupergroupSpam -> Value
toJSON
    ReportSupergroupSpam
      { supergroup_id :: ReportSupergroupSpam -> Maybe Int
supergroup_id = Maybe Int
supergroup_id_
      , message_ids :: ReportSupergroupSpam -> Maybe [Int]
message_ids   = Maybe [Int]
message_ids_
      }
        = [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
"reportSupergroupSpam"
          , Key
"supergroup_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
supergroup_id_
          , Key
"message_ids"   Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
message_ids_
          ]

defaultReportSupergroupSpam :: ReportSupergroupSpam
defaultReportSupergroupSpam :: ReportSupergroupSpam
defaultReportSupergroupSpam =
  ReportSupergroupSpam
    { supergroup_id :: Maybe Int
supergroup_id = Maybe Int
forall a. Maybe a
Nothing
    , message_ids :: Maybe [Int]
message_ids   = Maybe [Int]
forall a. Maybe a
Nothing
    }