module TD.Data.VerificationStatus
(VerificationStatus(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data VerificationStatus
= VerificationStatus
{ VerificationStatus -> Maybe Bool
is_verified :: Maybe Bool
, VerificationStatus -> Maybe Bool
is_scam :: Maybe Bool
, VerificationStatus -> Maybe Bool
is_fake :: Maybe Bool
, VerificationStatus -> Maybe Int
bot_verification_icon_custom_emoji_id :: Maybe Int
}
deriving (VerificationStatus -> VerificationStatus -> Bool
(VerificationStatus -> VerificationStatus -> Bool)
-> (VerificationStatus -> VerificationStatus -> Bool)
-> Eq VerificationStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerificationStatus -> VerificationStatus -> Bool
== :: VerificationStatus -> VerificationStatus -> Bool
$c/= :: VerificationStatus -> VerificationStatus -> Bool
/= :: VerificationStatus -> VerificationStatus -> Bool
Eq, Int -> VerificationStatus -> ShowS
[VerificationStatus] -> ShowS
VerificationStatus -> String
(Int -> VerificationStatus -> ShowS)
-> (VerificationStatus -> String)
-> ([VerificationStatus] -> ShowS)
-> Show VerificationStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerificationStatus -> ShowS
showsPrec :: Int -> VerificationStatus -> ShowS
$cshow :: VerificationStatus -> String
show :: VerificationStatus -> String
$cshowList :: [VerificationStatus] -> ShowS
showList :: [VerificationStatus] -> ShowS
Show)
instance I.ShortShow VerificationStatus where
shortShow :: VerificationStatus -> String
shortShow VerificationStatus
{ is_verified :: VerificationStatus -> Maybe Bool
is_verified = Maybe Bool
is_verified_
, is_scam :: VerificationStatus -> Maybe Bool
is_scam = Maybe Bool
is_scam_
, is_fake :: VerificationStatus -> Maybe Bool
is_fake = Maybe Bool
is_fake_
, bot_verification_icon_custom_emoji_id :: VerificationStatus -> Maybe Int
bot_verification_icon_custom_emoji_id = Maybe Int
bot_verification_icon_custom_emoji_id_
}
= String
"VerificationStatus"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"is_verified" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_verified_
, String
"is_scam" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_scam_
, String
"is_fake" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_fake_
, String
"bot_verification_icon_custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_verification_icon_custom_emoji_id_
]
instance AT.FromJSON VerificationStatus where
parseJSON :: Value -> Parser VerificationStatus
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
"verificationStatus" -> Value -> Parser VerificationStatus
parseVerificationStatus Value
v
String
_ -> Parser VerificationStatus
forall a. Monoid a => a
mempty
where
parseVerificationStatus :: A.Value -> AT.Parser VerificationStatus
parseVerificationStatus :: Value -> Parser VerificationStatus
parseVerificationStatus = String
-> (Object -> Parser VerificationStatus)
-> Value
-> Parser VerificationStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"VerificationStatus" ((Object -> Parser VerificationStatus)
-> Value -> Parser VerificationStatus)
-> (Object -> Parser VerificationStatus)
-> Value
-> Parser VerificationStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
is_verified_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_verified"
Maybe Bool
is_scam_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_scam"
Maybe Bool
is_fake_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_fake"
Maybe Int
bot_verification_icon_custom_emoji_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"bot_verification_icon_custom_emoji_id"
VerificationStatus -> Parser VerificationStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VerificationStatus -> Parser VerificationStatus)
-> VerificationStatus -> Parser VerificationStatus
forall a b. (a -> b) -> a -> b
$ VerificationStatus
{ is_verified :: Maybe Bool
is_verified = Maybe Bool
is_verified_
, is_scam :: Maybe Bool
is_scam = Maybe Bool
is_scam_
, is_fake :: Maybe Bool
is_fake = Maybe Bool
is_fake_
, bot_verification_icon_custom_emoji_id :: Maybe Int
bot_verification_icon_custom_emoji_id = Maybe Int
bot_verification_icon_custom_emoji_id_
}
parseJSON Value
_ = Parser VerificationStatus
forall a. Monoid a => a
mempty