module TD.Data.ChatStatistics
  (ChatStatistics(..)) 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.DateRange as DateRange
import qualified TD.Data.StatisticalValue as StatisticalValue
import qualified TD.Data.StatisticalGraph as StatisticalGraph
import qualified TD.Data.ChatStatisticsMessageSenderInfo as ChatStatisticsMessageSenderInfo
import qualified TD.Data.ChatStatisticsAdministratorActionsInfo as ChatStatisticsAdministratorActionsInfo
import qualified TD.Data.ChatStatisticsInviterInfo as ChatStatisticsInviterInfo
import qualified TD.Data.ChatStatisticsInteractionInfo as ChatStatisticsInteractionInfo

-- | Contains a detailed statistics about a chat
data ChatStatistics
  = ChatStatisticsSupergroup -- ^ A detailed statistics about a supergroup chat
    { ChatStatistics -> Maybe DateRange
period                :: Maybe DateRange.DateRange                                                             -- ^ A period to which the statistics applies
    , ChatStatistics -> Maybe StatisticalValue
member_count          :: Maybe StatisticalValue.StatisticalValue                                               -- ^ Number of members in the chat
    , ChatStatistics -> Maybe StatisticalValue
message_count         :: Maybe StatisticalValue.StatisticalValue                                               -- ^ Number of messages sent to the chat
    , ChatStatistics -> Maybe StatisticalValue
viewer_count          :: Maybe StatisticalValue.StatisticalValue                                               -- ^ Number of users who viewed messages in the chat
    , ChatStatistics -> Maybe StatisticalValue
sender_count          :: Maybe StatisticalValue.StatisticalValue                                               -- ^ Number of users who sent messages to the chat
    , ChatStatistics -> Maybe StatisticalGraph
member_count_graph    :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing number of members in the chat
    , ChatStatistics -> Maybe StatisticalGraph
join_graph            :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing number of members joined and left the chat
    , ChatStatistics -> Maybe StatisticalGraph
join_by_source_graph  :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing number of new member joins per source
    , ChatStatistics -> Maybe StatisticalGraph
language_graph        :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing distribution of active users per language
    , ChatStatistics -> Maybe StatisticalGraph
message_content_graph :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing distribution of sent messages by content type
    , ChatStatistics -> Maybe StatisticalGraph
action_graph          :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing number of different actions in the chat
    , ChatStatistics -> Maybe StatisticalGraph
day_graph             :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing distribution of message views per hour
    , ChatStatistics -> Maybe StatisticalGraph
week_graph            :: Maybe StatisticalGraph.StatisticalGraph                                               -- ^ A graph containing distribution of message views per day of week
    , ChatStatistics -> Maybe [ChatStatisticsMessageSenderInfo]
top_senders           :: Maybe [ChatStatisticsMessageSenderInfo.ChatStatisticsMessageSenderInfo]               -- ^ List of users sent most messages in the last week
    , ChatStatistics -> Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators    :: Maybe [ChatStatisticsAdministratorActionsInfo.ChatStatisticsAdministratorActionsInfo] -- ^ List of most active administrators in the last week
    , ChatStatistics -> Maybe [ChatStatisticsInviterInfo]
top_inviters          :: Maybe [ChatStatisticsInviterInfo.ChatStatisticsInviterInfo]                           -- ^ List of most active inviters of new members in the last week
    }
  | ChatStatisticsChannel -- ^ A detailed statistics about a channel chat
    { period                           :: Maybe DateRange.DateRange                                           -- ^ A period to which the statistics applies
    , member_count                     :: Maybe StatisticalValue.StatisticalValue                             -- ^ Number of members in the chat
    , ChatStatistics -> Maybe StatisticalValue
mean_message_view_count          :: Maybe StatisticalValue.StatisticalValue                             -- ^ Mean number of times the recently sent messages were viewed
    , ChatStatistics -> Maybe StatisticalValue
mean_message_share_count         :: Maybe StatisticalValue.StatisticalValue                             -- ^ Mean number of times the recently sent messages were shared
    , ChatStatistics -> Maybe StatisticalValue
mean_message_reaction_count      :: Maybe StatisticalValue.StatisticalValue                             -- ^ Mean number of times reactions were added to the recently sent messages
    , ChatStatistics -> Maybe StatisticalValue
mean_story_view_count            :: Maybe StatisticalValue.StatisticalValue                             -- ^ Mean number of times the recently sent stories were viewed
    , ChatStatistics -> Maybe StatisticalValue
mean_story_share_count           :: Maybe StatisticalValue.StatisticalValue                             -- ^ Mean number of times the recently sent stories were shared
    , ChatStatistics -> Maybe StatisticalValue
mean_story_reaction_count        :: Maybe StatisticalValue.StatisticalValue                             -- ^ Mean number of times reactions were added to the recently sent stories
    , ChatStatistics -> Maybe Double
enabled_notifications_percentage :: Maybe Double                                                        -- ^ A percentage of users with enabled notifications for the chat; 0-100
    , member_count_graph               :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of members in the chat
    , join_graph                       :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of members joined and left the chat
    , ChatStatistics -> Maybe StatisticalGraph
mute_graph                       :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of members muted and unmuted the chat
    , ChatStatistics -> Maybe StatisticalGraph
view_count_by_hour_graph         :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of message views in a given hour in the last two weeks
    , ChatStatistics -> Maybe StatisticalGraph
view_count_by_source_graph       :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of message views per source
    , join_by_source_graph             :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of new member joins per source
    , language_graph                   :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of users viewed chat messages per language
    , ChatStatistics -> Maybe StatisticalGraph
message_interaction_graph        :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of chat message views and shares
    , ChatStatistics -> Maybe StatisticalGraph
message_reaction_graph           :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of reactions on messages
    , ChatStatistics -> Maybe StatisticalGraph
story_interaction_graph          :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of story views and shares
    , ChatStatistics -> Maybe StatisticalGraph
story_reaction_graph             :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of reactions on stories
    , ChatStatistics -> Maybe StatisticalGraph
instant_view_interaction_graph   :: Maybe StatisticalGraph.StatisticalGraph                             -- ^ A graph containing number of views of associated with the chat instant views
    , ChatStatistics -> Maybe [ChatStatisticsInteractionInfo]
recent_interactions              :: Maybe [ChatStatisticsInteractionInfo.ChatStatisticsInteractionInfo] -- ^ Detailed statistics about number of views and shares of recently sent messages and stories
    }
  deriving (ChatStatistics -> ChatStatistics -> Bool
(ChatStatistics -> ChatStatistics -> Bool)
-> (ChatStatistics -> ChatStatistics -> Bool) -> Eq ChatStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatStatistics -> ChatStatistics -> Bool
== :: ChatStatistics -> ChatStatistics -> Bool
$c/= :: ChatStatistics -> ChatStatistics -> Bool
/= :: ChatStatistics -> ChatStatistics -> Bool
Eq, Int -> ChatStatistics -> ShowS
[ChatStatistics] -> ShowS
ChatStatistics -> String
(Int -> ChatStatistics -> ShowS)
-> (ChatStatistics -> String)
-> ([ChatStatistics] -> ShowS)
-> Show ChatStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatStatistics -> ShowS
showsPrec :: Int -> ChatStatistics -> ShowS
$cshow :: ChatStatistics -> String
show :: ChatStatistics -> String
$cshowList :: [ChatStatistics] -> ShowS
showList :: [ChatStatistics] -> ShowS
Show)

