module TD.Data.ChatRevenueAmount
(ChatRevenueAmount(..)) 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 ChatRevenueAmount
= ChatRevenueAmount
{ ChatRevenueAmount -> Maybe Text
cryptocurrency :: Maybe T.Text
, ChatRevenueAmount -> Maybe Int
total_amount :: Maybe Int
, ChatRevenueAmount -> Maybe Int
balance_amount :: Maybe Int
, ChatRevenueAmount -> Maybe Int
available_amount :: Maybe Int
, ChatRevenueAmount -> Maybe Bool
withdrawal_enabled :: Maybe Bool
}
deriving (ChatRevenueAmount -> ChatRevenueAmount -> Bool
(ChatRevenueAmount -> ChatRevenueAmount -> Bool)
-> (ChatRevenueAmount -> ChatRevenueAmount -> Bool)
-> Eq ChatRevenueAmount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatRevenueAmount -> ChatRevenueAmount -> Bool
== :: ChatRevenueAmount -> ChatRevenueAmount -> Bool
$c/= :: ChatRevenueAmount -> ChatRevenueAmount -> Bool
/= :: ChatRevenueAmount -> ChatRevenueAmount -> Bool
Eq, Int -> ChatRevenueAmount -> ShowS
[ChatRevenueAmount] -> ShowS
ChatRevenueAmount -> String
(Int -> ChatRevenueAmount -> ShowS)
-> (ChatRevenueAmount -> String)
-> ([ChatRevenueAmount] -> ShowS)
-> Show ChatRevenueAmount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatRevenueAmount -> ShowS
showsPrec :: Int -> ChatRevenueAmount -> ShowS
$cshow :: ChatRevenueAmount -> String
show :: ChatRevenueAmount -> String
$cshowList :: [ChatRevenueAmount] -> ShowS
showList :: [ChatRevenueAmount] -> ShowS
Show)
instance I.ShortShow ChatRevenueAmount where
shortShow :: ChatRevenueAmount -> String
shortShow ChatRevenueAmount
{ cryptocurrency :: ChatRevenueAmount -> Maybe Text
cryptocurrency = Maybe Text
cryptocurrency_
, total_amount :: ChatRevenueAmount -> Maybe Int
total_amount = Maybe Int
total_amount_
, balance_amount :: ChatRevenueAmount -> Maybe Int
balance_amount = Maybe Int
balance_amount_
, available_amount :: ChatRevenueAmount -> Maybe Int
available_amount = Maybe Int
available_amount_
, withdrawal_enabled :: ChatRevenueAmount -> Maybe Bool
withdrawal_enabled = Maybe Bool
withdrawal_enabled_
}
= String
"ChatRevenueAmount"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"cryptocurrency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
cryptocurrency_
, String
"total_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
total_amount_
, String
"balance_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
balance_amount_
, String
"available_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
available_amount_
, String
"withdrawal_enabled" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
withdrawal_enabled_
]
instance AT.FromJSON ChatRevenueAmount where
parseJSON :: Value -> Parser ChatRevenueAmount
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
"chatRevenueAmount" -> Value -> Parser ChatRevenueAmount
parseChatRevenueAmount Value
v
String
_ -> Parser ChatRevenueAmount
forall a. Monoid a => a
mempty
where
parseChatRevenueAmount :: A.Value -> AT.Parser ChatRevenueAmount
parseChatRevenueAmount :: Value -> Parser ChatRevenueAmount
parseChatRevenueAmount = String
-> (Object -> Parser ChatRevenueAmount)
-> Value
-> Parser ChatRevenueAmount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatRevenueAmount" ((Object -> Parser ChatRevenueAmount)
-> Value -> Parser ChatRevenueAmount)
-> (Object -> Parser ChatRevenueAmount)
-> Value
-> Parser ChatRevenueAmount
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
cryptocurrency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"cryptocurrency"
Maybe Int
total_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"total_amount"
Maybe Int
balance_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"balance_amount"
Maybe Int
available_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"available_amount"
Maybe Bool
withdrawal_enabled_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"withdrawal_enabled"
ChatRevenueAmount -> Parser ChatRevenueAmount
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatRevenueAmount -> Parser ChatRevenueAmount)
-> ChatRevenueAmount -> Parser ChatRevenueAmount
forall a b. (a -> b) -> a -> b
$ ChatRevenueAmount
{ cryptocurrency :: Maybe Text
cryptocurrency = Maybe Text
cryptocurrency_
, total_amount :: Maybe Int
total_amount = Maybe Int
total_amount_
, balance_amount :: Maybe Int
balance_amount = Maybe Int
balance_amount_
, available_amount :: Maybe Int
available_amount = Maybe Int
available_amount_
, withdrawal_enabled :: Maybe Bool
withdrawal_enabled = Maybe Bool
withdrawal_enabled_
}
parseJSON Value
_ = Parser ChatRevenueAmount
forall a. Monoid a => a
mempty