module TD.Data.CustomRequestResult
(CustomRequestResult(..)) 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 CustomRequestResult
= CustomRequestResult
{ CustomRequestResult -> Maybe Text
result :: Maybe T.Text
}
deriving (CustomRequestResult -> CustomRequestResult -> Bool
(CustomRequestResult -> CustomRequestResult -> Bool)
-> (CustomRequestResult -> CustomRequestResult -> Bool)
-> Eq CustomRequestResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CustomRequestResult -> CustomRequestResult -> Bool
== :: CustomRequestResult -> CustomRequestResult -> Bool
$c/= :: CustomRequestResult -> CustomRequestResult -> Bool
/= :: CustomRequestResult -> CustomRequestResult -> Bool
Eq, Int -> CustomRequestResult -> ShowS
[CustomRequestResult] -> ShowS
CustomRequestResult -> String
(Int -> CustomRequestResult -> ShowS)
-> (CustomRequestResult -> String)
-> ([CustomRequestResult] -> ShowS)
-> Show CustomRequestResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CustomRequestResult -> ShowS
showsPrec :: Int -> CustomRequestResult -> ShowS
$cshow :: CustomRequestResult -> String
show :: CustomRequestResult -> String
$cshowList :: [CustomRequestResult] -> ShowS
showList :: [CustomRequestResult] -> ShowS
Show)
instance I.ShortShow CustomRequestResult where
shortShow :: CustomRequestResult -> String
shortShow CustomRequestResult
{ result :: CustomRequestResult -> Maybe Text
result = Maybe Text
result_
}
= String
"CustomRequestResult"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"result" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
result_
]
instance AT.FromJSON CustomRequestResult where
parseJSON :: Value -> Parser CustomRequestResult
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
"customRequestResult" -> Value -> Parser CustomRequestResult
parseCustomRequestResult Value
v
String
_ -> Parser CustomRequestResult
forall a. Monoid a => a
mempty
where
parseCustomRequestResult :: A.Value -> AT.Parser CustomRequestResult
parseCustomRequestResult :: Value -> Parser CustomRequestResult
parseCustomRequestResult = String
-> (Object -> Parser CustomRequestResult)
-> Value
-> Parser CustomRequestResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CustomRequestResult" ((Object -> Parser CustomRequestResult)
-> Value -> Parser CustomRequestResult)
-> (Object -> Parser CustomRequestResult)
-> Value
-> Parser CustomRequestResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
result_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"result"
CustomRequestResult -> Parser CustomRequestResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CustomRequestResult -> Parser CustomRequestResult)
-> CustomRequestResult -> Parser CustomRequestResult
forall a b. (a -> b) -> a -> b
$ CustomRequestResult
{ result :: Maybe Text
result = Maybe Text
result_
}
parseJSON Value
_ = Parser CustomRequestResult
forall a. Monoid a => a
mempty