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