module TD.Data.BotVerificationParameters
(BotVerificationParameters(..)) 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
import qualified TD.Data.FormattedText as FormattedText
data BotVerificationParameters
= BotVerificationParameters
{ BotVerificationParameters -> Maybe Int
icon_custom_emoji_id :: Maybe Int
, BotVerificationParameters -> Maybe Text
organization_name :: Maybe T.Text
, BotVerificationParameters -> Maybe FormattedText
default_custom_description :: Maybe FormattedText.FormattedText
, BotVerificationParameters -> Maybe Bool
can_set_custom_description :: Maybe Bool
}
deriving (BotVerificationParameters -> BotVerificationParameters -> Bool
(BotVerificationParameters -> BotVerificationParameters -> Bool)
-> (BotVerificationParameters -> BotVerificationParameters -> Bool)
-> Eq BotVerificationParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotVerificationParameters -> BotVerificationParameters -> Bool
== :: BotVerificationParameters -> BotVerificationParameters -> Bool
$c/= :: BotVerificationParameters -> BotVerificationParameters -> Bool
/= :: BotVerificationParameters -> BotVerificationParameters -> Bool
Eq, Int -> BotVerificationParameters -> ShowS
[BotVerificationParameters] -> ShowS
BotVerificationParameters -> String
(Int -> BotVerificationParameters -> ShowS)
-> (BotVerificationParameters -> String)
-> ([BotVerificationParameters] -> ShowS)
-> Show BotVerificationParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BotVerificationParameters -> ShowS
showsPrec :: Int -> BotVerificationParameters -> ShowS
$cshow :: BotVerificationParameters -> String
show :: BotVerificationParameters -> String
$cshowList :: [BotVerificationParameters] -> ShowS
showList :: [BotVerificationParameters] -> ShowS
Show)
instance I.ShortShow BotVerificationParameters where
shortShow :: BotVerificationParameters -> String
shortShow BotVerificationParameters
{ icon_custom_emoji_id :: BotVerificationParameters -> Maybe Int
icon_custom_emoji_id = Maybe Int
icon_custom_emoji_id_
, organization_name :: BotVerificationParameters -> Maybe Text
organization_name = Maybe Text
organization_name_
, default_custom_description :: BotVerificationParameters -> Maybe FormattedText
default_custom_description = Maybe FormattedText
default_custom_description_
, can_set_custom_description :: BotVerificationParameters -> Maybe Bool
can_set_custom_description = Maybe Bool
can_set_custom_description_
}
= String
"BotVerificationParameters"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"icon_custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
icon_custom_emoji_id_
, String
"organization_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
organization_name_
, String
"default_custom_description" String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
default_custom_description_
, String
"can_set_custom_description" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_set_custom_description_
]
instance AT.FromJSON BotVerificationParameters where
parseJSON :: Value -> Parser BotVerificationParameters
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
"botVerificationParameters" -> Value -> Parser BotVerificationParameters
parseBotVerificationParameters Value
v
String
_ -> Parser BotVerificationParameters
forall a. Monoid a => a
mempty
where
parseBotVerificationParameters :: A.Value -> AT.Parser BotVerificationParameters
parseBotVerificationParameters :: Value -> Parser BotVerificationParameters
parseBotVerificationParameters = String
-> (Object -> Parser BotVerificationParameters)
-> Value
-> Parser BotVerificationParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotVerificationParameters" ((Object -> Parser BotVerificationParameters)
-> Value -> Parser BotVerificationParameters)
-> (Object -> Parser BotVerificationParameters)
-> Value
-> Parser BotVerificationParameters
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
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
"icon_custom_emoji_id"
Maybe Text
organization_name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"organization_name"
Maybe FormattedText
default_custom_description_ <- Object
o Object -> Key -> Parser (Maybe FormattedText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"default_custom_description"
Maybe Bool
can_set_custom_description_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_set_custom_description"
BotVerificationParameters -> Parser BotVerificationParameters
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotVerificationParameters -> Parser BotVerificationParameters)
-> BotVerificationParameters -> Parser BotVerificationParameters
forall a b. (a -> b) -> a -> b
$ BotVerificationParameters
{ icon_custom_emoji_id :: Maybe Int
icon_custom_emoji_id = Maybe Int
icon_custom_emoji_id_
, organization_name :: Maybe Text
organization_name = Maybe Text
organization_name_
, default_custom_description :: Maybe FormattedText
default_custom_description = Maybe FormattedText
default_custom_description_
, can_set_custom_description :: Maybe Bool
can_set_custom_description = Maybe Bool
can_set_custom_description_
}
parseJSON Value
_ = Parser BotVerificationParameters
forall a. Monoid a => a
mempty