module TD.Data.CommunityAddChatRequests
(CommunityAddChatRequests(..)) 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.CommunityAddChatRequest as CommunityAddChatRequest
import qualified Data.Text as T
data
=
{ CommunityAddChatRequests -> Maybe Int
total_count :: Maybe Int
, CommunityAddChatRequests -> Maybe [CommunityAddChatRequest]
requests :: Maybe [CommunityAddChatRequest.CommunityAddChatRequest]
, CommunityAddChatRequests -> Maybe Text
next_offset :: Maybe T.Text
}
deriving (CommunityAddChatRequests -> CommunityAddChatRequests -> Bool
(CommunityAddChatRequests -> CommunityAddChatRequests -> Bool)
-> (CommunityAddChatRequests -> CommunityAddChatRequests -> Bool)
-> Eq CommunityAddChatRequests
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommunityAddChatRequests -> CommunityAddChatRequests -> Bool
== :: CommunityAddChatRequests -> CommunityAddChatRequests -> Bool
$c/= :: CommunityAddChatRequests -> CommunityAddChatRequests -> Bool
/= :: CommunityAddChatRequests -> CommunityAddChatRequests -> Bool
Eq, Int -> CommunityAddChatRequests -> ShowS
[CommunityAddChatRequests] -> ShowS
CommunityAddChatRequests -> String
(Int -> CommunityAddChatRequests -> ShowS)
-> (CommunityAddChatRequests -> String)
-> ([CommunityAddChatRequests] -> ShowS)
-> Show CommunityAddChatRequests
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommunityAddChatRequests -> ShowS
showsPrec :: Int -> CommunityAddChatRequests -> ShowS
$cshow :: CommunityAddChatRequests -> String
show :: CommunityAddChatRequests -> String
$cshowList :: [CommunityAddChatRequests] -> ShowS
showList :: [CommunityAddChatRequests] -> ShowS
Show)
instance I.ShortShow CommunityAddChatRequests where
shortShow :: CommunityAddChatRequests -> String
shortShow CommunityAddChatRequests
{ total_count :: CommunityAddChatRequests -> Maybe Int
total_count = Maybe Int
total_count_
, requests :: CommunityAddChatRequests -> Maybe [CommunityAddChatRequest]
requests = Maybe [CommunityAddChatRequest]
requests_
, next_offset :: CommunityAddChatRequests -> Maybe Text
next_offset = Maybe Text
next_offset_
}
= String
"CommunityAddChatRequests"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"total_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
total_count_
, String
"requests" String -> Maybe [CommunityAddChatRequest] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [CommunityAddChatRequest]
requests_
, String
"next_offset" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
next_offset_
]
instance AT.FromJSON CommunityAddChatRequests where
parseJSON :: Value -> Parser CommunityAddChatRequests
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
"communityAddChatRequests" -> Value -> Parser CommunityAddChatRequests
parseCommunityAddChatRequests Value
v
String
_ -> Parser CommunityAddChatRequests
forall a. Monoid a => a
mempty
where
parseCommunityAddChatRequests :: A.Value -> AT.Parser CommunityAddChatRequests
parseCommunityAddChatRequests :: Value -> Parser CommunityAddChatRequests
parseCommunityAddChatRequests = String
-> (Object -> Parser CommunityAddChatRequests)
-> Value
-> Parser CommunityAddChatRequests
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CommunityAddChatRequests" ((Object -> Parser CommunityAddChatRequests)
-> Value -> Parser CommunityAddChatRequests)
-> (Object -> Parser CommunityAddChatRequests)
-> Value
-> Parser CommunityAddChatRequests
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
total_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"total_count"
Maybe [CommunityAddChatRequest]
requests_ <- Object
o Object -> Key -> Parser (Maybe [CommunityAddChatRequest])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"requests"
Maybe Text
next_offset_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_offset"
CommunityAddChatRequests -> Parser CommunityAddChatRequests
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CommunityAddChatRequests -> Parser CommunityAddChatRequests)
-> CommunityAddChatRequests -> Parser CommunityAddChatRequests
forall a b. (a -> b) -> a -> b
$ CommunityAddChatRequests
{ total_count :: Maybe Int
total_count = Maybe Int
total_count_
, requests :: Maybe [CommunityAddChatRequest]
requests = Maybe [CommunityAddChatRequest]
requests_
, next_offset :: Maybe Text
next_offset = Maybe Text
next_offset_
}
parseJSON Value
_ = Parser CommunityAddChatRequests
forall a. Monoid a => a
mempty