{-# LANGUAGE DeriveGeneric #-}
module Telegram.Bot.API.Types.PollAnswer where

import Data.Aeson (FromJSON (..), ToJSON (..))
import GHC.Generics (Generic)

import Telegram.Bot.API.Types.Common
import Telegram.Bot.API.Types.User
import Telegram.Bot.API.Internal.Utils

-- ** 'PollAnswer'

-- | This object represents an answer of a user in a non-anonymous poll.
data PollAnswer = PollAnswer
  { PollAnswer -> PollId
pollAnswerPollId    :: PollId -- ^ Unique poll identifier.
  , PollAnswer -> User
pollAnswerUser      :: User   -- ^ The user, who changed the answer to the poll.
  , PollAnswer -> [Int]
pollAnswerOptionIds :: [Int]  -- ^ 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.
  }
  deriving (forall x. Rep PollAnswer x -> PollAnswer
forall x. PollAnswer -> Rep PollAnswer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PollAnswer x -> PollAnswer
$cfrom :: forall x. PollAnswer -> Rep PollAnswer x
Generic, Int -> PollAnswer -> ShowS
[PollAnswer] -> ShowS
PollAnswer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PollAnswer] -> ShowS
$cshowList :: [PollAnswer] -> ShowS
show :: PollAnswer -> String
$cshow :: PollAnswer -> String
showsPrec :: Int -> PollAnswer -> ShowS
$cshowsPrec :: Int -> PollAnswer -> ShowS
Show)

instance ToJSON   PollAnswer where toJSON :: PollAnswer -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON PollAnswer where parseJSON :: Value -> Parser PollAnswer
parseJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON