module TD.Data.ChatAdministrator
(ChatAdministrator(..)) 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 ChatAdministrator
= ChatAdministrator
{ ChatAdministrator -> Maybe Int
user_id :: Maybe Int
, ChatAdministrator -> Maybe Text
custom_title :: Maybe T.Text
, ChatAdministrator -> Maybe Bool
is_owner :: Maybe Bool
}
deriving (ChatAdministrator -> ChatAdministrator -> Bool
(ChatAdministrator -> ChatAdministrator -> Bool)
-> (ChatAdministrator -> ChatAdministrator -> Bool)
-> Eq ChatAdministrator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatAdministrator -> ChatAdministrator -> Bool
== :: ChatAdministrator -> ChatAdministrator -> Bool
$c/= :: ChatAdministrator -> ChatAdministrator -> Bool
/= :: ChatAdministrator -> ChatAdministrator -> Bool
Eq, Int -> ChatAdministrator -> ShowS
[ChatAdministrator] -> ShowS
ChatAdministrator -> String
(Int -> ChatAdministrator -> ShowS)
-> (ChatAdministrator -> String)
-> ([ChatAdministrator] -> ShowS)
-> Show ChatAdministrator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatAdministrator -> ShowS
showsPrec :: Int -> ChatAdministrator -> ShowS
$cshow :: ChatAdministrator -> String
show :: ChatAdministrator -> String
$cshowList :: [ChatAdministrator] -> ShowS
showList :: [ChatAdministrator] -> ShowS
Show)
instance I.ShortShow ChatAdministrator where
shortShow :: ChatAdministrator -> String
shortShow ChatAdministrator
{ user_id :: ChatAdministrator -> Maybe Int
user_id = Maybe Int
user_id_
, custom_title :: ChatAdministrator -> Maybe Text
custom_title = Maybe Text
custom_title_
, is_owner :: ChatAdministrator -> Maybe Bool
is_owner = Maybe Bool
is_owner_
}
= String
"ChatAdministrator"
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
"custom_title" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
custom_title_
, String
"is_owner" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_owner_
]
instance AT.FromJSON ChatAdministrator where
parseJSON :: Value -> Parser ChatAdministrator
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
"chatAdministrator" -> Value -> Parser ChatAdministrator
parseChatAdministrator Value
v
String
_ -> Parser ChatAdministrator
forall a. Monoid a => a
mempty
where
parseChatAdministrator :: A.Value -> AT.Parser ChatAdministrator
parseChatAdministrator :: Value -> Parser ChatAdministrator
parseChatAdministrator = String
-> (Object -> Parser ChatAdministrator)
-> Value
-> Parser ChatAdministrator
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatAdministrator" ((Object -> Parser ChatAdministrator)
-> Value -> Parser ChatAdministrator)
-> (Object -> Parser ChatAdministrator)
-> Value
-> Parser ChatAdministrator
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 Text
custom_title_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"custom_title"
Maybe Bool
is_owner_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_owner"
ChatAdministrator -> Parser ChatAdministrator
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatAdministrator -> Parser ChatAdministrator)
-> ChatAdministrator -> Parser ChatAdministrator
forall a b. (a -> b) -> a -> b
$ ChatAdministrator
{ user_id :: Maybe Int
user_id = Maybe Int
user_id_
, custom_title :: Maybe Text
custom_title = Maybe Text
custom_title_
, is_owner :: Maybe Bool
is_owner = Maybe Bool
is_owner_
}
parseJSON Value
_ = Parser ChatAdministrator
forall a. Monoid a => a
mempty