instance I.ShortShow ChatStatistics where
  shortShow :: ChatStatistics -> String
shortShow ChatStatisticsSupergroup
    { period :: ChatStatistics -> Maybe DateRange
period                = Maybe DateRange
period_
    , member_count :: ChatStatistics -> Maybe StatisticalValue
member_count          = Maybe StatisticalValue
member_count_
    , message_count :: ChatStatistics -> Maybe StatisticalValue
message_count         = Maybe StatisticalValue
message_count_
    , viewer_count :: ChatStatistics -> Maybe StatisticalValue
viewer_count          = Maybe StatisticalValue
viewer_count_
    , sender_count :: ChatStatistics -> Maybe StatisticalValue
sender_count          = Maybe StatisticalValue
sender_count_
    , member_count_graph :: ChatStatistics -> Maybe StatisticalGraph
member_count_graph    = Maybe StatisticalGraph
member_count_graph_
    , join_graph :: ChatStatistics -> Maybe StatisticalGraph
join_graph            = Maybe StatisticalGraph
join_graph_
    , join_by_source_graph :: ChatStatistics -> Maybe StatisticalGraph
join_by_source_graph  = Maybe StatisticalGraph
join_by_source_graph_
    , language_graph :: ChatStatistics -> Maybe StatisticalGraph
language_graph        = Maybe StatisticalGraph
language_graph_
    , message_content_graph :: ChatStatistics -> Maybe StatisticalGraph
message_content_graph = Maybe StatisticalGraph
message_content_graph_
    , action_graph :: ChatStatistics -> Maybe StatisticalGraph
action_graph          = Maybe StatisticalGraph
action_graph_
    , day_graph :: ChatStatistics -> Maybe StatisticalGraph
day_graph             = Maybe StatisticalGraph
day_graph_
    , week_graph :: ChatStatistics -> Maybe StatisticalGraph
week_graph            = Maybe StatisticalGraph
week_graph_
    , top_senders :: ChatStatistics -> Maybe [ChatStatisticsMessageSenderInfo]
top_senders           = Maybe [ChatStatisticsMessageSenderInfo]
top_senders_
    , top_administrators :: ChatStatistics -> Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators    = Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators_
    , top_inviters :: ChatStatistics -> Maybe [ChatStatisticsInviterInfo]
top_inviters          = Maybe [ChatStatisticsInviterInfo]
top_inviters_
    }
      = String
