module TD.Data.ChatRevenueStatistics
(ChatRevenueStatistics(..)) 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.StatisticalGraph as StatisticalGraph
import qualified TD.Data.ChatRevenueAmount as ChatRevenueAmount
data ChatRevenueStatistics
= ChatRevenueStatistics
{ ChatRevenueStatistics -> Maybe StatisticalGraph
revenue_by_hour_graph :: Maybe StatisticalGraph.StatisticalGraph
, ChatRevenueStatistics -> Maybe StatisticalGraph
revenue_graph :: Maybe StatisticalGraph.StatisticalGraph
, ChatRevenueStatistics -> Maybe ChatRevenueAmount
revenue_amount :: Maybe ChatRevenueAmount.ChatRevenueAmount
, ChatRevenueStatistics -> Maybe Double
usd_rate :: Maybe Double
}
deriving (ChatRevenueStatistics -> ChatRevenueStatistics -> Bool
(ChatRevenueStatistics -> ChatRevenueStatistics -> Bool)
-> (ChatRevenueStatistics -> ChatRevenueStatistics -> Bool)
-> Eq ChatRevenueStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatRevenueStatistics -> ChatRevenueStatistics -> Bool
== :: ChatRevenueStatistics -> ChatRevenueStatistics -> Bool
$c/= :: ChatRevenueStatistics -> ChatRevenueStatistics -> Bool
/= :: ChatRevenueStatistics -> ChatRevenueStatistics -> Bool
Eq, Int -> ChatRevenueStatistics -> ShowS
[ChatRevenueStatistics] -> ShowS
ChatRevenueStatistics -> String
(Int -> ChatRevenueStatistics -> ShowS)
-> (ChatRevenueStatistics -> String)
-> ([ChatRevenueStatistics] -> ShowS)
-> Show ChatRevenueStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatRevenueStatistics -> ShowS
showsPrec :: Int -> ChatRevenueStatistics -> ShowS
$cshow :: ChatRevenueStatistics -> String
show :: ChatRevenueStatistics -> String
$cshowList :: [ChatRevenueStatistics] -> ShowS
showList :: [ChatRevenueStatistics] -> ShowS
Show)
instance I.ShortShow ChatRevenueStatistics where
shortShow :: ChatRevenueStatistics -> String
shortShow ChatRevenueStatistics
{ revenue_by_hour_graph :: ChatRevenueStatistics -> Maybe StatisticalGraph
revenue_by_hour_graph = Maybe StatisticalGraph
revenue_by_hour_graph_
, revenue_graph :: ChatRevenueStatistics -> Maybe StatisticalGraph
revenue_graph = Maybe StatisticalGraph
revenue_graph_
, revenue_amount :: ChatRevenueStatistics -> Maybe ChatRevenueAmount
revenue_amount = Maybe ChatRevenueAmount
revenue_amount_
, usd_rate :: ChatRevenueStatistics -> Maybe Double
usd_rate = Maybe Double
usd_rate_
}
= String
"ChatRevenueStatistics"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"revenue_by_hour_graph" String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
revenue_by_hour_graph_
, String
"revenue_graph" String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
revenue_graph_
, String
"revenue_amount" String -> Maybe ChatRevenueAmount -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatRevenueAmount
revenue_amount_
, String
"usd_rate" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
usd_rate_
]
instance AT.FromJSON ChatRevenueStatistics where
parseJSON :: Value -> Parser ChatRevenueStatistics
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
"chatRevenueStatistics" -> Value -> Parser ChatRevenueStatistics
parseChatRevenueStatistics Value
v
String
_ -> Parser ChatRevenueStatistics
forall a. Monoid a => a
mempty
where
parseChatRevenueStatistics :: A.Value -> AT.Parser ChatRevenueStatistics
parseChatRevenueStatistics :: Value -> Parser ChatRevenueStatistics
parseChatRevenueStatistics = String
-> (Object -> Parser ChatRevenueStatistics)
-> Value
-> Parser ChatRevenueStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatRevenueStatistics" ((Object -> Parser ChatRevenueStatistics)
-> Value -> Parser ChatRevenueStatistics)
-> (Object -> Parser ChatRevenueStatistics)
-> Value
-> Parser ChatRevenueStatistics
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe StatisticalGraph
revenue_by_hour_graph_ <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"revenue_by_hour_graph"
Maybe StatisticalGraph
revenue_graph_ <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"revenue_graph"
Maybe ChatRevenueAmount
revenue_amount_ <- Object
o Object -> Key -> Parser (Maybe ChatRevenueAmount)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"revenue_amount"
Maybe Double
usd_rate_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"usd_rate"
ChatRevenueStatistics -> Parser ChatRevenueStatistics
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatRevenueStatistics -> Parser ChatRevenueStatistics)
-> ChatRevenueStatistics -> Parser ChatRevenueStatistics
forall a b. (a -> b) -> a -> b
$ ChatRevenueStatistics
{ revenue_by_hour_graph :: Maybe StatisticalGraph
revenue_by_hour_graph = Maybe StatisticalGraph
revenue_by_hour_graph_
, revenue_graph :: Maybe StatisticalGraph
revenue_graph = Maybe StatisticalGraph
revenue_graph_
, revenue_amount :: Maybe ChatRevenueAmount
revenue_amount = Maybe ChatRevenueAmount
revenue_amount_
, usd_rate :: Maybe Double
usd_rate = Maybe Double
usd_rate_
}
parseJSON Value
_ = Parser ChatRevenueStatistics
forall a. Monoid a => a
mempty