module TD.Query.StopPendingMessage
  (StopPendingMessage(..)
  , defaultStopPendingMessage
  ) 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.MessageTopic as MessageTopic

-- | Stops a pending message generation by a bot. Returns 'TD.Data.Ok.Ok'
data StopPendingMessage
  = StopPendingMessage
    { StopPendingMessage -> Maybe Int
chat_id  :: Maybe Int                       -- ^ Identifier of the chat with the bot
    , StopPendingMessage -> Maybe MessageTopic
topic_id :: Maybe MessageTopic.MessageTopic -- ^ Identifier of the topic in which the action is performed; pass null if none
    , StopPendingMessage -> Maybe Int
draft_id :: Maybe Int                       -- ^ Unique identifier of the message draft within the message thread
    }
  deriving (StopPendingMessage -> StopPendingMessage -> Bool
(StopPendingMessage -> StopPendingMessage -> Bool)
-> (StopPendingMessage -> StopPendingMessage -> Bool)
-> Eq StopPendingMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StopPendingMessage -> StopPendingMessage -> Bool
== :: StopPendingMessage -> StopPendingMessage -> Bool
$c/= :: StopPendingMessage -> StopPendingMessage -> Bool
/= :: StopPendingMessage -> StopPendingMessage -> Bool
Eq, Int -> StopPendingMessage -> ShowS
[StopPendingMessage] -> ShowS
StopPendingMessage -> String
(Int -> StopPendingMessage -> ShowS)
-> (StopPendingMessage -> String)
-> ([StopPendingMessage] -> ShowS)
-> Show StopPendingMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StopPendingMessage -> ShowS
showsPrec :: Int -> StopPendingMessage -> ShowS
$cshow :: StopPendingMessage -> String
show :: StopPendingMessage -> String
$cshowList :: [StopPendingMessage] -> ShowS
showList :: [StopPendingMessage] -> ShowS
Show)

instance I.ShortShow StopPendingMessage where
  shortShow :: StopPendingMessage -> String
shortShow
    StopPendingMessage
      { chat_id :: StopPendingMessage -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , topic_id :: StopPendingMessage -> Maybe MessageTopic
topic_id = Maybe MessageTopic
topic_id_
      , draft_id :: StopPendingMessage -> Maybe Int
draft_id = Maybe Int
draft_id_
      }
        = String
"StopPendingMessage"
          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
"topic_id" String -> Maybe MessageTopic -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageTopic
topic_id_
          , String
"draft_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
draft_id_
          ]

instance AT.ToJSON StopPendingMessage where
  toJSON :: StopPendingMessage -> Value
toJSON
    StopPendingMessage
      { chat_id :: StopPendingMessage -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , topic_id :: StopPendingMessage -> Maybe MessageTopic
topic_id = Maybe MessageTopic
topic_id_
      , draft_id :: StopPendingMessage -> Maybe Int
draft_id = Maybe Int
draft_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
"stopPendingMessage"
          , 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
"topic_id" Key -> Maybe MessageTopic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageTopic
topic_id_
          , Key
"draft_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
draft_id_
          ]

defaultStopPendingMessage :: StopPendingMessage
defaultStopPendingMessage :: StopPendingMessage
defaultStopPendingMessage =
  StopPendingMessage
    { chat_id :: Maybe Int
chat_id  = Maybe Int
forall a. Maybe a
Nothing
    , topic_id :: Maybe MessageTopic
topic_id = Maybe MessageTopic
forall a. Maybe a
Nothing
    , draft_id :: Maybe Int
draft_id = Maybe Int
forall a. Maybe a
Nothing
    }