module TD.Query.StopPoll
  (StopPoll(..)
  , defaultStopPoll
  ) 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.ReplyMarkup as ReplyMarkup

-- | Stops a poll. Returns 'TD.Data.Ok.Ok'
data StopPoll
  = StopPoll
    { StopPoll -> Maybe Int
chat_id      :: Maybe Int                     -- ^ Identifier of the chat to which the poll belongs
    , StopPoll -> Maybe Int
message_id   :: Maybe Int                     -- ^ Identifier of the message containing the poll. Use messageProperties.can_be_edited to check whether the poll can be stopped
    , StopPoll -> Maybe ReplyMarkup
reply_markup :: Maybe ReplyMarkup.ReplyMarkup -- ^ The new message reply markup; pass null if none; for bots only
    }
  deriving (StopPoll -> StopPoll -> Bool
(StopPoll -> StopPoll -> Bool)
-> (StopPoll -> StopPoll -> Bool) -> Eq StopPoll
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StopPoll -> StopPoll -> Bool
== :: StopPoll -> StopPoll -> Bool
$c/= :: StopPoll -> StopPoll -> Bool
/= :: StopPoll -> StopPoll -> Bool
Eq, Int -> StopPoll -> ShowS
[StopPoll] -> ShowS
StopPoll -> String
(Int -> StopPoll -> ShowS)
-> (StopPoll -> String) -> ([StopPoll] -> ShowS) -> Show StopPoll
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StopPoll -> ShowS
showsPrec :: Int -> StopPoll -> ShowS
$cshow :: StopPoll -> String
show :: StopPoll -> String
$cshowList :: [StopPoll] -> ShowS
showList :: [StopPoll] -> ShowS
Show)

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

instance AT.ToJSON StopPoll where
  toJSON :: StopPoll -> Value
toJSON
    StopPoll
      { chat_id :: StopPoll -> Maybe Int
chat_id      = Maybe Int
chat_id_
      , message_id :: StopPoll -> Maybe Int
message_id   = Maybe Int
message_id_
      , reply_markup :: StopPoll -> Maybe ReplyMarkup
reply_markup = Maybe ReplyMarkup
reply_markup_
      }
        = [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
"stopPoll"
          , 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
"reply_markup" Key -> Maybe ReplyMarkup -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ReplyMarkup
reply_markup_
          ]

defaultStopPoll :: StopPoll
defaultStopPoll :: StopPoll
defaultStopPoll =
  StopPoll
    { 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
    , reply_markup :: Maybe ReplyMarkup
reply_markup = Maybe ReplyMarkup
forall a. Maybe a
Nothing
    }