module TD.Data.FoundChatBoosts
(FoundChatBoosts(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.ChatBoost as ChatBoost
import qualified Data.Text as T
data FoundChatBoosts
= FoundChatBoosts
{ FoundChatBoosts -> Maybe Int
total_count :: Maybe Int
, FoundChatBoosts -> Maybe [ChatBoost]
boosts :: Maybe [ChatBoost.ChatBoost]
, FoundChatBoosts -> Maybe Text
next_offset :: Maybe T.Text
}
deriving (FoundChatBoosts -> FoundChatBoosts -> Bool
(FoundChatBoosts -> FoundChatBoosts -> Bool)
-> (FoundChatBoosts -> FoundChatBoosts -> Bool)
-> Eq FoundChatBoosts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FoundChatBoosts -> FoundChatBoosts -> Bool
== :: FoundChatBoosts -> FoundChatBoosts -> Bool
$c/= :: FoundChatBoosts -> FoundChatBoosts -> Bool
/= :: FoundChatBoosts -> FoundChatBoosts -> Bool
Eq, Int -> FoundChatBoosts -> ShowS
[FoundChatBoosts] -> ShowS
FoundChatBoosts -> String
(Int -> FoundChatBoosts -> ShowS)
-> (FoundChatBoosts -> String)
-> ([FoundChatBoosts] -> ShowS)
-> Show FoundChatBoosts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FoundChatBoosts -> ShowS
showsPrec :: Int -> FoundChatBoosts -> ShowS
$cshow :: FoundChatBoosts -> String
show :: FoundChatBoosts -> String
$cshowList :: [FoundChatBoosts] -> ShowS
showList :: [FoundChatBoosts] -> ShowS
Show)
instance I.ShortShow FoundChatBoosts where
shortShow :: FoundChatBoosts -> String
shortShow FoundChatBoosts
{ total_count :: FoundChatBoosts -> Maybe Int
total_count = Maybe Int
total_count_
, boosts :: FoundChatBoosts -> Maybe [ChatBoost]
boosts = Maybe [ChatBoost]
boosts_
, next_offset :: FoundChatBoosts -> Maybe Text
next_offset = Maybe Text
next_offset_
}
= String
"FoundChatBoosts"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"total_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
total_count_
, String
"boosts" String -> Maybe [ChatBoost] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatBoost]
boosts_
, String
"next_offset" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
next_offset_
]
instance AT.FromJSON FoundChatBoosts where
parseJSON :: Value -> Parser FoundChatBoosts
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
"foundChatBoosts" -> Value -> Parser FoundChatBoosts
parseFoundChatBoosts Value
v
String
_ -> Parser FoundChatBoosts
forall a. Monoid a => a
mempty
where
parseFoundChatBoosts :: A.Value -> AT.Parser FoundChatBoosts
parseFoundChatBoosts :: Value -> Parser FoundChatBoosts
parseFoundChatBoosts = String
-> (Object -> Parser FoundChatBoosts)
-> Value
-> Parser FoundChatBoosts
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FoundChatBoosts" ((Object -> Parser FoundChatBoosts)
-> Value -> Parser FoundChatBoosts)
-> (Object -> Parser FoundChatBoosts)
-> Value
-> Parser FoundChatBoosts
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
total_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"total_count"
Maybe [ChatBoost]
boosts_ <- Object
o Object -> Key -> Parser (Maybe [ChatBoost])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"boosts"
Maybe Text
next_offset_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_offset"
FoundChatBoosts -> Parser FoundChatBoosts
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FoundChatBoosts -> Parser FoundChatBoosts)
-> FoundChatBoosts -> Parser FoundChatBoosts
forall a b. (a -> b) -> a -> b
$ FoundChatBoosts
{ total_count :: Maybe Int
total_count = Maybe Int
total_count_
, boosts :: Maybe [ChatBoost]
boosts = Maybe [ChatBoost]
boosts_
, next_offset :: Maybe Text
next_offset = Maybe Text
next_offset_
}
parseJSON Value
_ = Parser FoundChatBoosts
forall a. Monoid a => a
mempty