module TD.Data.GiveawayParticipantStatus
(GiveawayParticipantStatus(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
data GiveawayParticipantStatus
= GiveawayParticipantStatusEligible
| GiveawayParticipantStatusParticipating
| GiveawayParticipantStatusAlreadyWasMember
{ GiveawayParticipantStatus -> Maybe Int
joined_chat_date :: Maybe Int
}
| GiveawayParticipantStatusAdministrator
{ GiveawayParticipantStatus -> Maybe Int
chat_id :: Maybe Int
}
| GiveawayParticipantStatusDisallowedCountry
{ GiveawayParticipantStatus -> Maybe Text
user_country_code :: Maybe T.Text
}
deriving (GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool
(GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool)
-> (GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool)
-> Eq GiveawayParticipantStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool
== :: GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool
$c/= :: GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool
/= :: GiveawayParticipantStatus -> GiveawayParticipantStatus -> Bool
Eq, Int -> GiveawayParticipantStatus -> ShowS
[GiveawayParticipantStatus] -> ShowS
GiveawayParticipantStatus -> String
(Int -> GiveawayParticipantStatus -> ShowS)
-> (GiveawayParticipantStatus -> String)
-> ([GiveawayParticipantStatus] -> ShowS)
-> Show GiveawayParticipantStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiveawayParticipantStatus -> ShowS
showsPrec :: Int -> GiveawayParticipantStatus -> ShowS
$cshow :: GiveawayParticipantStatus -> String
show :: GiveawayParticipantStatus -> String
$cshowList :: [GiveawayParticipantStatus] -> ShowS
showList :: [GiveawayParticipantStatus] -> ShowS
Show)
instance I.ShortShow GiveawayParticipantStatus where
shortShow :: GiveawayParticipantStatus -> String
shortShow GiveawayParticipantStatus
GiveawayParticipantStatusEligible
= String
"GiveawayParticipantStatusEligible"
shortShow GiveawayParticipantStatus
GiveawayParticipantStatusParticipating
= String
"GiveawayParticipantStatusParticipating"
shortShow GiveawayParticipantStatusAlreadyWasMember
{ joined_chat_date :: GiveawayParticipantStatus -> Maybe Int
joined_chat_date = Maybe Int
joined_chat_date_
}
= String
"GiveawayParticipantStatusAlreadyWasMember"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"joined_chat_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
joined_chat_date_
]
shortShow GiveawayParticipantStatusAdministrator
{ chat_id :: GiveawayParticipantStatus -> Maybe Int
chat_id = Maybe Int
chat_id_
}
= String
"GiveawayParticipantStatusAdministrator"
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_
]
shortShow GiveawayParticipantStatusDisallowedCountry
{ user_country_code :: GiveawayParticipantStatus -> Maybe Text
user_country_code = Maybe Text
user_country_code_
}
= String
"GiveawayParticipantStatusDisallowedCountry"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_country_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
user_country_code_
]
instance AT.FromJSON GiveawayParticipantStatus where
parseJSON :: Value -> Parser GiveawayParticipantStatus
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"giveawayParticipantStatusEligible" -> GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GiveawayParticipantStatus
GiveawayParticipantStatusEligible
String
"giveawayParticipantStatusParticipating" -> GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GiveawayParticipantStatus
GiveawayParticipantStatusParticipating
String
"giveawayParticipantStatusAlreadyWasMember" -> Value -> Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusAlreadyWasMember Value
v
String
"giveawayParticipantStatusAdministrator" -> Value -> Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusAdministrator Value
v
String
"giveawayParticipantStatusDisallowedCountry" -> Value -> Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusDisallowedCountry Value
v
String
_ -> Parser GiveawayParticipantStatus
forall a. Monoid a => a
mempty
where
parseGiveawayParticipantStatusAlreadyWasMember :: A.Value -> AT.Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusAlreadyWasMember :: Value -> Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusAlreadyWasMember = String
-> (Object -> Parser GiveawayParticipantStatus)
-> Value
-> Parser GiveawayParticipantStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiveawayParticipantStatusAlreadyWasMember" ((Object -> Parser GiveawayParticipantStatus)
-> Value -> Parser GiveawayParticipantStatus)
-> (Object -> Parser GiveawayParticipantStatus)
-> Value
-> Parser GiveawayParticipantStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
joined_chat_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"joined_chat_date"
GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiveawayParticipantStatus -> Parser GiveawayParticipantStatus)
-> GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a b. (a -> b) -> a -> b
$ GiveawayParticipantStatusAlreadyWasMember
{ joined_chat_date :: Maybe Int
joined_chat_date = Maybe Int
joined_chat_date_
}
parseGiveawayParticipantStatusAdministrator :: A.Value -> AT.Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusAdministrator :: Value -> Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusAdministrator = String
-> (Object -> Parser GiveawayParticipantStatus)
-> Value
-> Parser GiveawayParticipantStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiveawayParticipantStatusAdministrator" ((Object -> Parser GiveawayParticipantStatus)
-> Value -> Parser GiveawayParticipantStatus)
-> (Object -> Parser GiveawayParticipantStatus)
-> Value
-> Parser GiveawayParticipantStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_id"
GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiveawayParticipantStatus -> Parser GiveawayParticipantStatus)
-> GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a b. (a -> b) -> a -> b
$ GiveawayParticipantStatusAdministrator
{ chat_id :: Maybe Int
chat_id = Maybe Int
chat_id_
}
parseGiveawayParticipantStatusDisallowedCountry :: A.Value -> AT.Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusDisallowedCountry :: Value -> Parser GiveawayParticipantStatus
parseGiveawayParticipantStatusDisallowedCountry = String
-> (Object -> Parser GiveawayParticipantStatus)
-> Value
-> Parser GiveawayParticipantStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiveawayParticipantStatusDisallowedCountry" ((Object -> Parser GiveawayParticipantStatus)
-> Value -> Parser GiveawayParticipantStatus)
-> (Object -> Parser GiveawayParticipantStatus)
-> Value
-> Parser GiveawayParticipantStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
user_country_code_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_country_code"
GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiveawayParticipantStatus -> Parser GiveawayParticipantStatus)
-> GiveawayParticipantStatus -> Parser GiveawayParticipantStatus
forall a b. (a -> b) -> a -> b
$ GiveawayParticipantStatusDisallowedCountry
{ user_country_code :: Maybe Text
user_country_code = Maybe Text
user_country_code_
}
parseJSON Value
_ = Parser GiveawayParticipantStatus
forall a. Monoid a => a
mempty