module TD.Query.GetPollVoters
  (GetPollVoters(..)
  , defaultGetPollVoters
  ) where

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

-- | Returns message senders voted for the specified option in a non-anonymous polls. For optimal performance, the number of returned users is chosen by TDLib. Returns 'TD.Data.MessageSenders.MessageSenders'
data GetPollVoters
  = GetPollVoters
    { GetPollVoters -> Maybe Int
chat_id    :: Maybe Int -- ^ Identifier of the chat to which the poll belongs
    , GetPollVoters -> Maybe Int
message_id :: Maybe Int -- ^ Identifier of the message containing the poll
    , GetPollVoters -> Maybe Int
option_id  :: Maybe Int -- ^ 0-based identifier of the answer option
    , GetPollVoters -> Maybe Int
offset     :: Maybe Int -- ^ Number of voters to skip in the result; must be non-negative
    , GetPollVoters -> Maybe Int
limit      :: Maybe Int -- ^ The maximum number of voters to be returned; must be positive and can't be greater than 50. For optimal performance, the number of returned voters is chosen by TDLib and can be smaller than the specified limit, even if the end of the voter list has not been reached
    }
  deriving (GetPollVoters -> GetPollVoters -> Bool
(GetPollVoters -> GetPollVoters -> Bool)
-> (GetPollVoters -> GetPollVoters -> Bool) -> Eq GetPollVoters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetPollVoters -> GetPollVoters -> Bool
== :: GetPollVoters -> GetPollVoters -> Bool
$c/= :: GetPollVoters -> GetPollVoters -> Bool
/= :: GetPollVoters -> GetPollVoters -> Bool
Eq, Int -> GetPollVoters -> ShowS
[GetPollVoters] -> ShowS
GetPollVoters -> String
(Int -> GetPollVoters -> ShowS)
-> (GetPollVoters -> String)
-> ([GetPollVoters] -> ShowS)
-> Show GetPollVoters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetPollVoters -> ShowS
showsPrec :: Int -> GetPollVoters -> ShowS
$cshow :: GetPollVoters -> String
show :: GetPollVoters -> String
$cshowList :: [GetPollVoters] -> ShowS
showList :: [GetPollVoters] -> ShowS
Show)

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

instance AT.ToJSON GetPollVoters where
  toJSON :: GetPollVoters -> Value
toJSON
    GetPollVoters
      { chat_id :: GetPollVoters -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , message_id :: GetPollVoters -> Maybe Int
message_id = Maybe Int
message_id_
      , option_id :: GetPollVoters -> Maybe Int
option_id  = Maybe Int
option_id_
      , offset :: GetPollVoters -> Maybe Int
offset     = Maybe Int
offset_
      , limit :: GetPollVoters -> Maybe Int
limit      = Maybe Int
limit_
      }
        = [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
"getPollVoters"
          , 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 Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
option_id_
          , Key
"offset"     Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
offset_
          , Key
"limit"      Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetPollVoters :: GetPollVoters
defaultGetPollVoters :: GetPollVoters
defaultGetPollVoters =
  GetPollVoters
    { 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 Int
option_id  = Maybe Int
forall a. Maybe a
Nothing
    , offset :: Maybe Int
offset     = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit      = Maybe Int
forall a. Maybe a
Nothing
    }