"ChatStatisticsSupergroup"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"period"                String -> Maybe DateRange -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DateRange
period_
        , String
"member_count"          String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
member_count_
        , String
"message_count"         String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
message_count_
        , String
"viewer_count"          String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
viewer_count_
        , String
"sender_count"          String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
sender_count_
        , String
"member_count_graph"    String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
member_count_graph_
        , String
"join_graph"            String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
join_graph_
        , String
"join_by_source_graph"  String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
join_by_source_graph_
        , String
"language_graph"        String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
language_graph_
        , String
"message_content_graph" String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
message_content_graph_
        , String
"action_graph"          String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
action_graph_
        , String
"day_graph"             String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
day_graph_
        , String
"week_graph"            String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
week_graph_
        , String
"top_senders"           String -> Maybe [ChatStatisticsMessageSenderInfo] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatStatisticsMessageSenderInfo]
top_senders_
        , String
"top_administrators"    String -> Maybe [ChatStatisticsAdministratorActionsInfo] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators_
        , String
"top_inviters"          String -> Maybe [ChatStatisticsInviterInfo] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatStatisticsInviterInfo]
top_inviters_
        ]
  shortShow ChatStatisticsChannel
    { period :: ChatStatistics -> Maybe DateRange
period                           = Maybe DateRange
period_
    , member_count :: ChatStatistics -> Maybe StatisticalValue
member_count                     = Maybe StatisticalValue
member_count_
    , mean_message_view_count :: ChatStatistics -> Maybe StatisticalValue
mean_message_view_count          = Maybe StatisticalValue
mean_message_view_count_
    , mean_message_share_count :: ChatStatistics -> Maybe StatisticalValue
mean_message_share_count         = Maybe StatisticalValue
mean_message_share_count_
    , mean_message_reaction_count :: ChatStatistics -> Maybe StatisticalValue
mean_message_reaction_count      = Maybe StatisticalValue
mean_message_reaction_count_
    , mean_story_view_count :: ChatStatistics -> Maybe StatisticalValue
mean_story_view_count            = Maybe StatisticalValue
mean_story_view_count_
    , mean_story_share_count :: ChatStatistics -> Maybe StatisticalValue
mean_story_share_count           = Maybe StatisticalValue
mean_story_share_count_
    , mean_story_reaction_count :: ChatStatistics -> Maybe StatisticalValue
mean_story_reaction_count        = Maybe StatisticalValue
mean_story_reaction_count_
    , enabled_notifications_percentage :: ChatStatistics -> Maybe Double
enabled_notifications_percentage = Maybe Double
enabled_notifications_percentage_
    , member_count_graph :: ChatStatistics -> Maybe StatisticalGraph
member_count_graph               = Maybe StatisticalGraph
member_count_graph_
    , join_graph :: ChatStatistics -> Maybe StatisticalGraph
join_graph                       = Maybe StatisticalGraph
join_graph_
    , mute_graph :: ChatStatistics -> Maybe StatisticalGraph
mute_graph                       = Maybe StatisticalGraph
mute_graph_
    , view_count_by_hour_graph :: ChatStatistics -> Maybe StatisticalGraph
view_count_by_hour_graph         = Maybe StatisticalGraph
view_count_by_hour_graph_
    , view_count_by_source_graph :: ChatStatistics -> Maybe StatisticalGraph
view_count_by_source_graph       = Maybe StatisticalGraph
view_count_by_source_graph_
    , join_by_source_graph :: ChatStatistics -> Maybe StatisticalGraph
join_by_source_graph             = Maybe StatisticalGraph
join_by_source_graph_
    , language_graph :: ChatStatistics -> Maybe StatisticalGraph
language_graph                   = Maybe StatisticalGraph
language_graph_
    , message_interaction_graph :: ChatStatistics -> Maybe StatisticalGraph
message_interaction_graph        = Maybe StatisticalGraph
message_interaction_graph_
    , message_reaction_graph :: ChatStatistics -> Maybe StatisticalGraph
message_reaction_graph           = Maybe StatisticalGraph
message_reaction_graph_
    , story_interaction_graph :: ChatStatistics -> Maybe StatisticalGraph
story_interaction_graph          = Maybe StatisticalGraph
story_interaction_graph_
    , story_reaction_graph :: ChatStatistics -> Maybe StatisticalGraph
story_reaction_graph             = Maybe StatisticalGraph
story_reaction_graph_
    , instant_view_interaction_graph :: ChatStatistics -> Maybe StatisticalGraph
instant_view_interaction_graph   = Maybe StatisticalGraph
instant_view_interaction_graph_
    , recent_interactions :: ChatStatistics -> Maybe [ChatStatisticsInteractionInfo]
recent_interactions              = Maybe [ChatStatisticsInteractionInfo]
recent_interactions_
    }
      = String
