module TD.Data.Chat
  (Chat(..)) 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.ChatType as ChatType
import qualified Data.Text as T
import qualified TD.Data.ChatPhotoInfo as ChatPhotoInfo
import qualified TD.Data.ChatPermissions as ChatPermissions
import qualified TD.Data.Message as Message
import qualified TD.Data.ChatPosition as ChatPosition
import qualified TD.Data.ChatList as ChatList
import qualified TD.Data.MessageSender as MessageSender
import qualified TD.Data.BlockList as BlockList
import qualified TD.Data.ChatNotificationSettings as ChatNotificationSettings
import qualified TD.Data.ChatAvailableReactions as ChatAvailableReactions
import qualified TD.Data.EmojiStatus as EmojiStatus
import qualified TD.Data.ChatBackground as ChatBackground
import qualified TD.Data.ChatActionBar as ChatActionBar
import qualified TD.Data.BusinessBotManageBar as BusinessBotManageBar
import qualified TD.Data.VideoChat as VideoChat
import qualified TD.Data.ChatJoinRequestsInfo as ChatJoinRequestsInfo
import qualified TD.Data.DraftMessage as DraftMessage

data Chat
  = Chat -- ^ A chat. (Can be a private chat, basic group, supergroup, or secret chat)
    { Chat -> Maybe Int
_id                                :: Maybe Int                                               -- ^ Chat unique identifier
    , Chat -> Maybe ChatType
_type                              :: Maybe ChatType.ChatType                                 -- ^ Type of the chat
    , Chat -> Maybe Text
title                              :: Maybe T.Text                                            -- ^ Chat title
    , Chat -> Maybe ChatPhotoInfo
photo                              :: Maybe ChatPhotoInfo.ChatPhotoInfo                       -- ^ Chat photo; may be null
    , Chat -> Maybe Int
accent_color_id                    :: Maybe Int                                               -- ^ Identifier of the accent color for message sender name, and backgrounds of chat photo, reply header, and link preview
    , Chat -> Maybe Int
background_custom_emoji_id         :: Maybe Int                                               -- ^ Identifier of a custom emoji to be shown on the reply header and link preview background for messages sent by the chat; 0 if none
    , Chat -> Maybe Int
profile_accent_color_id            :: Maybe Int                                               -- ^ Identifier of the profile accent color for the chat's profile; -1 if none
    , Chat -> Maybe Int
profile_background_custom_emoji_id :: Maybe Int                                               -- ^ Identifier of a custom emoji to be shown on the background of the chat's profile; 0 if none
    , Chat -> Maybe ChatPermissions
permissions                        :: Maybe ChatPermissions.ChatPermissions                   -- ^ Actions that non-administrator chat members are allowed to take in the chat
    , Chat -> Maybe Message
last_message                       :: Maybe Message.Message                                   -- ^ Last message in the chat; may be null if none or unknown
    , Chat -> Maybe [ChatPosition]
positions                          :: Maybe [ChatPosition.ChatPosition]                       -- ^ Positions of the chat in chat lists
    , Chat -> Maybe [ChatList]
chat_lists                         :: Maybe [ChatList.ChatList]                               -- ^ Chat lists to which the chat belongs. A chat can have a non-zero position in a chat list even it doesn't belong to the chat list and have no position in a chat list even it belongs to the chat list
    , Chat -> Maybe MessageSender
message_sender_id                  :: Maybe MessageSender.MessageSender                       -- ^ Identifier of a user or chat that is selected to send messages in the chat; may be null if the user can't change message sender
    , Chat -> Maybe BlockList
block_list                         :: Maybe BlockList.BlockList                               -- ^ Block list to which the chat is added; may be null if none
    , Chat -> Maybe Bool
has_protected_content              :: Maybe Bool                                              -- ^ True, if chat content can't be saved locally, forwarded, or copied
    , Chat -> Maybe Bool
is_translatable                    :: Maybe Bool                                              -- ^ True, if translation of all messages in the chat must be suggested to the user
    , Chat -> Maybe Bool
is_marked_as_unread                :: Maybe Bool                                              -- ^ True, if the chat is marked as unread
    , Chat -> Maybe Bool
view_as_topics                     :: Maybe Bool                                              -- ^ True, if the chat is a forum supergroup that must be shown in the "View as topics" mode, or Saved Messages chat that must be shown in the "View as chats"
    , Chat -> Maybe Bool
has_scheduled_messages             :: Maybe Bool                                              -- ^ True, if the chat has scheduled messages
    , Chat -> Maybe Bool
can_be_deleted_only_for_self       :: Maybe Bool                                              -- ^ True, if the chat messages can be deleted only for the current user while other users will continue to see the messages
    , Chat -> Maybe Bool
can_be_deleted_for_all_users       :: Maybe Bool                                              -- ^ True, if the chat messages can be deleted for all users
    , Chat -> Maybe Bool
can_be_reported                    :: Maybe Bool                                              -- ^ True, if the chat can be reported to Telegram moderators through reportChat or reportChatPhoto
    , Chat -> Maybe Bool
default_disable_notification       :: Maybe Bool                                              -- ^ Default value of the disable_notification parameter, used when a message is sent to the chat
    , Chat -> Maybe Int
unread_count                       :: Maybe Int                                               -- ^ Number of unread messages in the chat
    , Chat -> Maybe Int
last_read_inbox_message_id         :: Maybe Int                                               -- ^ Identifier of the last read incoming message
    , Chat -> Maybe Int
last_read_outbox_message_id        :: Maybe Int                                               -- ^ Identifier of the last read outgoing message
    , Chat -> Maybe Int
unread_mention_count               :: Maybe Int                                               -- ^ Number of unread messages with a mention/reply in the chat
    , Chat -> Maybe Int
unread_reaction_count              :: Maybe Int                                               -- ^ Number of messages with unread reactions in the chat
    , Chat -> Maybe ChatNotificationSettings
notification_settings              :: Maybe ChatNotificationSettings.ChatNotificationSettings -- ^ Notification settings for the chat
    , Chat -> Maybe ChatAvailableReactions
available_reactions                :: Maybe ChatAvailableReactions.ChatAvailableReactions     -- ^ Types of reaction, available in the chat
    , Chat -> Maybe Int
message_auto_delete_time           :: Maybe Int                                               -- ^ Current message auto-delete or self-destruct timer setting for the chat, in seconds; 0 if disabled. Self-destruct timer in secret chats starts after the message or its content is viewed. Auto-delete timer in other chats starts from the send date
    , Chat -> Maybe EmojiStatus
emoji_status                       :: Maybe EmojiStatus.EmojiStatus                           -- ^ Emoji status to be shown along with chat title; may be null
    , Chat -> Maybe ChatBackground
background                         :: Maybe ChatBackground.ChatBackground                     -- ^ Background set for the chat; may be null if none
    , Chat -> Maybe Text
theme_name                         :: Maybe T.Text                                            -- ^ If non-empty, name of a theme, set for the chat
    , Chat -> Maybe ChatActionBar
action_bar                         :: Maybe ChatActionBar.ChatActionBar                       -- ^ Information about actions which must be possible to do through the chat action bar; may be null if none
    , Chat -> Maybe BusinessBotManageBar
business_bot_manage_bar            :: Maybe BusinessBotManageBar.BusinessBotManageBar         -- ^ Information about bar for managing a business bot in the chat; may be null if none
    , Chat -> Maybe VideoChat
video_chat                         :: Maybe VideoChat.VideoChat                               -- ^ Information about video chat of the chat
    , Chat -> Maybe ChatJoinRequestsInfo
pending_join_requests              :: Maybe ChatJoinRequestsInfo.ChatJoinRequestsInfo         -- ^ Information about pending join requests; may be null if none
    , Chat -> Maybe Int
reply_markup_message_id            :: Maybe Int                                               -- ^ Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
    , Chat -> Maybe DraftMessage
draft_message                      :: Maybe DraftMessage.DraftMessage                         -- ^ A draft of a message in the chat; may be null if none
    , Chat -> Maybe Text
client_data                        :: Maybe T.Text                                            -- ^ Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
    }
  deriving (Chat -> Chat -> Bool
(Chat -> Chat -> Bool) -> (Chat -> Chat -> Bool) -> Eq Chat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Chat -> Chat -> Bool
== :: Chat -> Chat -> Bool
$c/= :: Chat -> Chat -> Bool
/= :: Chat -> Chat -> Bool
Eq, Int -> Chat -> ShowS
[Chat] -> ShowS
Chat -> String
(Int -> Chat -> ShowS)
-> (Chat -> String) -> ([Chat] -> ShowS) -> Show Chat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Chat -> ShowS
showsPrec :: Int -> Chat -> ShowS
$cshow :: Chat -> String
show :: Chat -> String
$cshowList :: [Chat] -> ShowS
showList :: [Chat] -> ShowS
Show)

