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 Data.Text as T

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, getChatsToSendStories, 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_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. Always true for channels and non-discussion supergroups
    , Supergroup -> Maybe Bool
join_by_request           :: Maybe Bool                              -- ^ True, if all users directly joining the supergroup need to be approved by supergroup administrators. Always false for channels and supergroups without 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_verified               :: Maybe Bool                              -- ^ True, if the supergroup or channel is verified
    , Supergroup -> Maybe Bool
has_sensitive_content     :: Maybe Bool                              -- ^ True, if content of media messages in the supergroup or channel chat must be hidden with 18+ spoiler
    , Supergroup -> Maybe Text
restriction_reason        :: Maybe T.Text                            -- ^ If non-empty, contains a human-readable description of the reason why access to this supergroup or channel must be restricted
    , Supergroup -> Maybe Bool
is_scam                   :: Maybe Bool                              -- ^ True, if many users reported this supergroup or channel as a scam
    , Supergroup -> Maybe Bool
is_fake                   :: Maybe Bool                              -- ^ True, if many users reported this supergroup or channel as a fake account
    , 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_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_verified :: Supergroup -> Maybe Bool
is_verified               = Maybe Bool
is_verified_
    , has_sensitive_content :: Supergroup -> Maybe Bool
has_sensitive_content     = Maybe Bool
has_sensitive_content_
    , restriction_reason :: Supergroup -> Maybe Text
restriction_reason        = Maybe Text
restriction_reason_
    , is_scam :: Supergroup -> Maybe Bool
is_scam                   = Maybe Bool
is_scam_
    , is_fake :: Supergroup -> Maybe Bool
is_fake                   = Maybe Bool
is_fake_
    , 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_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_verified"               String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_verified_
        , String
"has_sensitive_content"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_sensitive_content_
        , String
"restriction_reason"        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
restriction_reason_
        , String
"is_scam"                   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_scam_
        , String
"is_fake"                   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_fake_
        , 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_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_verified_               <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_verified"
        Maybe Bool
has_sensitive_content_     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_sensitive_content"
        Maybe Text
restriction_reason_        <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"restriction_reason"
        Maybe Bool
is_scam_                   <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_scam"
        Maybe Bool
is_fake_                   <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_fake"
        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_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_verified :: Maybe Bool
is_verified               = Maybe Bool
is_verified_
          , has_sensitive_content :: Maybe Bool
has_sensitive_content     = Maybe Bool
has_sensitive_content_
          , restriction_reason :: Maybe Text
restriction_reason        = Maybe Text
restriction_reason_
          , is_scam :: Maybe Bool
is_scam                   = Maybe Bool
is_scam_
          , is_fake :: Maybe Bool
is_fake                   = Maybe Bool
is_fake_
          , 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