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

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text
import Data.Time.Clock.POSIX (POSIXTime)
import GHC.Generics (Generic)

import Telegram.Bot.API.Internal.Utils
import Telegram.Bot.API.Types.Chat

-- ** 'Giveaway'

-- | This object represents a message about a scheduled giveaway.
data Giveaway = Giveaway
  { Giveaway -> [Chat]
giveawayChats :: [Chat] -- ^ The list of chats which the user must join to participate in the giveaway
  , Giveaway -> POSIXTime
giveawayWinnersSelectionDate :: POSIXTime -- ^ Point in time (Unix timestamp) when winners of the giveaway will be selected.
  , Giveaway -> Int
giveawayWinnerCount :: Int -- ^ The number of users which are supposed to be selected as winners of the giveaway.
  , Giveaway -> Maybe Bool
giveawayOnlyNewMembers :: Maybe Bool -- ^ 'True', if only users who join the chats after the giveaway started should be eligible to win.
  , Giveaway -> Maybe Bool
giveawayHasPublicWinners :: Maybe Bool -- ^ 'True', if the list of giveaway winners will be visible to everyone.
  , Giveaway -> Maybe Text
giveawayPrizeDescription :: Maybe Text -- ^ Description of additional giveaway prize.
  , Giveaway -> Maybe [Text]
giveawayCountryCodes :: Maybe [Text] -- ^ A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
  , Giveaway -> Maybe Int
giveawayPremiumSubscriptionMonthCount :: Maybe Int -- ^ The number of months the Telegram Premium subscription won from the giveaway will be active for.
  }
  deriving ((forall x. Giveaway -> Rep Giveaway x)
-> (forall x. Rep Giveaway x -> Giveaway) -> Generic Giveaway
forall x. Rep Giveaway x -> Giveaway
forall x. Giveaway -> Rep Giveaway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Giveaway -> Rep Giveaway x
from :: forall x. Giveaway -> Rep Giveaway x
$cto :: forall x. Rep Giveaway x -> Giveaway
to :: forall x. Rep Giveaway x -> Giveaway
Generic, Int -> Giveaway -> ShowS
[Giveaway] -> ShowS
Giveaway -> String
(Int -> Giveaway -> ShowS)
-> (Giveaway -> String) -> ([Giveaway] -> ShowS) -> Show Giveaway
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Giveaway -> ShowS
showsPrec :: Int -> Giveaway -> ShowS
$cshow :: Giveaway -> String
show :: Giveaway -> String
$cshowList :: [Giveaway] -> ShowS
showList :: [Giveaway] -> ShowS
Show)

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