instance I.ShortShow Chat where
  shortShow :: Chat -> String
shortShow Chat
    { _id :: Chat -> Maybe Int
_id                                = Maybe Int
_id_
    , _type :: Chat -> Maybe ChatType
_type                              = Maybe ChatType
_type_
    , title :: Chat -> Maybe Text
title                              = Maybe Text
title_
    , photo :: Chat -> Maybe ChatPhotoInfo
photo                              = Maybe ChatPhotoInfo
photo_
    , accent_color_id :: Chat -> Maybe Int
accent_color_id                    = Maybe Int
accent_color_id_
    , background_custom_emoji_id :: Chat -> Maybe Int
background_custom_emoji_id         = Maybe Int
background_custom_emoji_id_
    , profile_accent_color_id :: Chat -> Maybe Int
profile_accent_color_id            = Maybe Int
profile_accent_color_id_
    , profile_background_custom_emoji_id :: Chat -> Maybe Int
profile_background_custom_emoji_id = Maybe Int
profile_background_custom_emoji_id_
    , permissions :: Chat -> Maybe ChatPermissions
permissions                        = Maybe ChatPermissions
permissions_
    , last_message :: Chat -> Maybe Message
last_message                       = Maybe Message
last_message_
    , positions :: Chat -> Maybe [ChatPosition]
positions                          = Maybe [ChatPosition]
positions_
    , chat_lists :: Chat -> Maybe [ChatList]
chat_lists                         = Maybe [ChatList]
chat_lists_
    , message_sender_id :: Chat -> Maybe MessageSender
message_sender_id                  = Maybe MessageSender
message_sender_id_
    , block_list :: Chat -> Maybe BlockList
block_list                         = Maybe BlockList
block_list_
    , has_protected_content :: Chat -> Maybe Bool
has_protected_content              = Maybe Bool
has_protected_content_
    , is_translatable :: Chat -> Maybe Bool
is_translatable                    = Maybe Bool
is_translatable_
    , is_marked_as_unread :: Chat -> Maybe Bool
is_marked_as_unread                = Maybe Bool
is_marked_as_unread_
    , view_as_topics :: Chat -> Maybe Bool
view_as_topics                     = Maybe Bool
view_as_topics_
    , has_scheduled_messages :: Chat -> Maybe Bool
has_scheduled_messages             = Maybe Bool
has_scheduled_messages_
    , can_be_deleted_only_for_self :: Chat -> Maybe Bool
can_be_deleted_only_for_self       = Maybe Bool
can_be_deleted_only_for_self_
    , can_be_deleted_for_all_users :: Chat -> Maybe Bool
can_be_deleted_for_all_users       = Maybe Bool
can_be_deleted_for_all_users_
    , can_be_reported :: Chat -> Maybe Bool
can_be_reported                    = Maybe Bool
can_be_reported_
    , default_disable_notification :: Chat -> Maybe Bool
default_disable_notification       = Maybe Bool
default_disable_notification_
    , unread_count :: Chat -> Maybe Int
unread_count                       = Maybe Int
unread_count_
    , last_read_inbox_message_id :: Chat -> Maybe Int
last_read_inbox_message_id         = Maybe Int
last_read_inbox_message_id_
    , last_read_outbox_message_id :: Chat -> Maybe Int
last_read_outbox_message_id        = Maybe Int
last_read_outbox_message_id_
    , unread_mention_count :: Chat -> Maybe Int
unread_mention_count               = Maybe Int
unread_mention_count_
    , unread_reaction_count :: Chat -> Maybe Int
unread_reaction_count              = Maybe Int
unread_reaction_count_
    , notification_settings :: Chat -> Maybe ChatNotificationSettings
notification_settings              = Maybe ChatNotificationSettings
notification_settings_
    , available_reactions :: Chat -> Maybe ChatAvailableReactions
available_reactions                = Maybe ChatAvailableReactions
available_reactions_
    , message_auto_delete_time :: Chat -> Maybe Int
message_auto_delete_time           = Maybe Int
message_auto_delete_time_
    , emoji_status :: Chat -> Maybe EmojiStatus
emoji_status                       = Maybe EmojiStatus
emoji_status_
    , background :: Chat -> Maybe ChatBackground
background                         = Maybe ChatBackground
background_
    , theme_name :: Chat -> Maybe Text
theme_name                         = Maybe Text
theme_name_
    , action_bar :: Chat -> Maybe ChatActionBar
action_bar                         = Maybe ChatActionBar
action_bar_
    , business_bot_manage_bar :: Chat -> Maybe BusinessBotManageBar
business_bot_manage_bar            = Maybe BusinessBotManageBar
business_bot_manage_bar_
    , video_chat :: Chat -> Maybe VideoChat
video_chat                         = Maybe VideoChat
video_chat_
    , pending_join_requests :: Chat -> Maybe ChatJoinRequestsInfo
pending_join_requests              = Maybe ChatJoinRequestsInfo
pending_join_requests_
    , reply_markup_message_id :: Chat -> Maybe Int
reply_markup_message_id            = Maybe Int
reply_markup_message_id_
    , draft_message :: Chat -> Maybe DraftMessage
draft_message                      = Maybe DraftMessage
draft_message_
    , client_data :: Chat -> Maybe Text
client_data                        = Maybe Text
client_data_
    }
      = String