"ChatStatisticsChannel"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"period"                           String -> Maybe DateRange -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DateRange
period_
        , String
"member_count"                     String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
member_count_
        , String
"mean_message_view_count"          String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
mean_message_view_count_
        , String
"mean_message_share_count"         String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
mean_message_share_count_
        , String
"mean_message_reaction_count"      String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
mean_message_reaction_count_
        , String
"mean_story_view_count"            String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
mean_story_view_count_
        , String
"mean_story_share_count"           String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
mean_story_share_count_
        , String
"mean_story_reaction_count"        String -> Maybe StatisticalValue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalValue
mean_story_reaction_count_
        , String
"enabled_notifications_percentage" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
enabled_notifications_percentage_
        , String
"member_count_graph"               String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
member_count_graph_
        , String
"join_graph"                       String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
join_graph_
        , String
"mute_graph"                       String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
mute_graph_
        , String
"view_count_by_hour_graph"         String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
view_count_by_hour_graph_
        , String
"view_count_by_source_graph"       String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
view_count_by_source_graph_
        , String
"join_by_source_graph"             String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
join_by_source_graph_
        , String
"language_graph"                   String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
language_graph_
        , String
"message_interaction_graph"        String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
message_interaction_graph_
        , String
"message_reaction_graph"           String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
message_reaction_graph_
        , String
