module TD.Data.ChatBoostSlot
(ChatBoostSlot(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ChatBoostSlot
= ChatBoostSlot
{ ChatBoostSlot -> Maybe Int
slot_id :: Maybe Int
, ChatBoostSlot -> Maybe Int
currently_boosted_chat_id :: Maybe Int
, ChatBoostSlot -> Maybe Int
start_date :: Maybe Int
, ChatBoostSlot -> Maybe Int
expiration_date :: Maybe Int
, ChatBoostSlot -> Maybe Int
cooldown_until_date :: Maybe Int
}
deriving (ChatBoostSlot -> ChatBoostSlot -> Bool
(ChatBoostSlot -> ChatBoostSlot -> Bool)
-> (ChatBoostSlot -> ChatBoostSlot -> Bool) -> Eq ChatBoostSlot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatBoostSlot -> ChatBoostSlot -> Bool
== :: ChatBoostSlot -> ChatBoostSlot -> Bool
$c/= :: ChatBoostSlot -> ChatBoostSlot -> Bool
/= :: ChatBoostSlot -> ChatBoostSlot -> Bool
Eq, Int -> ChatBoostSlot -> ShowS
[ChatBoostSlot] -> ShowS
ChatBoostSlot -> String
(Int -> ChatBoostSlot -> ShowS)
-> (ChatBoostSlot -> String)
-> ([ChatBoostSlot] -> ShowS)
-> Show ChatBoostSlot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatBoostSlot -> ShowS
showsPrec :: Int -> ChatBoostSlot -> ShowS
$cshow :: ChatBoostSlot -> String
show :: ChatBoostSlot -> String
$cshowList :: [ChatBoostSlot] -> ShowS
showList :: [ChatBoostSlot] -> ShowS
Show)
instance I.ShortShow ChatBoostSlot where
shortShow :: ChatBoostSlot -> String
shortShow ChatBoostSlot
{ slot_id :: ChatBoostSlot -> Maybe Int
slot_id = Maybe Int
slot_id_
, currently_boosted_chat_id :: ChatBoostSlot -> Maybe Int
currently_boosted_chat_id = Maybe Int
currently_boosted_chat_id_
, start_date :: ChatBoostSlot -> Maybe Int
start_date = Maybe Int
start_date_
, expiration_date :: ChatBoostSlot -> Maybe Int
expiration_date = Maybe Int
expiration_date_
, cooldown_until_date :: ChatBoostSlot -> Maybe Int
cooldown_until_date = Maybe Int
cooldown_until_date_
}
= String
"ChatBoostSlot"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"slot_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
slot_id_
, String
"currently_boosted_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
currently_boosted_chat_id_
, String
"start_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
start_date_
, String
"expiration_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
expiration_date_
, String
"cooldown_until_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
cooldown_until_date_
]
instance AT.FromJSON ChatBoostSlot where
parseJSON :: Value -> Parser ChatBoostSlot
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
"chatBoostSlot" -> Value -> Parser ChatBoostSlot
parseChatBoostSlot Value
v
String
_ -> Parser ChatBoostSlot
forall a. Monoid a => a
mempty
where
parseChatBoostSlot :: A.Value -> AT.Parser ChatBoostSlot
parseChatBoostSlot :: Value -> Parser ChatBoostSlot
parseChatBoostSlot = String
-> (Object -> Parser ChatBoostSlot)
-> Value
-> Parser ChatBoostSlot
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatBoostSlot" ((Object -> Parser ChatBoostSlot) -> Value -> Parser ChatBoostSlot)
-> (Object -> Parser ChatBoostSlot)
-> Value
-> Parser ChatBoostSlot
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
slot_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"slot_id"
Maybe Int
currently_boosted_chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currently_boosted_chat_id"
Maybe Int
start_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"start_date"
Maybe Int
expiration_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"expiration_date"
Maybe Int
cooldown_until_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"cooldown_until_date"
ChatBoostSlot -> Parser ChatBoostSlot
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatBoostSlot -> Parser ChatBoostSlot)
-> ChatBoostSlot -> Parser ChatBoostSlot
forall a b. (a -> b) -> a -> b
$ ChatBoostSlot
{ slot_id :: Maybe Int
slot_id = Maybe Int
slot_id_
, currently_boosted_chat_id :: Maybe Int
currently_boosted_chat_id = Maybe Int
currently_boosted_chat_id_
, start_date :: Maybe Int
start_date = Maybe Int
start_date_
, expiration_date :: Maybe Int
expiration_date = Maybe Int
expiration_date_
, cooldown_until_date :: Maybe Int
cooldown_until_date = Maybe Int
cooldown_until_date_
}
parseJSON Value
_ = Parser ChatBoostSlot
forall a. Monoid a => a
mempty