module TD.Data.Supergroup
  (Supergroup(..)) 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.Usernames as Usernames
import qualified TD.Data.ChatMemberStatus as ChatMemberStatus
import qualified TD.Data.VerificationStatus as VerificationStatus
import qualified TD.Data.RestrictionInfo as RestrictionInfo

data Supergroup
  = Supergroup -- ^ Represents a supergroup or channel with zero or more members (subscribers in the case of channels). From the point of view of the system, a channel is a special kind of a supergroup: only administrators can post and see the list of members, and posts from all administrators use the name and photo of the channel instead of individual names and profile photos. Unlike supergroups, channels can have an unlimited number of subscribers
    { Supergroup -> Maybe Int
_id                                   :: Maybe Int                                   -- ^ Supergroup or channel identifier
    , Supergroup -> Maybe Usernames
usernames                             :: Maybe Usernames.Usernames                   -- ^ Usernames of the supergroup or channel; may be null
    , Supergroup -> Maybe Int
date                                  :: Maybe Int                                   -- ^ Point in time (Unix timestamp) when the current user joined, or the point in time when the supergroup or channel was created, in case the user is not a member
    , Supergroup -> Maybe ChatMemberStatus
status                                :: Maybe ChatMemberStatus.ChatMemberStatus     -- ^ Status of the current user in the supergroup or channel; custom title will always be empty
    , Supergroup -> Maybe Int
member_count                          :: Maybe Int                                   -- ^ Number of members in the supergroup or channel; 0 if unknown. Currently, it is guaranteed to be known only if the supergroup or channel was received through getChatSimilarChats, getChatsToPostStories, getCreatedPublicChats, getGroupsInCommon, getInactiveSupergroupChats, getRecommendedChats, getSuitableDiscussionChats, getUserPrivacySettingRules, getVideoChatAvailableParticipants, searchPublicChats, or in chatFolderInviteLinkInfo.missing_chat_ids, or in userFullInfo.personal_chat_id, or for chats with messages or stories from publicForwards and foundStories
    , Supergroup -> Maybe Int
boost_level                           :: Maybe Int                                   -- ^ Approximate boost level for the chat
    , Supergroup -> Maybe Bool
has_automatic_translation             :: Maybe Bool                                  -- ^ True, if automatic translation of messages is enabled in the channel
    , Supergroup -> Maybe Bool
has_linked_chat                       :: Maybe Bool                                  -- ^ True, if the channel has a discussion group, or the supergroup is the designated discussion group for a channel
    , Supergroup -> Maybe Bool
has_location                          :: Maybe Bool                                  -- ^ True, if the supergroup is connected to a location, i.e. the supergroup is a location-based supergroup
    , Supergroup -> Maybe Bool
sign_messages                         :: Maybe Bool                                  -- ^ True, if messages sent to the channel contains name of the sender. This field is only applicable to channels
    , Supergroup -> Maybe Bool
show_message_sender                   :: Maybe Bool                                  -- ^ True, if messages sent to the channel have information about the sender user. This field is only applicable to channels
    , Supergroup -> Maybe Bool
join_to_send_messages                 :: Maybe Bool                                  -- ^ True, if users need to join the supergroup before they can send messages. May be false only for discussion supergroups and channel direct messages groups
    , Supergroup -> Maybe Bool
join_by_request                       :: Maybe Bool                                  -- ^ True, if all users directly joining the supergroup need to be approved by supergroup administrators. May be true only for non-broadcast supergroups with username, location, or a linked chat
    , Supergroup -> Maybe Bool
is_slow_mode_enabled                  :: Maybe Bool                                  -- ^ True, if the slow mode is enabled in the supergroup
    , Supergroup -> Maybe Bool
is_channel                            :: Maybe Bool                                  -- ^ True, if the supergroup is a channel
    , Supergroup -> Maybe Bool
is_broadcast_group                    :: Maybe Bool                                  -- ^ True, if the supergroup is a broadcast group, i.e. only administrators can send messages and there is no limit on the number of members
    , Supergroup -> Maybe Bool
is_forum                              :: Maybe Bool                                  -- ^ True, if the supergroup is a forum with topics
    , Supergroup -> Maybe Bool
is_direct_messages_group              :: Maybe Bool                                  -- ^ True, if the supergroup is a direct message group for a channel chat
    , Supergroup -> Maybe Bool
is_administered_direct_messages_group :: Maybe Bool                                  -- ^ True, if the supergroup is a direct messages group for a channel chat that is administered by the current user
    , Supergroup -> Maybe VerificationStatus
verification_status                   :: Maybe VerificationStatus.VerificationStatus -- ^ Information about verification status of the supergroup or channel; may be null if none
    , Supergroup -> Maybe Bool
has_direct_messages_group             :: Maybe Bool                                  -- ^ True, if the channel has direct messages group
    , Supergroup -> Maybe Bool
has_forum_tabs                        :: Maybe Bool                                  -- ^ True, if the supergroup is a forum, which topics are shown in the same way as in channel direct messages groups
    , Supergroup -> Maybe RestrictionInfo
restriction_info                      :: Maybe RestrictionInfo.RestrictionInfo       -- ^ Information about the restrictions that must be applied to the corresponding supergroup or channel chat; may be null if none
    ,                :: Maybe Int                                   -- ^ Number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message
    , Supergroup -> Maybe Bool
has_active_stories                    :: Maybe Bool                                  -- ^ True, if the supergroup or channel has non-expired stories available to the current user
    , Supergroup -> Maybe Bool
has_unread_active_stories             :: Maybe Bool                                  -- ^ True, if the supergroup or channel has unread non-expired stories available to the current user
    }
  deriving (Supergroup -> Supergroup -> Bool
(Supergroup -> Supergroup -> Bool)
-> (Supergroup -> Supergroup -> Bool) -> Eq Supergroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Supergroup -> Supergroup -> Bool
== :: Supergroup -> Supergroup -> Bool
$c/= :: Supergroup -> Supergroup -> Bool
/= :: Supergroup -> Supergroup -> Bool
Eq, Int -> Supergroup -> ShowS
[Supergroup] -> ShowS
Supergroup -> String
(Int -> Supergroup -> ShowS)
-> (Supergroup -> String)
-> ([Supergroup] -> ShowS)
-> Show Supergroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Supergroup -> ShowS
showsPrec :: Int -> Supergroup -> ShowS
$cshow :: Supergroup -> String
show :: Supergroup -> String
$cshowList :: [Supergroup] -> ShowS
showList :: [Supergroup] -> ShowS
Show)

