module TD.Data.ChatInviteLinkMember
( ChatInviteLinkMember(..)
, defaultChatInviteLinkMember
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ChatInviteLinkMember
= ChatInviteLinkMember
{ ChatInviteLinkMember -> Maybe Int
user_id :: Maybe Int
, ChatInviteLinkMember -> Maybe Int
joined_chat_date :: Maybe Int
, ChatInviteLinkMember -> Maybe Bool
via_chat_folder_invite_link :: Maybe Bool
, ChatInviteLinkMember -> Maybe Int
approver_user_id :: Maybe Int
}
deriving (ChatInviteLinkMember -> ChatInviteLinkMember -> Bool
(ChatInviteLinkMember -> ChatInviteLinkMember -> Bool)
-> (ChatInviteLinkMember -> ChatInviteLinkMember -> Bool)
-> Eq ChatInviteLinkMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatInviteLinkMember -> ChatInviteLinkMember -> Bool
== :: ChatInviteLinkMember -> ChatInviteLinkMember -> Bool
$c/= :: ChatInviteLinkMember -> ChatInviteLinkMember -> Bool
/= :: ChatInviteLinkMember -> ChatInviteLinkMember -> Bool
Eq, Int -> ChatInviteLinkMember -> ShowS
[ChatInviteLinkMember] -> ShowS
ChatInviteLinkMember -> String
(Int -> ChatInviteLinkMember -> ShowS)
-> (ChatInviteLinkMember -> String)
-> ([ChatInviteLinkMember] -> ShowS)
-> Show ChatInviteLinkMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatInviteLinkMember -> ShowS
showsPrec :: Int -> ChatInviteLinkMember -> ShowS
$cshow :: ChatInviteLinkMember -> String
show :: ChatInviteLinkMember -> String
$cshowList :: [ChatInviteLinkMember] -> ShowS
showList :: [ChatInviteLinkMember] -> ShowS
Show)
instance I.ShortShow ChatInviteLinkMember where
shortShow :: ChatInviteLinkMember -> String
shortShow ChatInviteLinkMember
{ user_id :: ChatInviteLinkMember -> Maybe Int
user_id = Maybe Int
user_id_
, joined_chat_date :: ChatInviteLinkMember -> Maybe Int
joined_chat_date = Maybe Int
joined_chat_date_
, via_chat_folder_invite_link :: ChatInviteLinkMember -> Maybe Bool
via_chat_folder_invite_link = Maybe Bool
via_chat_folder_invite_link_
, approver_user_id :: ChatInviteLinkMember -> Maybe Int
approver_user_id = Maybe Int
approver_user_id_
}
= String
"ChatInviteLinkMember"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
, String
"joined_chat_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
joined_chat_date_
, String
"via_chat_folder_invite_link" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
via_chat_folder_invite_link_
, String
"approver_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
approver_user_id_
]
instance AT.FromJSON ChatInviteLinkMember where
parseJSON :: Value -> Parser ChatInviteLinkMember
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
"chatInviteLinkMember" -> Value -> Parser ChatInviteLinkMember
parseChatInviteLinkMember Value
v
String
_ -> Parser ChatInviteLinkMember
forall a. Monoid a => a
mempty
where
parseChatInviteLinkMember :: A.Value -> AT.Parser ChatInviteLinkMember
parseChatInviteLinkMember :: Value -> Parser ChatInviteLinkMember
parseChatInviteLinkMember = String
-> (Object -> Parser ChatInviteLinkMember)
-> Value
-> Parser ChatInviteLinkMember
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatInviteLinkMember" ((Object -> Parser ChatInviteLinkMember)
-> Value -> Parser ChatInviteLinkMember)
-> (Object -> Parser ChatInviteLinkMember)
-> Value
-> Parser ChatInviteLinkMember
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_id"
Maybe Int
joined_chat_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"joined_chat_date"
Maybe Bool
via_chat_folder_invite_link_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"via_chat_folder_invite_link"
Maybe Int
approver_user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"approver_user_id"
ChatInviteLinkMember -> Parser ChatInviteLinkMember
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatInviteLinkMember -> Parser ChatInviteLinkMember)
-> ChatInviteLinkMember -> Parser ChatInviteLinkMember
forall a b. (a -> b) -> a -> b
$ ChatInviteLinkMember
{ user_id :: Maybe Int
user_id = Maybe Int
user_id_
, joined_chat_date :: Maybe Int
joined_chat_date = Maybe Int
joined_chat_date_
, via_chat_folder_invite_link :: Maybe Bool
via_chat_folder_invite_link = Maybe Bool
via_chat_folder_invite_link_
, approver_user_id :: Maybe Int
approver_user_id = Maybe Int
approver_user_id_
}
parseJSON Value
_ = Parser ChatInviteLinkMember
forall a. Monoid a => a
mempty
instance AT.ToJSON ChatInviteLinkMember where
toJSON :: ChatInviteLinkMember -> Value
toJSON ChatInviteLinkMember
{ user_id :: ChatInviteLinkMember -> Maybe Int
user_id = Maybe Int
user_id_
, joined_chat_date :: ChatInviteLinkMember -> Maybe Int
joined_chat_date = Maybe Int
joined_chat_date_
, via_chat_folder_invite_link :: ChatInviteLinkMember -> Maybe Bool
via_chat_folder_invite_link = Maybe Bool
via_chat_folder_invite_link_
, approver_user_id :: ChatInviteLinkMember -> Maybe Int
approver_user_id = Maybe Int
approver_user_id_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatInviteLinkMember"
, Key
"user_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
user_id_
, Key
"joined_chat_date" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
joined_chat_date_
, Key
"via_chat_folder_invite_link" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
via_chat_folder_invite_link_
, Key
"approver_user_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
approver_user_id_
]
defaultChatInviteLinkMember :: ChatInviteLinkMember
defaultChatInviteLinkMember :: ChatInviteLinkMember
defaultChatInviteLinkMember =
ChatInviteLinkMember
{ user_id :: Maybe Int
user_id = Maybe Int
forall a. Maybe a
Nothing
, joined_chat_date :: Maybe Int
joined_chat_date = Maybe Int
forall a. Maybe a
Nothing
, via_chat_folder_invite_link :: Maybe Bool
via_chat_folder_invite_link = Maybe Bool
forall a. Maybe a
Nothing
, approver_user_id :: Maybe Int
approver_user_id = Maybe Int
forall a. Maybe a
Nothing
}