module TD.Data.ChatBoostLinkInfo
(ChatBoostLinkInfo(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ChatBoostLinkInfo
= ChatBoostLinkInfo
{ ChatBoostLinkInfo -> Maybe Bool
is_public :: Maybe Bool
, ChatBoostLinkInfo -> Maybe Int
chat_id :: Maybe Int
}
deriving (ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool
(ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool)
-> (ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool)
-> Eq ChatBoostLinkInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool
== :: ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool
$c/= :: ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool
/= :: ChatBoostLinkInfo -> ChatBoostLinkInfo -> Bool
Eq, Int -> ChatBoostLinkInfo -> ShowS
[ChatBoostLinkInfo] -> ShowS
ChatBoostLinkInfo -> String
(Int -> ChatBoostLinkInfo -> ShowS)
-> (ChatBoostLinkInfo -> String)
-> ([ChatBoostLinkInfo] -> ShowS)
-> Show ChatBoostLinkInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatBoostLinkInfo -> ShowS
showsPrec :: Int -> ChatBoostLinkInfo -> ShowS
$cshow :: ChatBoostLinkInfo -> String
show :: ChatBoostLinkInfo -> String
$cshowList :: [ChatBoostLinkInfo] -> ShowS
showList :: [ChatBoostLinkInfo] -> ShowS
Show)
instance I.ShortShow ChatBoostLinkInfo where
shortShow :: ChatBoostLinkInfo -> String
shortShow ChatBoostLinkInfo
{ is_public :: ChatBoostLinkInfo -> Maybe Bool
is_public = Maybe Bool
is_public_
, chat_id :: ChatBoostLinkInfo -> Maybe Int
chat_id = Maybe Int
chat_id_
}
= String
"ChatBoostLinkInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"is_public" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_public_
, String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
]
instance AT.FromJSON ChatBoostLinkInfo where
parseJSON :: Value -> Parser ChatBoostLinkInfo
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
"chatBoostLinkInfo" -> Value -> Parser ChatBoostLinkInfo
parseChatBoostLinkInfo Value
v
String
_ -> Parser ChatBoostLinkInfo
forall a. Monoid a => a
mempty
where
parseChatBoostLinkInfo :: A.Value -> AT.Parser ChatBoostLinkInfo
parseChatBoostLinkInfo :: Value -> Parser ChatBoostLinkInfo
parseChatBoostLinkInfo = String
-> (Object -> Parser ChatBoostLinkInfo)
-> Value
-> Parser ChatBoostLinkInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatBoostLinkInfo" ((Object -> Parser ChatBoostLinkInfo)
-> Value -> Parser ChatBoostLinkInfo)
-> (Object -> Parser ChatBoostLinkInfo)
-> Value
-> Parser ChatBoostLinkInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
is_public_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_public"
Maybe Int
chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_id"
ChatBoostLinkInfo -> Parser ChatBoostLinkInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatBoostLinkInfo -> Parser ChatBoostLinkInfo)
-> ChatBoostLinkInfo -> Parser ChatBoostLinkInfo
forall a b. (a -> b) -> a -> b
$ ChatBoostLinkInfo
{ is_public :: Maybe Bool
is_public = Maybe Bool
is_public_
, chat_id :: Maybe Int
chat_id = Maybe Int
chat_id_
}
parseJSON Value
_ = Parser ChatBoostLinkInfo
forall a. Monoid a => a
mempty