instance I.ShortShow Supergroup where
  shortShow :: Supergroup -> String
shortShow Supergroup
    { _id :: Supergroup -> Maybe Int
_id                                   = Maybe Int
_id_
    , usernames :: Supergroup -> Maybe Usernames
usernames                             = Maybe Usernames
usernames_
    , date :: Supergroup -> Maybe Int
date                                  = Maybe Int
date_
    , status :: Supergroup -> Maybe ChatMemberStatus
status                                = Maybe ChatMemberStatus
status_
    , member_count :: Supergroup -> Maybe Int
member_count                          = Maybe Int
member_count_
    , boost_level :: Supergroup -> Maybe Int
boost_level                           = Maybe Int
boost_level_
    , has_automatic_translation :: Supergroup -> Maybe Bool
has_automatic_translation             = Maybe Bool
has_automatic_translation_
    , has_linked_chat :: Supergroup -> Maybe Bool
has_linked_chat                       = Maybe Bool
has_linked_chat_
    , has_location :: Supergroup -> Maybe Bool
has_location                          = Maybe Bool
has_location_
    , sign_messages :: Supergroup -> Maybe Bool
sign_messages                         = Maybe Bool
sign_messages_
    , show_message_sender :: Supergroup -> Maybe Bool
show_message_sender                   = Maybe Bool
show_message_sender_
    , join_to_send_messages :: Supergroup -> Maybe Bool
join_to_send_messages                 = Maybe Bool
join_to_send_messages_
    , join_by_request :: Supergroup -> Maybe Bool
join_by_request                       = Maybe Bool
join_by_request_
    , is_slow_mode_enabled :: Supergroup -> Maybe Bool
is_slow_mode_enabled                  = Maybe Bool
is_slow_mode_enabled_
    , is_channel :: Supergroup -> Maybe Bool
is_channel                            = Maybe Bool
is_channel_
    , is_broadcast_group :: Supergroup -> Maybe Bool
is_broadcast_group                    = Maybe Bool
is_broadcast_group_
    , is_forum :: Supergroup -> Maybe Bool
is_forum                              = Maybe Bool
is_forum_
    , is_direct_messages_group :: Supergroup -> Maybe Bool
is_direct_messages_group              = Maybe Bool
is_direct_messages_group_
    , is_administered_direct_messages_group :: Supergroup -> Maybe Bool
is_administered_direct_messages_group = Maybe Bool
is_administered_direct_messages_group_
    , verification_status :: Supergroup -> Maybe VerificationStatus
verification_status                   = Maybe VerificationStatus
verification_status_
    , has_direct_messages_group :: Supergroup -> Maybe Bool
has_direct_messages_group             = Maybe Bool
has_direct_messages_group_
    , has_forum_tabs :: Supergroup -> Maybe Bool
has_forum_tabs                        = Maybe Bool
has_forum_tabs_
    , restriction_info :: Supergroup -> Maybe RestrictionInfo
restriction_info                      = Maybe RestrictionInfo
restriction_info_
    , paid_message_star_count :: Supergroup -> Maybe Int
paid_message_star_count               = Maybe Int
paid_message_star_count_
    , has_active_stories :: Supergroup -> Maybe Bool
has_active_stories                    = Maybe Bool
has_active_stories_
    , has_unread_active_stories :: Supergroup -> Maybe Bool
has_unread_active_stories             = Maybe Bool
has_unread_active_stories_
    }
      = String
