module TD.Query.GetPollVoteStatistics
  (GetPollVoteStatistics(..)
  , defaultGetPollVoteStatistics
  ) where

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

-- | Returns statistics of poll votes in a poll. Returns 'TD.Data.PollVoteStatistics.PollVoteStatistics'
data GetPollVoteStatistics
  = GetPollVoteStatistics
    { GetPollVoteStatistics -> Maybe Int
chat_id    :: Maybe Int  -- ^ Identifier of the chat to which the poll belongs
    , GetPollVoteStatistics -> Maybe Int
message_id :: Maybe Int  -- ^ Identifier of the message containing the poll. Use messageProperties.can_get_poll_vote_statistics to check whether the method can be used for a message
    , GetPollVoteStatistics -> Maybe Bool
is_dark    :: Maybe Bool -- ^ Pass true if a dark theme is used by the application
    }
  deriving (GetPollVoteStatistics -> GetPollVoteStatistics -> Bool
(GetPollVoteStatistics -> GetPollVoteStatistics -> Bool)
-> (GetPollVoteStatistics -> GetPollVoteStatistics -> Bool)
-> Eq GetPollVoteStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetPollVoteStatistics -> GetPollVoteStatistics -> Bool
== :: GetPollVoteStatistics -> GetPollVoteStatistics -> Bool
$c/= :: GetPollVoteStatistics -> GetPollVoteStatistics -> Bool
/= :: GetPollVoteStatistics -> GetPollVoteStatistics -> Bool
Eq, Int -> GetPollVoteStatistics -> ShowS
[GetPollVoteStatistics] -> ShowS
GetPollVoteStatistics -> String
(Int -> GetPollVoteStatistics -> ShowS)
-> (GetPollVoteStatistics -> String)
-> ([GetPollVoteStatistics] -> ShowS)
-> Show GetPollVoteStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetPollVoteStatistics -> ShowS
showsPrec :: Int -> GetPollVoteStatistics -> ShowS
$cshow :: GetPollVoteStatistics -> String
show :: GetPollVoteStatistics -> String
$cshowList :: [GetPollVoteStatistics] -> ShowS
showList :: [GetPollVoteStatistics] -> ShowS
Show)

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

instance AT.ToJSON GetPollVoteStatistics where
  toJSON :: GetPollVoteStatistics -> Value
toJSON
    GetPollVoteStatistics
      { chat_id :: GetPollVoteStatistics -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , message_id :: GetPollVoteStatistics -> Maybe Int
message_id = Maybe Int
message_id_
      , is_dark :: GetPollVoteStatistics -> Maybe Bool
is_dark    = Maybe Bool
is_dark_
      }
        = [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
"getPollVoteStatistics"
          , 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
"is_dark"    Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_dark_
          ]

defaultGetPollVoteStatistics :: GetPollVoteStatistics
defaultGetPollVoteStatistics :: GetPollVoteStatistics
defaultGetPollVoteStatistics =
  GetPollVoteStatistics
    { 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
    , is_dark :: Maybe Bool
is_dark    = Maybe Bool
forall a. Maybe a
Nothing
    }