"Chat"
        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
"_type"                              String -> Maybe ChatType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatType
_type_
        , String
"title"                              String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
        , String
"photo"                              String -> Maybe ChatPhotoInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatPhotoInfo
photo_
        , String
"accent_color_id"                    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
accent_color_id_
        , String
"background_custom_emoji_id"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
background_custom_emoji_id_
        , String
"profile_accent_color_id"            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
profile_accent_color_id_
        , String
"profile_background_custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
profile_background_custom_emoji_id_
        , String
"permissions"                        String -> Maybe ChatPermissions -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatPermissions
permissions_
        , String
"last_message"                       String -> Maybe Message -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Message
last_message_
        , String
"positions"                          String -> Maybe [ChatPosition] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatPosition]
positions_
        , String
"chat_lists"                         String -> Maybe [ChatList] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatList]
chat_lists_
        , String
"message_sender_id"                  String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
message_sender_id_
        , String
"block_list"                         String -> Maybe BlockList -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BlockList
block_list_
        , String
"has_protected_content"              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_protected_content_
        , String
"is_translatable"                    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_translatable_
        , String
"is_marked_as_unread"                String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_marked_as_unread_
        , String
"view_as_topics"                     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
view_as_topics_
        , String
"has_scheduled_messages"             String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_scheduled_messages_
        , String