"Supergroup"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"_id"                                   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
_id_
        , String
"usernames"                             String -> Maybe Usernames -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Usernames
usernames_
        , String
"date"                                  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
date_
        , String
"status"                                String -> Maybe ChatMemberStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatMemberStatus
status_
        , String
"member_count"                          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
member_count_
        , String
"boost_level"                           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
boost_level_
        , String
"has_automatic_translation"             String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_automatic_translation_
        , String
"has_linked_chat"                       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_linked_chat_
        , String
"has_location"                          String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_location_
        , String
"sign_messages"                         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
sign_messages_
        , String
"show_message_sender"                   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
show_message_sender_
        , String
"join_to_send_messages"                 String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
join_to_send_messages_
        , String
"join_by_request"                       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
join_by_request_
        , String
"is_slow_mode_enabled"                  String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_slow_mode_enabled_
        , String
"is_channel"                            String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_channel_
        , String
"is_broadcast_group"                    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_broadcast_group_
        , String
"is_forum"                              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_forum_
        , String
"is_direct_messages_group"              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_direct_messages_group_
        , String
"is_administered_direct_messages_group" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_administered_direct_messages_group_
        , String
"verification_status"                   String -> Maybe VerificationStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe VerificationStatus
verification_status_
        , String
"has_direct_messages_group"             String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_direct_messages_group_
        , String
"has_forum_tabs"                        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_forum_tabs_
        , String
"restriction_info"                      String -> Maybe RestrictionInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe RestrictionInfo
restriction_info_
        , String
"paid_message_star_count"               String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
paid_message_star_count_
        , String
"has_active_stories"                    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_active_stories_
        , String
"has_unread_active_stories"             String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_unread_active_stories_
        ]

instance AT.FromJSON Supergroup where
  parseJSON :: Value -> Parser Supergroup
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
"supergroup" -> Value -> Parser Supergroup
parseSupergroup Value
v
      String
_            -> Parser Supergroup
forall a. Monoid a => a
mempty
    
    where
      parseSupergroup :: A.Value -> AT.Parser Supergroup
      parseSupergroup :: Value -> Parser Supergroup
parseSupergroup = String
-> (Object -> Parser Supergroup) -> Value -> Parser Supergroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"Supergroup" ((Object -> Parser Supergroup) -> Value -> Parser Supergroup)
-> (Object -> Parser Supergroup) -> Value -> Parser Supergroup
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
_id_                                   <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"id"
        Maybe Usernames
usernames_                             <- Object
o Object -> Key -> Parser (Maybe Usernames)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"usernames"
        Maybe Int
date_                                  <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"date"
        Maybe ChatMemberStatus
