module TD.Data.ChatFolderInviteLink
(ChatFolderInviteLink(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
data ChatFolderInviteLink
= ChatFolderInviteLink
{ ChatFolderInviteLink -> Maybe Text
invite_link :: Maybe T.Text
, ChatFolderInviteLink -> Maybe Text
name :: Maybe T.Text
, ChatFolderInviteLink -> Maybe [Int]
chat_ids :: Maybe [Int]
}
deriving (ChatFolderInviteLink -> ChatFolderInviteLink -> Bool
(ChatFolderInviteLink -> ChatFolderInviteLink -> Bool)
-> (ChatFolderInviteLink -> ChatFolderInviteLink -> Bool)
-> Eq ChatFolderInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatFolderInviteLink -> ChatFolderInviteLink -> Bool
== :: ChatFolderInviteLink -> ChatFolderInviteLink -> Bool
$c/= :: ChatFolderInviteLink -> ChatFolderInviteLink -> Bool
/= :: ChatFolderInviteLink -> ChatFolderInviteLink -> Bool
Eq, Int -> ChatFolderInviteLink -> ShowS
[ChatFolderInviteLink] -> ShowS
ChatFolderInviteLink -> String
(Int -> ChatFolderInviteLink -> ShowS)
-> (ChatFolderInviteLink -> String)
-> ([ChatFolderInviteLink] -> ShowS)
-> Show ChatFolderInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatFolderInviteLink -> ShowS
showsPrec :: Int -> ChatFolderInviteLink -> ShowS
$cshow :: ChatFolderInviteLink -> String
show :: ChatFolderInviteLink -> String
$cshowList :: [ChatFolderInviteLink] -> ShowS
showList :: [ChatFolderInviteLink] -> ShowS
Show)
instance I.ShortShow ChatFolderInviteLink where
shortShow :: ChatFolderInviteLink -> String
shortShow ChatFolderInviteLink
{ invite_link :: ChatFolderInviteLink -> Maybe Text
invite_link = Maybe Text
invite_link_
, name :: ChatFolderInviteLink -> Maybe Text
name = Maybe Text
name_
, chat_ids :: ChatFolderInviteLink -> Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
= String
"ChatFolderInviteLink"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"invite_link" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
invite_link_
, String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
, String
"chat_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
chat_ids_
]
instance AT.FromJSON ChatFolderInviteLink where
parseJSON :: Value -> Parser ChatFolderInviteLink
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
"chatFolderInviteLink" -> Value -> Parser ChatFolderInviteLink
parseChatFolderInviteLink Value
v
String
_ -> Parser ChatFolderInviteLink
forall a. Monoid a => a
mempty
where
parseChatFolderInviteLink :: A.Value -> AT.Parser ChatFolderInviteLink
parseChatFolderInviteLink :: Value -> Parser ChatFolderInviteLink
parseChatFolderInviteLink = String
-> (Object -> Parser ChatFolderInviteLink)
-> Value
-> Parser ChatFolderInviteLink
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatFolderInviteLink" ((Object -> Parser ChatFolderInviteLink)
-> Value -> Parser ChatFolderInviteLink)
-> (Object -> Parser ChatFolderInviteLink)
-> Value
-> Parser ChatFolderInviteLink
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
invite_link_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"invite_link"
Maybe Text
name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"name"
Maybe [Int]
chat_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_ids"
ChatFolderInviteLink -> Parser ChatFolderInviteLink
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatFolderInviteLink -> Parser ChatFolderInviteLink)
-> ChatFolderInviteLink -> Parser ChatFolderInviteLink
forall a b. (a -> b) -> a -> b
$ ChatFolderInviteLink
{ invite_link :: Maybe Text
invite_link = Maybe Text
invite_link_
, name :: Maybe Text
name = Maybe Text
name_
, chat_ids :: Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
parseJSON Value
_ = Parser ChatFolderInviteLink
forall a. Monoid a => a
mempty