module TD.Data.ChatInviteLinkInfo
(ChatInviteLinkInfo(..)) 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.InviteLinkChatType as InviteLinkChatType
import qualified Data.Text as T
import qualified TD.Data.ChatPhotoInfo as ChatPhotoInfo
import qualified TD.Data.ChatInviteLinkSubscriptionInfo as ChatInviteLinkSubscriptionInfo
import qualified TD.Data.VerificationStatus as VerificationStatus
data ChatInviteLinkInfo
= ChatInviteLinkInfo
{ ChatInviteLinkInfo -> Maybe Int
chat_id :: Maybe Int
, ChatInviteLinkInfo -> Maybe Int
accessible_for :: Maybe Int
, ChatInviteLinkInfo -> Maybe InviteLinkChatType
_type :: Maybe InviteLinkChatType.InviteLinkChatType
, ChatInviteLinkInfo -> Maybe Text
title :: Maybe T.Text
, ChatInviteLinkInfo -> Maybe ChatPhotoInfo
photo :: Maybe ChatPhotoInfo.ChatPhotoInfo
, ChatInviteLinkInfo -> Maybe Int
accent_color_id :: Maybe Int
, ChatInviteLinkInfo -> Maybe Text
description :: Maybe T.Text
, ChatInviteLinkInfo -> Maybe Int
member_count :: Maybe Int
, ChatInviteLinkInfo -> Maybe [Int]
member_user_ids :: Maybe [Int]
, ChatInviteLinkInfo -> Maybe ChatInviteLinkSubscriptionInfo
subscription_info :: Maybe ChatInviteLinkSubscriptionInfo.ChatInviteLinkSubscriptionInfo
, ChatInviteLinkInfo -> Maybe Bool
creates_join_request :: Maybe Bool
, ChatInviteLinkInfo -> Maybe Bool
is_public :: Maybe Bool
, ChatInviteLinkInfo -> Maybe VerificationStatus
verification_status :: Maybe VerificationStatus.VerificationStatus
}
deriving (ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
(ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool)
-> (ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool)
-> Eq ChatInviteLinkInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
== :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
$c/= :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
/= :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
Eq, Int -> ChatInviteLinkInfo -> ShowS
[ChatInviteLinkInfo] -> ShowS
ChatInviteLinkInfo -> String
(Int -> ChatInviteLinkInfo -> ShowS)
-> (ChatInviteLinkInfo -> String)
-> ([ChatInviteLinkInfo] -> ShowS)
-> Show ChatInviteLinkInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatInviteLinkInfo -> ShowS
showsPrec :: Int -> ChatInviteLinkInfo -> ShowS
$cshow :: ChatInviteLinkInfo -> String
show :: ChatInviteLinkInfo -> String
$cshowList :: [ChatInviteLinkInfo] -> ShowS
showList :: [ChatInviteLinkInfo] -> ShowS
Show)
instance I.ShortShow ChatInviteLinkInfo where
shortShow :: ChatInviteLinkInfo -> String
shortShow ChatInviteLinkInfo
{ chat_id :: ChatInviteLinkInfo -> Maybe Int
chat_id = Maybe Int
chat_id_
, accessible_for :: ChatInviteLinkInfo -> Maybe Int
accessible_for = Maybe Int
accessible_for_
, _type :: ChatInviteLinkInfo -> Maybe InviteLinkChatType
_type = Maybe InviteLinkChatType
_type_
, title :: ChatInviteLinkInfo -> Maybe Text
title = Maybe Text
title_
, photo :: ChatInviteLinkInfo -> Maybe ChatPhotoInfo
photo = Maybe ChatPhotoInfo
photo_
, accent_color_id :: ChatInviteLinkInfo -> Maybe Int
accent_color_id = Maybe Int
accent_color_id_
, description :: ChatInviteLinkInfo -> Maybe Text
description = Maybe Text
description_
, member_count :: ChatInviteLinkInfo -> Maybe Int
member_count = Maybe Int
member_count_
, member_user_ids :: ChatInviteLinkInfo -> Maybe [Int]
member_user_ids = Maybe [Int]
member_user_ids_
, subscription_info :: ChatInviteLinkInfo -> Maybe ChatInviteLinkSubscriptionInfo
subscription_info = Maybe ChatInviteLinkSubscriptionInfo
subscription_info_
, creates_join_request :: ChatInviteLinkInfo -> Maybe Bool
creates_join_request = Maybe Bool
creates_join_request_
, is_public :: ChatInviteLinkInfo -> Maybe Bool
is_public = Maybe Bool
is_public_
, verification_status :: ChatInviteLinkInfo -> Maybe VerificationStatus
verification_status = Maybe VerificationStatus
verification_status_
}
= String
"ChatInviteLinkInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
, String
"accessible_for" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
accessible_for_
, String
"_type" String -> Maybe InviteLinkChatType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InviteLinkChatType
_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
"description" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
description_
, String
"member_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
member_count_
, String
"member_user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
member_user_ids_
, String
"subscription_info" String -> Maybe ChatInviteLinkSubscriptionInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatInviteLinkSubscriptionInfo
subscription_info_
, String
"creates_join_request" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
creates_join_request_
, String
"is_public" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_public_
, String
"verification_status" String -> Maybe VerificationStatus -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe VerificationStatus
verification_status_
]
instance AT.FromJSON ChatInviteLinkInfo where
parseJSON :: Value -> Parser ChatInviteLinkInfo
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
"chatInviteLinkInfo" -> Value -> Parser ChatInviteLinkInfo
parseChatInviteLinkInfo Value
v
String
_ -> Parser ChatInviteLinkInfo
forall a. Monoid a => a
mempty
where
parseChatInviteLinkInfo :: A.Value -> AT.Parser ChatInviteLinkInfo
parseChatInviteLinkInfo :: Value -> Parser ChatInviteLinkInfo
parseChatInviteLinkInfo = String
-> (Object -> Parser ChatInviteLinkInfo)
-> Value
-> Parser ChatInviteLinkInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatInviteLinkInfo" ((Object -> Parser ChatInviteLinkInfo)
-> Value -> Parser ChatInviteLinkInfo)
-> (Object -> Parser ChatInviteLinkInfo)
-> Value
-> Parser ChatInviteLinkInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_id"
Maybe Int
accessible_for_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"accessible_for"
Maybe InviteLinkChatType
_type_ <- Object
o Object -> Key -> Parser (Maybe InviteLinkChatType)
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 Text
description_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"description"
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]
member_user_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"member_user_ids"
Maybe ChatInviteLinkSubscriptionInfo
subscription_info_ <- Object
o Object -> Key -> Parser (Maybe ChatInviteLinkSubscriptionInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"subscription_info"
Maybe Bool
creates_join_request_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"creates_join_request"
Maybe Bool
is_public_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_public"
Maybe VerificationStatus
verification_status_ <- Object
o Object -> Key -> Parser (Maybe VerificationStatus)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"verification_status"
ChatInviteLinkInfo -> Parser ChatInviteLinkInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatInviteLinkInfo -> Parser ChatInviteLinkInfo)
-> ChatInviteLinkInfo -> Parser ChatInviteLinkInfo
forall a b. (a -> b) -> a -> b
$ ChatInviteLinkInfo
{ chat_id :: Maybe Int
chat_id = Maybe Int
chat_id_
, accessible_for :: Maybe Int
accessible_for = Maybe Int
accessible_for_
, _type :: Maybe InviteLinkChatType
_type = Maybe InviteLinkChatType
_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_
, description :: Maybe Text
description = Maybe Text
description_
, member_count :: Maybe Int
member_count = Maybe Int
member_count_
, member_user_ids :: Maybe [Int]
member_user_ids = Maybe [Int]
member_user_ids_
, subscription_info :: Maybe ChatInviteLinkSubscriptionInfo
subscription_info = Maybe ChatInviteLinkSubscriptionInfo
subscription_info_
, creates_join_request :: Maybe Bool
creates_join_request = Maybe Bool
creates_join_request_
, is_public :: Maybe Bool
is_public = Maybe Bool
is_public_
, verification_status :: Maybe VerificationStatus
verification_status = Maybe VerificationStatus
verification_status_
}
parseJSON Value
_ = Parser ChatInviteLinkInfo
forall a. Monoid a => a
mempty