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