"story_interaction_graph"          String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
story_interaction_graph_
        , String
"story_reaction_graph"             String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
story_reaction_graph_
        , String
"instant_view_interaction_graph"   String -> Maybe StatisticalGraph -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StatisticalGraph
instant_view_interaction_graph_
        , String
"recent_interactions"              String -> Maybe [ChatStatisticsInteractionInfo] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatStatisticsInteractionInfo]
recent_interactions_
        ]

instance AT.FromJSON ChatStatistics where
  parseJSON :: Value -> Parser ChatStatistics
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
"chatStatisticsSupergroup" -> Value -> Parser ChatStatistics
parseChatStatisticsSupergroup Value
v
      String
"chatStatisticsChannel"    -> Value -> Parser ChatStatistics
parseChatStatisticsChannel Value
v
      String
_                          -> Parser ChatStatistics
forall a. Monoid a => a
mempty
    
    where
      parseChatStatisticsSupergroup :: A.Value -> AT.Parser ChatStatistics
      parseChatStatisticsSupergroup :: Value -> Parser ChatStatistics
parseChatStatisticsSupergroup = String
-> (Object -> Parser ChatStatistics)
-> Value
-> Parser ChatStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatStatisticsSupergroup" ((Object -> Parser ChatStatistics)
 -> Value -> Parser ChatStatistics)
-> (Object -> Parser ChatStatistics)
-> Value
-> Parser ChatStatistics
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe DateRange
period_                <- Object
o Object -> Key -> Parser (Maybe DateRange)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"period"
        Maybe StatisticalValue
member_count_          <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_count"
        Maybe StatisticalValue
message_count_         <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"message_count"
        Maybe StatisticalValue
viewer_count_          <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"viewer_count"
        Maybe StatisticalValue
sender_count_          <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"sender_count"
        Maybe StatisticalGraph
member_count_graph_    <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_count_graph"
        Maybe StatisticalGraph
join_graph_            <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"join_graph"
        Maybe StatisticalGraph
join_by_source_graph_  <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"join_by_source_graph"
        Maybe StatisticalGraph
language_graph_        <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"language_graph"
        Maybe StatisticalGraph
message_content_graph_ <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"message_content_graph"
        Maybe StatisticalGraph
action_graph_          <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"action_graph"
        Maybe StatisticalGraph
day_graph_             <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"day_graph"
        Maybe StatisticalGraph
week_graph_            <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"week_graph"
        Maybe [ChatStatisticsMessageSenderInfo]
top_senders_           <- Object
o Object -> Key -> Parser (Maybe [ChatStatisticsMessageSenderInfo])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"top_senders"
        Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators_    <- Object
o Object
-> Key -> Parser (Maybe [ChatStatisticsAdministratorActionsInfo])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"top_administrators"
        Maybe [ChatStatisticsInviterInfo]