"can_be_deleted_only_for_self"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_deleted_only_for_self_
        , String
"can_be_deleted_for_all_users"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_deleted_for_all_users_
        , String
"can_be_reported"                    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_reported_
        , String
"default_disable_notification"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
default_disable_notification_
        , String
"unread_count"                       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
unread_count_
        , String
"last_read_inbox_message_id"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
last_read_inbox_message_id_
        , String
"last_read_outbox_message_id"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
last_read_outbox_message_id_
        , String
"unread_mention_count"               String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
unread_mention_count_
        , String
"unread_reaction_count"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
unread_reaction_count_
        , String
"notification_settings"              String -> Maybe ChatNotificationSettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatNotificationSettings
notification_settings_
        , String
"available_reactions"                String -> Maybe ChatAvailableReactions -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatAvailableReactions
available_reactions_
        , String
"message_auto_delete_time"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_auto_delete_time_
        , String
"emoji_status"                       String -> Maybe EmojiStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe EmojiStatus
emoji_status_
        , String
"background"                         String -> Maybe ChatBackground -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatBackground
background_
        , String
"theme_name"                         String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
theme_name_
        , String
"action_bar"                         String -> Maybe ChatActionBar -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatActionBar
action_bar_
        , String
"business_bot_manage_bar"            String -> Maybe BusinessBotManageBar -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BusinessBotManageBar
business_bot_manage_bar_
        , String
