module TD.Data.ChatFolderInviteLinks
(ChatFolderInviteLinks(..)) 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.ChatFolderInviteLink as ChatFolderInviteLink
data ChatFolderInviteLinks
= ChatFolderInviteLinks
{ ChatFolderInviteLinks -> Maybe [ChatFolderInviteLink]
invite_links :: Maybe [ChatFolderInviteLink.ChatFolderInviteLink]
}
deriving (ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool
(ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool)
-> (ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool)
-> Eq ChatFolderInviteLinks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool
== :: ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool
$c/= :: ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool
/= :: ChatFolderInviteLinks -> ChatFolderInviteLinks -> Bool
Eq, Int -> ChatFolderInviteLinks -> ShowS
[ChatFolderInviteLinks] -> ShowS
ChatFolderInviteLinks -> String
(Int -> ChatFolderInviteLinks -> ShowS)
-> (ChatFolderInviteLinks -> String)
-> ([ChatFolderInviteLinks] -> ShowS)
-> Show ChatFolderInviteLinks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatFolderInviteLinks -> ShowS
showsPrec :: Int -> ChatFolderInviteLinks -> ShowS
$cshow :: ChatFolderInviteLinks -> String
show :: ChatFolderInviteLinks -> String
$cshowList :: [ChatFolderInviteLinks] -> ShowS
showList :: [ChatFolderInviteLinks] -> ShowS
Show)
instance I.ShortShow ChatFolderInviteLinks where
shortShow :: ChatFolderInviteLinks -> String
shortShow ChatFolderInviteLinks
{ invite_links :: ChatFolderInviteLinks -> Maybe [ChatFolderInviteLink]
invite_links = Maybe [ChatFolderInviteLink]
invite_links_
}
= String
"ChatFolderInviteLinks"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"invite_links" String -> Maybe [ChatFolderInviteLink] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatFolderInviteLink]
invite_links_
]
instance AT.FromJSON ChatFolderInviteLinks where
parseJSON :: Value -> Parser ChatFolderInviteLinks
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
"chatFolderInviteLinks" -> Value -> Parser ChatFolderInviteLinks
parseChatFolderInviteLinks Value
v
String
_ -> Parser ChatFolderInviteLinks
forall a. Monoid a => a
mempty
where
parseChatFolderInviteLinks :: A.Value -> AT.Parser ChatFolderInviteLinks
parseChatFolderInviteLinks :: Value -> Parser ChatFolderInviteLinks
parseChatFolderInviteLinks = String
-> (Object -> Parser ChatFolderInviteLinks)
-> Value
-> Parser ChatFolderInviteLinks
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatFolderInviteLinks" ((Object -> Parser ChatFolderInviteLinks)
-> Value -> Parser ChatFolderInviteLinks)
-> (Object -> Parser ChatFolderInviteLinks)
-> Value
-> Parser ChatFolderInviteLinks
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [ChatFolderInviteLink]
invite_links_ <- Object
o Object -> Key -> Parser (Maybe [ChatFolderInviteLink])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"invite_links"
ChatFolderInviteLinks -> Parser ChatFolderInviteLinks
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatFolderInviteLinks -> Parser ChatFolderInviteLinks)
-> ChatFolderInviteLinks -> Parser ChatFolderInviteLinks
forall a b. (a -> b) -> a -> b
$ ChatFolderInviteLinks
{ invite_links :: Maybe [ChatFolderInviteLink]
invite_links = Maybe [ChatFolderInviteLink]
invite_links_
}
parseJSON Value
_ = Parser ChatFolderInviteLinks
forall a. Monoid a => a
mempty