status_                                <- Object
o Object -> Key -> Parser (Maybe ChatMemberStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"status"
        Maybe Int
member_count_                          <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_count"
        Maybe Int
boost_level_                           <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"boost_level"
        Maybe Bool
has_automatic_translation_             <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_automatic_translation"
        Maybe Bool
has_linked_chat_                       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_linked_chat"
        Maybe Bool
has_location_                          <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_location"
        Maybe Bool
sign_messages_                         <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"sign_messages"
        Maybe Bool
show_message_sender_                   <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"show_message_sender"
        Maybe Bool
join_to_send_messages_                 <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"join_to_send_messages"
        Maybe Bool
join_by_request_                       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"join_by_request"
        Maybe Bool
is_slow_mode_enabled_                  <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_slow_mode_enabled"
        Maybe Bool
is_channel_                            <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_channel"
        Maybe Bool
is_broadcast_group_                    <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_broadcast_group"
        Maybe Bool
is_forum_                              <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_forum"
        Maybe Bool
is_direct_messages_group_              <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_direct_messages_group"
        Maybe Bool
is_administered_direct_messages_group_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_administered_direct_messages_group"
        Maybe VerificationStatus
verification_status_                   <- Object
o Object -> Key -> Parser (Maybe VerificationStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"verification_status"
        Maybe Bool
has_direct_messages_group_             <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_direct_messages_group"
        Maybe Bool
has_forum_tabs_                        <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_forum_tabs"
        Maybe RestrictionInfo
restriction_info_                      <- Object
o Object -> Key -> Parser (Maybe RestrictionInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"restriction_info"
        Maybe Int
paid_message_star_count_               <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"paid_message_star_count"
        Maybe Bool
has_active_stories_                    <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_active_stories"
        Maybe Bool
has_unread_active_stories_             <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_unread_active_stories"
        Supergroup -> Parser Supergroup
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Supergroup -> Parser Supergroup)
-> Supergroup -> Parser Supergroup
forall a b. (a -> b) -> a -> b
$ Supergroup
          { _id :: Maybe Int
_id                                   = Maybe Int
_id_
          , usernames :: Maybe Usernames
usernames                             = Maybe Usernames
usernames_
          , date :: Maybe Int
date                                  = Maybe Int
date_
          , status :: Maybe ChatMemberStatus
status                                = Maybe ChatMemberStatus
status_
          , member_count :: Maybe Int
member_count                          = Maybe Int
member_count_
          , boost_level :: Maybe Int
boost_level                           = Maybe Int
boost_level_
          , has_automatic_translation :: Maybe Bool
has_automatic_translation             = Maybe Bool
has_automatic_translation_
          , has_linked_chat :: Maybe Bool
has_linked_chat                       = Maybe Bool
has_linked_chat_
          , has_location :: Maybe Bool
has_location                          = Maybe Bool
has_location_
          , sign_messages :: Maybe Bool
sign_messages                         = Maybe Bool
sign_messages_
          , show_message_sender :: Maybe Bool
show_message_sender                   = Maybe Bool
show_message_sender_
          , join_to_send_messages :: Maybe Bool
join_to_send_messages                 = Maybe Bool
join_to_send_messages_
          , join_by_request :: Maybe Bool
join_by_request                       = Maybe Bool
join_by_request_
          , is_slow_mode_enabled :: Maybe Bool
is_slow_mode_enabled                  = Maybe Bool
is_slow_mode_enabled_
          , is_channel :: Maybe Bool
is_channel                            = Maybe Bool
is_channel_
          , is_broadcast_group :: Maybe Bool
is_broadcast_group                    = Maybe Bool
is_broadcast_group_
          , is_forum :: Maybe Bool
is_forum                              = Maybe Bool
is_forum_
          , is_direct_messages_group :: Maybe Bool
is_direct_messages_group              = Maybe Bool
is_direct_messages_group_
          , is_administered_direct_messages_group :: Maybe Bool
is_administered_direct_messages_group = Maybe Bool
is_administered_direct_messages_group_
          , verification_status :: Maybe VerificationStatus
verification_status                   = Maybe VerificationStatus
verification_status_
          , has_direct_messages_group :: Maybe Bool
has_direct_messages_group             = Maybe Bool
has_direct_messages_group_
          , has_forum_tabs :: Maybe Bool
has_forum_tabs                        = Maybe Bool
has_forum_tabs_
          , restriction_info :: Maybe RestrictionInfo
restriction_info                      = Maybe RestrictionInfo
restriction_info_
          , paid_message_star_count :: Maybe Int
paid_message_star_count               = Maybe Int
paid_message_star_count_
          , has_active_stories :: Maybe Bool
has_active_stories                    = Maybe Bool
has_active_stories_
          , has_unread_active_stories :: Maybe Bool
has_unread_active_stories             = Maybe Bool
has_unread_active_stories_
          }
  parseJSON Value
_ = Parser Supergroup
forall a. Monoid a => a
mempty