"video_chat"                         String -> Maybe VideoChat -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe VideoChat
video_chat_
        , String
"pending_join_requests"              String -> Maybe ChatJoinRequestsInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatJoinRequestsInfo
pending_join_requests_
        , String
"reply_markup_message_id"            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
reply_markup_message_id_
        , String
"draft_message"                      String -> Maybe DraftMessage -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe DraftMessage
draft_message_
        , String
"client_data"                        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
client_data_
        ]

instance AT.FromJSON Chat where
  parseJSON :: Value -> Parser Chat
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
"chat" -> Value -> Parser Chat
parseChat Value
v
      String
_      -> Parser Chat
forall a. Monoid a => a
mempty
    
    where
      parseChat :: A.Value -> AT.Parser Chat
      parseChat :: Value -> Parser Chat
parseChat = String -> (Object -> Parser Chat) -> Value -> Parser Chat
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"Chat" ((Object -> Parser Chat) -> Value -> Parser Chat)
-> (Object -> Parser Chat) -> Value -> Parser Chat
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 ChatType
_type_                              <- Object
o Object -> Key -> Parser (Maybe ChatType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"type"
        Maybe Text
title_                              <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"title"
        Maybe ChatPhotoInfo
photo_                              <- Object
o Object -> Key -> Parser (Maybe ChatPhotoInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"photo"
        Maybe Int
accent_color_id_                    <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"accent_color_id"
        Maybe Int
background_custom_emoji_id_         <- (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
"background_custom_emoji_id"
        Maybe Int
profile_accent_color_id_            <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"profile_accent_color_id"
        Maybe Int
profile_background_custom_emoji_id_ <- (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
"profile_background_custom_emoji_id"
        Maybe ChatPermissions
permissions_                        <- Object
o Object -> Key -> Parser (Maybe ChatPermissions)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"permissions"
        Maybe Message
last_message_                       <- Object
o Object -> Key -> Parser (Maybe Message)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"last_message"
        Maybe [ChatPosition]
positions_                          <- Object
o Object -> Key -> Parser (Maybe [ChatPosition])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"positions"
        Maybe [ChatList]
chat_lists_                         <- Object
o Object -> Key -> Parser (Maybe [ChatList])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"chat_lists"
        Maybe MessageSender
message_sender_id_                  <- Object
o Object -> Key -> Parser (Maybe MessageSender)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"message_sender_id"
        Maybe BlockList
block_list_                         <- Object
o Object -> Key -> Parser (Maybe BlockList)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"block_list"
        Maybe Bool
has_protected_content_              <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"has_protected_content"
        Maybe Bool
is_translatable_                    <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"is_translatable"
        Maybe Bool
is_marked_as_unread_                <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"is_marked_as_unread"
        Maybe Bool
view_as_topics_                     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"view_as_topics"
        Maybe Bool
has_scheduled_messages_             <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"has_scheduled_messages"
        Maybe Bool
can_be_deleted_only_for_self_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"can_be_deleted_only_for_self"
        Maybe Bool
can_be_deleted_for_all_users_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"can_be_deleted_for_all_users"
        Maybe Bool
can_be_reported_                    <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"can_be_reported"
        Maybe Bool
default_disable_notification_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"default_disable_notification"
        Maybe Int
unread_count_                       <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"unread_count"
        Maybe Int
last_read_inbox_message_id_         <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"last_read_inbox_message_id"
        Maybe Int
last_read_outbox_message_id_        <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"last_read_outbox_message_id"
        Maybe Int
unread_mention_count_               <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"unread_mention_count"
        Maybe Int
unread_reaction_count_              <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"unread_reaction_count"
        Maybe ChatNotificationSettings
notification_settings_              <- Object
o Object -> Key -> Parser (Maybe ChatNotificationSettings)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"notification_settings"
        Maybe ChatAvailableReactions
available_reactions_                <- Object
o Object -> Key -> Parser (Maybe ChatAvailableReactions)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"available_reactions"
        Maybe Int
message_auto_delete_time_           <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"message_auto_delete_time"
        Maybe EmojiStatus
emoji_status_                       <- Object
o Object -> Key -> Parser (Maybe EmojiStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"emoji_status"
        Maybe ChatBackground
background_                         <- Object
o Object -> Key -> Parser (Maybe ChatBackground)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"background"
        Maybe Text
theme_name_                         <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"theme_name"
        Maybe ChatActionBar
action_bar_                         <- Object
o Object -> Key -> Parser (Maybe ChatActionBar)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"action_bar"
        Maybe BusinessBotManageBar
business_bot_manage_bar_            <- Object
o Object -> Key -> Parser (Maybe BusinessBotManageBar)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"business_bot_manage_bar"
        Maybe VideoChat
video_chat_                         <- Object
o Object -> Key -> Parser (Maybe VideoChat)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"video_chat"
        Maybe ChatJoinRequestsInfo
pending_join_requests_              <- Object
o Object -> Key -> Parser (Maybe ChatJoinRequestsInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"pending_join_requests"
        Maybe Int
reply_markup_message_id_            <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"reply_markup_message_id"
        Maybe DraftMessage
draft_message_                      <- Object
o Object -> Key -> Parser (Maybe DraftMessage)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"draft_message"
        Maybe Text
client_data_                        <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"client_data"
        Chat -> Parser Chat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Chat -> Parser Chat) -> Chat -> Parser Chat
forall a b. (a -> b) -> a -> b
$ Chat
          { _id :: Maybe Int
_id                                = Maybe Int
_id_
          , _type :: Maybe ChatType
_type                              = Maybe ChatType
_type_
          , title :: Maybe Text
title                              = Maybe Text
title_
          , photo :: Maybe ChatPhotoInfo
photo                              = Maybe ChatPhotoInfo
photo_
          , accent_color_id :: Maybe Int
accent_color_id                    = Maybe Int
accent_color_id_
          , background_custom_emoji_id :: Maybe Int
background_custom_emoji_id         = Maybe Int
background_custom_emoji_id_
          , profile_accent_color_id :: Maybe Int
profile_accent_color_id            = Maybe Int
profile_accent_color_id_
          , profile_background_custom_emoji_id :: Maybe Int
profile_background_custom_emoji_id = Maybe Int
profile_background_custom_emoji_id_
          , permissions :: Maybe ChatPermissions
permissions                        = Maybe ChatPermissions
permissions_
          , last_message :: Maybe Message
last_message                       = Maybe Message
last_message_
          , positions :: Maybe [ChatPosition]
positions                          = Maybe [ChatPosition]
positions_
          , chat_lists :: Maybe [ChatList]
chat_lists                         = Maybe [ChatList]
chat_lists_
          , message_sender_id :: Maybe MessageSender
message_sender_id                  = Maybe MessageSender
message_sender_id_
          , block_list :: Maybe BlockList
block_list                         = Maybe BlockList
block_list_
          , has_protected_content :: Maybe Bool
has_protected_content              = Maybe Bool
has_protected_content_
          , is_translatable :: Maybe Bool
is_translatable                    = Maybe Bool
is_translatable_
          , is_marked_as_unread :: Maybe Bool
is_marked_as_unread                = Maybe Bool
is_marked_as_unread_
          , view_as_topics :: Maybe Bool
view_as_topics                     = Maybe Bool
view_as_topics_
          , has_scheduled_messages :: Maybe Bool
has_scheduled_messages             = Maybe Bool
has_scheduled_messages_
          , can_be_deleted_only_for_self :: Maybe Bool
can_be_deleted_only_for_self       = Maybe Bool
can_be_deleted_only_for_self_
          , can_be_deleted_for_all_users :: Maybe Bool
can_be_deleted_for_all_users       = Maybe Bool
can_be_deleted_for_all_users_
          , can_be_reported :: Maybe Bool
can_be_reported                    = Maybe Bool
can_be_reported_
          , default_disable_notification :: Maybe Bool
default_disable_notification       = Maybe Bool
default_disable_notification_
          , unread_count :: Maybe Int
unread_count                       = Maybe Int
unread_count_
          , last_read_inbox_message_id :: Maybe Int
last_read_inbox_message_id         = Maybe Int
last_read_inbox_message_id_
          , last_read_outbox_message_id :: Maybe Int
last_read_outbox_message_id        = Maybe Int
last_read_outbox_message_id_
          , unread_mention_count :: Maybe Int
unread_mention_count               = Maybe Int
unread_mention_count_
          , unread_reaction_count :: Maybe Int
unread_reaction_count              = Maybe Int
unread_reaction_count_
          , notification_settings :: Maybe ChatNotificationSettings
notification_settings              = Maybe ChatNotificationSettings
notification_settings_
          , available_reactions :: Maybe ChatAvailableReactions
available_reactions                = Maybe ChatAvailableReactions
available_reactions_
          , message_auto_delete_time :: Maybe Int
message_auto_delete_time           = Maybe Int
message_auto_delete_time_
          , emoji_status :: Maybe EmojiStatus
emoji_status                       = Maybe EmojiStatus
emoji_status_
          , background :: Maybe ChatBackground
background                         = Maybe ChatBackground
background_
          , theme_name :: Maybe Text
theme_name                         = Maybe Text
theme_name_
          , action_bar :: Maybe ChatActionBar
action_bar                         = Maybe ChatActionBar
action_bar_
          , business_bot_manage_bar :: Maybe BusinessBotManageBar
business_bot_manage_bar            = Maybe BusinessBotManageBar
business_bot_manage_bar_
          , video_chat :: Maybe VideoChat
video_chat                         = Maybe VideoChat
video_chat_
          , pending_join_requests :: Maybe ChatJoinRequestsInfo
pending_join_requests              = Maybe ChatJoinRequestsInfo
pending_join_requests_
          , reply_markup_message_id :: Maybe Int
reply_markup_message_id            = Maybe Int
reply_markup_message_id_
          , draft_message :: Maybe DraftMessage
draft_message                      = Maybe DraftMessage
draft_message_
          , client_data :: Maybe Text
client_data                        = Maybe Text
client_data_
          }
  parseJSON Value
_ = Parser Chat
forall a. Monoid a => a
mempty