module TD.Data.FailedToAddMember
(FailedToAddMember(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data FailedToAddMember
= FailedToAddMember
{ FailedToAddMember -> Maybe Int
user_id :: Maybe Int
, FailedToAddMember -> Maybe Bool
premium_would_allow_invite :: Maybe Bool
, FailedToAddMember -> Maybe Bool
premium_required_to_send_messages :: Maybe Bool
}
deriving (FailedToAddMember -> FailedToAddMember -> Bool
(FailedToAddMember -> FailedToAddMember -> Bool)
-> (FailedToAddMember -> FailedToAddMember -> Bool)
-> Eq FailedToAddMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FailedToAddMember -> FailedToAddMember -> Bool
== :: FailedToAddMember -> FailedToAddMember -> Bool
$c/= :: FailedToAddMember -> FailedToAddMember -> Bool
/= :: FailedToAddMember -> FailedToAddMember -> Bool
Eq, Int -> FailedToAddMember -> ShowS
[FailedToAddMember] -> ShowS
FailedToAddMember -> String
(Int -> FailedToAddMember -> ShowS)
-> (FailedToAddMember -> String)
-> ([FailedToAddMember] -> ShowS)
-> Show FailedToAddMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FailedToAddMember -> ShowS
showsPrec :: Int -> FailedToAddMember -> ShowS
$cshow :: FailedToAddMember -> String
show :: FailedToAddMember -> String
$cshowList :: [FailedToAddMember] -> ShowS
showList :: [FailedToAddMember] -> ShowS
Show)
instance I.ShortShow FailedToAddMember where
shortShow :: FailedToAddMember -> String
shortShow FailedToAddMember
{ user_id :: FailedToAddMember -> Maybe Int
user_id = Maybe Int
user_id_
, premium_would_allow_invite :: FailedToAddMember -> Maybe Bool
premium_would_allow_invite = Maybe Bool
premium_would_allow_invite_
, premium_required_to_send_messages :: FailedToAddMember -> Maybe Bool
premium_required_to_send_messages = Maybe Bool
premium_required_to_send_messages_
}
= String
"FailedToAddMember"
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
"premium_would_allow_invite" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
premium_would_allow_invite_
, String
"premium_required_to_send_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
premium_required_to_send_messages_
]
instance AT.FromJSON FailedToAddMember where
parseJSON :: Value -> Parser FailedToAddMember
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
"failedToAddMember" -> Value -> Parser FailedToAddMember
parseFailedToAddMember Value
v
String
_ -> Parser FailedToAddMember
forall a. Monoid a => a
mempty
where
parseFailedToAddMember :: A.Value -> AT.Parser FailedToAddMember
parseFailedToAddMember :: Value -> Parser FailedToAddMember
parseFailedToAddMember = String
-> (Object -> Parser FailedToAddMember)
-> Value
-> Parser FailedToAddMember
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"FailedToAddMember" ((Object -> Parser FailedToAddMember)
-> Value -> Parser FailedToAddMember)
-> (Object -> Parser FailedToAddMember)
-> Value
-> Parser FailedToAddMember
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 Bool
premium_would_allow_invite_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"premium_would_allow_invite"
Maybe Bool
premium_required_to_send_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"premium_required_to_send_messages"
FailedToAddMember -> Parser FailedToAddMember
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FailedToAddMember -> Parser FailedToAddMember)
-> FailedToAddMember -> Parser FailedToAddMember
forall a b. (a -> b) -> a -> b
$ FailedToAddMember
{ user_id :: Maybe Int
user_id = Maybe Int
user_id_
, premium_would_allow_invite :: Maybe Bool
premium_would_allow_invite = Maybe Bool
premium_would_allow_invite_
, premium_required_to_send_messages :: Maybe Bool
premium_required_to_send_messages = Maybe Bool
premium_required_to_send_messages_
}
parseJSON Value
_ = Parser FailedToAddMember
forall a. Monoid a => a
mempty