module TD.Query.ReportChatPhoto
  (ReportChatPhoto(..)
  , defaultReportChatPhoto
  ) 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.ReportReason as ReportReason
import qualified Data.Text as T

-- | Reports a chat photo to the Telegram moderators. A chat photo can be reported only if chat.can_be_reported. Returns 'TD.Data.Ok.Ok'
data ReportChatPhoto
  = ReportChatPhoto
    { ReportChatPhoto -> Maybe Int
chat_id :: Maybe Int                       -- ^ Chat identifier
    , ReportChatPhoto -> Maybe Int
file_id :: Maybe Int                       -- ^ Identifier of the photo to report. Only full photos from chatPhoto can be reported
    , ReportChatPhoto -> Maybe ReportReason
reason  :: Maybe ReportReason.ReportReason -- ^ The reason for reporting the chat photo
    , ReportChatPhoto -> Maybe Text
text    :: Maybe T.Text                    -- ^ Additional report details; 0-1024 characters
    }
  deriving (ReportChatPhoto -> ReportChatPhoto -> Bool
(ReportChatPhoto -> ReportChatPhoto -> Bool)
-> (ReportChatPhoto -> ReportChatPhoto -> Bool)
-> Eq ReportChatPhoto
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReportChatPhoto -> ReportChatPhoto -> Bool
== :: ReportChatPhoto -> ReportChatPhoto -> Bool
$c/= :: ReportChatPhoto -> ReportChatPhoto -> Bool
/= :: ReportChatPhoto -> ReportChatPhoto -> Bool
Eq, Int -> ReportChatPhoto -> ShowS
[ReportChatPhoto] -> ShowS
ReportChatPhoto -> String
(Int -> ReportChatPhoto -> ShowS)
-> (ReportChatPhoto -> String)
-> ([ReportChatPhoto] -> ShowS)
-> Show ReportChatPhoto
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReportChatPhoto -> ShowS
showsPrec :: Int -> ReportChatPhoto -> ShowS
$cshow :: ReportChatPhoto -> String
show :: ReportChatPhoto -> String
$cshowList :: [ReportChatPhoto] -> ShowS
showList :: [ReportChatPhoto] -> ShowS
Show)

instance I.ShortShow ReportChatPhoto where
  shortShow :: ReportChatPhoto -> String
shortShow
    ReportChatPhoto
      { chat_id :: ReportChatPhoto -> Maybe Int
chat_id = Maybe Int
chat_id_
      , file_id :: ReportChatPhoto -> Maybe Int
file_id = Maybe Int
file_id_
      , reason :: ReportChatPhoto -> Maybe ReportReason
reason  = Maybe ReportReason
reason_
      , text :: ReportChatPhoto -> Maybe Text
text    = Maybe Text
text_
      }
        = String
"ReportChatPhoto"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"file_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
file_id_
          , String
"reason"  String -> Maybe ReportReason -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ReportReason
reason_
          , String
"text"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
text_
          ]

instance AT.ToJSON ReportChatPhoto where
  toJSON :: ReportChatPhoto -> Value
toJSON
    ReportChatPhoto
      { chat_id :: ReportChatPhoto -> Maybe Int
chat_id = Maybe Int
chat_id_
      , file_id :: ReportChatPhoto -> Maybe Int
file_id = Maybe Int
file_id_
      , reason :: ReportChatPhoto -> Maybe ReportReason
reason  = Maybe ReportReason
reason_
      , text :: ReportChatPhoto -> Maybe Text
text    = Maybe Text
text_
      }
        = [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
"reportChatPhoto"
          , Key
"chat_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
chat_id_
          , Key
"file_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
file_id_
          , Key
"reason"  Key -> Maybe ReportReason -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ReportReason
reason_
          , Key
"text"    Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
text_
          ]

defaultReportChatPhoto :: ReportChatPhoto
defaultReportChatPhoto :: ReportChatPhoto
defaultReportChatPhoto =
  ReportChatPhoto
    { chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
    , file_id :: Maybe Int
file_id = Maybe Int
forall a. Maybe a
Nothing
    , reason :: Maybe ReportReason
reason  = Maybe ReportReason
forall a. Maybe a
Nothing
    , text :: Maybe Text
text    = Maybe Text
forall a. Maybe a
Nothing
    }