module TD.Data.CreatedBasicGroupChat
(CreatedBasicGroupChat(..)) 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.FailedToAddMembers as FailedToAddMembers
data CreatedBasicGroupChat
= CreatedBasicGroupChat
{ CreatedBasicGroupChat -> Maybe Int
chat_id :: Maybe Int
, CreatedBasicGroupChat -> Maybe FailedToAddMembers
failed_to_add_members :: Maybe FailedToAddMembers.FailedToAddMembers
}
deriving (CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool
(CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool)
-> (CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool)
-> Eq CreatedBasicGroupChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool
== :: CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool
$c/= :: CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool
/= :: CreatedBasicGroupChat -> CreatedBasicGroupChat -> Bool
Eq, Int -> CreatedBasicGroupChat -> ShowS
[CreatedBasicGroupChat] -> ShowS
CreatedBasicGroupChat -> String
(Int -> CreatedBasicGroupChat -> ShowS)
-> (CreatedBasicGroupChat -> String)
-> ([CreatedBasicGroupChat] -> ShowS)
-> Show CreatedBasicGroupChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreatedBasicGroupChat -> ShowS
showsPrec :: Int -> CreatedBasicGroupChat -> ShowS
$cshow :: CreatedBasicGroupChat -> String
show :: CreatedBasicGroupChat -> String
$cshowList :: [CreatedBasicGroupChat] -> ShowS
showList :: [CreatedBasicGroupChat] -> ShowS
Show)
instance I.ShortShow CreatedBasicGroupChat where
shortShow :: CreatedBasicGroupChat -> String
shortShow CreatedBasicGroupChat
{ chat_id :: CreatedBasicGroupChat -> Maybe Int
chat_id = Maybe Int
chat_id_
, failed_to_add_members :: CreatedBasicGroupChat -> Maybe FailedToAddMembers
failed_to_add_members = Maybe FailedToAddMembers
failed_to_add_members_
}
= String
"CreatedBasicGroupChat"
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
"failed_to_add_members" String -> Maybe FailedToAddMembers -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FailedToAddMembers
failed_to_add_members_
]
instance AT.FromJSON CreatedBasicGroupChat where
parseJSON :: Value -> Parser CreatedBasicGroupChat
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
"createdBasicGroupChat" -> Value -> Parser CreatedBasicGroupChat
parseCreatedBasicGroupChat Value
v
String
_ -> Parser CreatedBasicGroupChat
forall a. Monoid a => a
mempty
where
parseCreatedBasicGroupChat :: A.Value -> AT.Parser CreatedBasicGroupChat
parseCreatedBasicGroupChat :: Value -> Parser CreatedBasicGroupChat
parseCreatedBasicGroupChat = String
-> (Object -> Parser CreatedBasicGroupChat)
-> Value
-> Parser CreatedBasicGroupChat
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CreatedBasicGroupChat" ((Object -> Parser CreatedBasicGroupChat)
-> Value -> Parser CreatedBasicGroupChat)
-> (Object -> Parser CreatedBasicGroupChat)
-> Value
-> Parser CreatedBasicGroupChat
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 FailedToAddMembers
failed_to_add_members_ <- Object
o Object -> Key -> Parser (Maybe FailedToAddMembers)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"failed_to_add_members"
CreatedBasicGroupChat -> Parser CreatedBasicGroupChat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CreatedBasicGroupChat -> Parser CreatedBasicGroupChat)
-> CreatedBasicGroupChat -> Parser CreatedBasicGroupChat
forall a b. (a -> b) -> a -> b
$ CreatedBasicGroupChat
{ chat_id :: Maybe Int
chat_id = Maybe Int
chat_id_
, failed_to_add_members :: Maybe FailedToAddMembers
failed_to_add_members = Maybe FailedToAddMembers
failed_to_add_members_
}
parseJSON Value
_ = Parser CreatedBasicGroupChat
forall a. Monoid a => a
mempty