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