top_inviters_          <- Object
o Object -> Key -> Parser (Maybe [ChatStatisticsInviterInfo])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"top_inviters"
        ChatStatistics -> Parser ChatStatistics
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatStatistics -> Parser ChatStatistics)
-> ChatStatistics -> Parser ChatStatistics
forall a b. (a -> b) -> a -> b
$ ChatStatisticsSupergroup
          { period :: Maybe DateRange
period                = Maybe DateRange
period_
          , member_count :: Maybe StatisticalValue
member_count          = Maybe StatisticalValue
member_count_
          , message_count :: Maybe StatisticalValue
message_count         = Maybe StatisticalValue
message_count_
          , viewer_count :: Maybe StatisticalValue
viewer_count          = Maybe StatisticalValue
viewer_count_
          , sender_count :: Maybe StatisticalValue
sender_count          = Maybe StatisticalValue
sender_count_
          , member_count_graph :: Maybe StatisticalGraph
member_count_graph    = Maybe StatisticalGraph
member_count_graph_
          , join_graph :: Maybe StatisticalGraph
join_graph            = Maybe StatisticalGraph
join_graph_
          , join_by_source_graph :: Maybe StatisticalGraph
join_by_source_graph  = Maybe StatisticalGraph
join_by_source_graph_
          , language_graph :: Maybe StatisticalGraph
language_graph        = Maybe StatisticalGraph
language_graph_
          , message_content_graph :: Maybe StatisticalGraph
message_content_graph = Maybe StatisticalGraph
message_content_graph_
          , action_graph :: Maybe StatisticalGraph
action_graph          = Maybe StatisticalGraph
action_graph_
          , day_graph :: Maybe StatisticalGraph
day_graph             = Maybe StatisticalGraph
day_graph_
          , week_graph :: Maybe StatisticalGraph
week_graph            = Maybe StatisticalGraph
week_graph_
          , top_senders :: Maybe [ChatStatisticsMessageSenderInfo]
top_senders           = Maybe [ChatStatisticsMessageSenderInfo]
top_senders_
          , top_administrators :: Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators    = Maybe [ChatStatisticsAdministratorActionsInfo]
top_administrators_
          , top_inviters :: Maybe [ChatStatisticsInviterInfo]
top_inviters          = Maybe [ChatStatisticsInviterInfo]
top_inviters_
          }
      parseChatStatisticsChannel :: A.Value -> AT.Parser ChatStatistics
      parseChatStatisticsChannel :: Value -> Parser ChatStatistics
parseChatStatisticsChannel = String
-> (Object -> Parser ChatStatistics)
-> Value
-> Parser ChatStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatStatisticsChannel" ((Object -> Parser ChatStatistics)
 -> Value -> Parser ChatStatistics)
-> (Object -> Parser ChatStatistics)
-> Value
-> Parser ChatStatistics
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe DateRange
period_                           <- Object
o Object -> Key -> Parser (Maybe DateRange)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"period"
        Maybe StatisticalValue
member_count_                     <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_count"
        Maybe StatisticalValue
mean_message_view_count_          <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mean_message_view_count"
        Maybe StatisticalValue
mean_message_share_count_         <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mean_message_share_count"
        Maybe StatisticalValue
mean_message_reaction_count_      <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mean_message_reaction_count"
        Maybe StatisticalValue
mean_story_view_count_            <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mean_story_view_count"
        Maybe StatisticalValue
mean_story_share_count_           <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mean_story_share_count"
        Maybe StatisticalValue
