module TD.Data.ChatRevenueTransactions
(ChatRevenueTransactions(..)) 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.ChatRevenueTransaction as ChatRevenueTransaction
data ChatRevenueTransactions
= ChatRevenueTransactions
{ ChatRevenueTransactions -> Maybe Int
total_count :: Maybe Int
, ChatRevenueTransactions -> Maybe [ChatRevenueTransaction]
transactions :: Maybe [ChatRevenueTransaction.ChatRevenueTransaction]
}
deriving (ChatRevenueTransactions -> ChatRevenueTransactions -> Bool
(ChatRevenueTransactions -> ChatRevenueTransactions -> Bool)
-> (ChatRevenueTransactions -> ChatRevenueTransactions -> Bool)
-> Eq ChatRevenueTransactions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatRevenueTransactions -> ChatRevenueTransactions -> Bool
== :: ChatRevenueTransactions -> ChatRevenueTransactions -> Bool
$c/= :: ChatRevenueTransactions -> ChatRevenueTransactions -> Bool
/= :: ChatRevenueTransactions -> ChatRevenueTransactions -> Bool
Eq, Int -> ChatRevenueTransactions -> ShowS
[ChatRevenueTransactions] -> ShowS
ChatRevenueTransactions -> String
(Int -> ChatRevenueTransactions -> ShowS)
-> (ChatRevenueTransactions -> String)
-> ([ChatRevenueTransactions] -> ShowS)
-> Show ChatRevenueTransactions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatRevenueTransactions -> ShowS
showsPrec :: Int -> ChatRevenueTransactions -> ShowS
$cshow :: ChatRevenueTransactions -> String
show :: ChatRevenueTransactions -> String
$cshowList :: [ChatRevenueTransactions] -> ShowS
showList :: [ChatRevenueTransactions] -> ShowS
Show)
instance I.ShortShow ChatRevenueTransactions where
shortShow :: ChatRevenueTransactions -> String
shortShow ChatRevenueTransactions
{ total_count :: ChatRevenueTransactions -> Maybe Int
total_count = Maybe Int
total_count_
, transactions :: ChatRevenueTransactions -> Maybe [ChatRevenueTransaction]
transactions = Maybe [ChatRevenueTransaction]
transactions_
}
= String
"ChatRevenueTransactions"
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
"transactions" String -> Maybe [ChatRevenueTransaction] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatRevenueTransaction]
transactions_
]
instance AT.FromJSON ChatRevenueTransactions where
parseJSON :: Value -> Parser ChatRevenueTransactions
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
"chatRevenueTransactions" -> Value -> Parser ChatRevenueTransactions
parseChatRevenueTransactions Value
v
String
_ -> Parser ChatRevenueTransactions
forall a. Monoid a => a
mempty
where
parseChatRevenueTransactions :: A.Value -> AT.Parser ChatRevenueTransactions
parseChatRevenueTransactions :: Value -> Parser ChatRevenueTransactions
parseChatRevenueTransactions = String
-> (Object -> Parser ChatRevenueTransactions)
-> Value
-> Parser ChatRevenueTransactions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatRevenueTransactions" ((Object -> Parser ChatRevenueTransactions)
-> Value -> Parser ChatRevenueTransactions)
-> (Object -> Parser ChatRevenueTransactions)
-> Value
-> Parser ChatRevenueTransactions
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 [ChatRevenueTransaction]
transactions_ <- Object
o Object -> Key -> Parser (Maybe [ChatRevenueTransaction])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"transactions"
ChatRevenueTransactions -> Parser ChatRevenueTransactions
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatRevenueTransactions -> Parser ChatRevenueTransactions)
-> ChatRevenueTransactions -> Parser ChatRevenueTransactions
forall a b. (a -> b) -> a -> b
$ ChatRevenueTransactions
{ total_count :: Maybe Int
total_count = Maybe Int
total_count_
, transactions :: Maybe [ChatRevenueTransaction]
transactions = Maybe [ChatRevenueTransaction]
transactions_
}
parseJSON Value
_ = Parser ChatRevenueTransactions
forall a. Monoid a => a
mempty