module TD.Query.ReportChatSponsoredMessage
  (ReportChatSponsoredMessage(..)
  , defaultReportChatSponsoredMessage
  ) where

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

-- | Reports a sponsored message to Telegram moderators. Returns 'TD.Data.ReportChatSponsoredMessageResult.ReportChatSponsoredMessageResult'
data ReportChatSponsoredMessage
  = ReportChatSponsoredMessage
    { ReportChatSponsoredMessage -> Maybe Int
chat_id    :: Maybe Int           -- ^ Chat identifier of the sponsored message
    , ReportChatSponsoredMessage -> Maybe Int
message_id :: Maybe Int           -- ^ Identifier of the sponsored message
    , ReportChatSponsoredMessage -> Maybe ByteString
option_id  :: Maybe BS.ByteString -- ^ Option identifier chosen by the user; leave empty for the initial request
    }
  deriving (ReportChatSponsoredMessage -> ReportChatSponsoredMessage -> Bool
(ReportChatSponsoredMessage -> ReportChatSponsoredMessage -> Bool)
-> (ReportChatSponsoredMessage
    -> ReportChatSponsoredMessage -> Bool)
-> Eq ReportChatSponsoredMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReportChatSponsoredMessage -> ReportChatSponsoredMessage -> Bool
== :: ReportChatSponsoredMessage -> ReportChatSponsoredMessage -> Bool
$c/= :: ReportChatSponsoredMessage -> ReportChatSponsoredMessage -> Bool
/= :: ReportChatSponsoredMessage -> ReportChatSponsoredMessage -> Bool
Eq, Int -> ReportChatSponsoredMessage -> ShowS
[ReportChatSponsoredMessage] -> ShowS
ReportChatSponsoredMessage -> String
(Int -> ReportChatSponsoredMessage -> ShowS)
-> (ReportChatSponsoredMessage -> String)
-> ([ReportChatSponsoredMessage] -> ShowS)
-> Show ReportChatSponsoredMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReportChatSponsoredMessage -> ShowS
showsPrec :: Int -> ReportChatSponsoredMessage -> ShowS
$cshow :: ReportChatSponsoredMessage -> String
show :: ReportChatSponsoredMessage -> String
$cshowList :: [ReportChatSponsoredMessage] -> ShowS
showList :: [ReportChatSponsoredMessage] -> ShowS
Show)

instance I.ShortShow ReportChatSponsoredMessage where
  shortShow :: ReportChatSponsoredMessage -> String
shortShow
    ReportChatSponsoredMessage
      { chat_id :: ReportChatSponsoredMessage -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , message_id :: ReportChatSponsoredMessage -> Maybe Int
message_id = Maybe Int
message_id_
      , option_id :: ReportChatSponsoredMessage -> Maybe ByteString
option_id  = Maybe ByteString
option_id_
      }
        = String
"ReportChatSponsoredMessage"
          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
"message_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_id_
          , String
"option_id"  String -> Maybe ByteString -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ByteString
option_id_
          ]

instance AT.ToJSON ReportChatSponsoredMessage where
  toJSON :: ReportChatSponsoredMessage -> Value
toJSON
    ReportChatSponsoredMessage
      { chat_id :: ReportChatSponsoredMessage -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , message_id :: ReportChatSponsoredMessage -> Maybe Int
message_id = Maybe Int
message_id_
      , option_id :: ReportChatSponsoredMessage -> Maybe ByteString
option_id  = Maybe ByteString
option_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
"reportChatSponsoredMessage"
          , 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
"message_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
message_id_
          , Key
"option_id"  Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (ByteString -> Value) -> Maybe ByteString -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Value
I.writeBytes  Maybe ByteString
option_id_
          ]

defaultReportChatSponsoredMessage :: ReportChatSponsoredMessage
defaultReportChatSponsoredMessage :: ReportChatSponsoredMessage
defaultReportChatSponsoredMessage =
  ReportChatSponsoredMessage
    { chat_id :: Maybe Int
chat_id    = Maybe Int
forall a. Maybe a
Nothing
    , message_id :: Maybe Int
message_id = Maybe Int
forall a. Maybe a
Nothing
    , option_id :: Maybe ByteString
option_id  = Maybe ByteString
forall a. Maybe a
Nothing
    }