mean_story_reaction_count_        <- Object
o Object -> Key -> Parser (Maybe StatisticalValue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mean_story_reaction_count"
        Maybe Double
enabled_notifications_percentage_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"enabled_notifications_percentage"
        Maybe StatisticalGraph
member_count_graph_               <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_count_graph"
        Maybe StatisticalGraph
join_graph_                       <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"join_graph"
        Maybe StatisticalGraph
mute_graph_                       <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mute_graph"
        Maybe StatisticalGraph
view_count_by_hour_graph_         <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"view_count_by_hour_graph"
        Maybe StatisticalGraph
view_count_by_source_graph_       <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"view_count_by_source_graph"
        Maybe StatisticalGraph
join_by_source_graph_             <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"join_by_source_graph"
        Maybe StatisticalGraph
language_graph_                   <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"language_graph"
        Maybe StatisticalGraph
message_interaction_graph_        <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"message_interaction_graph"
        Maybe StatisticalGraph
message_reaction_graph_           <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"message_reaction_graph"
        Maybe StatisticalGraph
story_interaction_graph_          <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"story_interaction_graph"
        Maybe StatisticalGraph
story_reaction_graph_             <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"story_reaction_graph"
        Maybe StatisticalGraph
instant_view_interaction_graph_   <- Object
o Object -> Key -> Parser (Maybe StatisticalGraph)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"instant_view_interaction_graph"
        Maybe [ChatStatisticsInteractionInfo]
recent_interactions_              <- Object
o Object -> Key -> Parser (Maybe [ChatStatisticsInteractionInfo])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"recent_interactions"
        ChatStatistics -> Parser ChatStatistics
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatStatistics -> Parser ChatStatistics)
-> ChatStatistics -> Parser ChatStatistics
forall a b. (a -> b) -> a -> b
$ ChatStatisticsChannel
          { period :: Maybe DateRange
period                           = Maybe DateRange
period_
          , member_count :: Maybe StatisticalValue
member_count                     = Maybe StatisticalValue
member_count_
          , mean_message_view_count :: Maybe StatisticalValue
mean_message_view_count          = Maybe StatisticalValue
mean_message_view_count_
          , mean_message_share_count :: Maybe StatisticalValue
mean_message_share_count         = Maybe StatisticalValue
mean_message_share_count_
          , mean_message_reaction_count :: Maybe StatisticalValue
mean_message_reaction_count      = Maybe StatisticalValue
mean_message_reaction_count_
          , mean_story_view_count :: Maybe StatisticalValue
mean_story_view_count            = Maybe StatisticalValue
mean_story_view_count_
          , mean_story_share_count :: Maybe StatisticalValue
mean_story_share_count           = Maybe StatisticalValue
mean_story_share_count_
          , mean_story_reaction_count :: Maybe StatisticalValue
mean_story_reaction_count        = Maybe StatisticalValue
mean_story_reaction_count_
          , enabled_notifications_percentage :: Maybe Double
enabled_notifications_percentage = Maybe Double
enabled_notifications_percentage_
          , member_count_graph :: Maybe StatisticalGraph
member_count_graph               = Maybe StatisticalGraph
member_count_graph_
          , join_graph :: Maybe StatisticalGraph
join_graph                       = Maybe StatisticalGraph
join_graph_
          , mute_graph :: Maybe StatisticalGraph
mute_graph                       = Maybe StatisticalGraph
mute_graph_
          , view_count_by_hour_graph :: Maybe StatisticalGraph
view_count_by_hour_graph         = Maybe StatisticalGraph
view_count_by_hour_graph_
          , view_count_by_source_graph :: Maybe StatisticalGraph
view_count_by_source_graph       = Maybe StatisticalGraph
view_count_by_source_graph_
          , join_by_source_graph :: Maybe StatisticalGraph
join_by_source_graph             = Maybe StatisticalGraph
join_by_source_graph_
          , language_graph :: Maybe StatisticalGraph
language_graph                   = Maybe StatisticalGraph
language_graph_
          , message_interaction_graph :: Maybe StatisticalGraph
message_interaction_graph        = Maybe StatisticalGraph
message_interaction_graph_
          , message_reaction_graph :: Maybe StatisticalGraph
message_reaction_graph           = Maybe StatisticalGraph
message_reaction_graph_
          , story_interaction_graph :: Maybe StatisticalGraph
story_interaction_graph          = Maybe StatisticalGraph
story_interaction_graph_
          , story_reaction_graph :: Maybe StatisticalGraph
story_reaction_graph             = Maybe StatisticalGraph
story_reaction_graph_
          , instant_view_interaction_graph :: Maybe StatisticalGraph
instant_view_interaction_graph   = Maybe StatisticalGraph
instant_view_interaction_graph_
          , recent_interactions :: Maybe [ChatStatisticsInteractionInfo]
recent_interactions              = Maybe [ChatStatisticsInteractionInfo]
recent_interactions_
          }
  parseJSON Value
_ = Parser ChatStatistics
forall a. Monoid a => a
mempty