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

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

import Telegram.Bot.API.Types.Chat
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 -> Maybe Chat
pollAnswerVoterChat :: Maybe Chat -- ^ The chat that changed the answer to the poll, if the voter is anonymous.
  , PollAnswer -> Maybe User
pollAnswerUser      :: Maybe User   -- ^ The user that changed the answer to the poll, if the voter isn't anonymous. For backward compatibility, the field user in such objects will contain the user @136817688@ (\@Channel_Bot).
  , 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. PollAnswer -> Rep PollAnswer x)
-> (forall x. Rep PollAnswer x -> PollAnswer) -> Generic PollAnswer
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
$cfrom :: forall x. PollAnswer -> Rep PollAnswer x
from :: forall x. PollAnswer -> Rep PollAnswer x
$cto :: forall x. Rep PollAnswer x -> PollAnswer
to :: forall x. Rep PollAnswer x -> PollAnswer
Generic, Int -> PollAnswer -> ShowS
[PollAnswer] -> ShowS
PollAnswer -> String
(Int -> PollAnswer -> ShowS)
-> (PollAnswer -> String)
-> ([PollAnswer] -> ShowS)
-> Show PollAnswer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PollAnswer -> ShowS
showsPrec :: Int -> PollAnswer -> ShowS
$cshow :: PollAnswer -> String
show :: PollAnswer -> String
$cshowList :: [PollAnswer] -> ShowS
showList :: [PollAnswer] -> ShowS
Show)

instance ToJSON   PollAnswer where toJSON :: PollAnswer -> Value
toJSON = PollAnswer -> Value
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 = Value -> Parser PollAnswer
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON