module TD.Data.LanguagePackInfo
( LanguagePackInfo(..)
, defaultLanguagePackInfo
) 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 LanguagePackInfo
= LanguagePackInfo
{ LanguagePackInfo -> Maybe Text
_id :: Maybe T.Text
, LanguagePackInfo -> Maybe Text
base_language_pack_id :: Maybe T.Text
, LanguagePackInfo -> Maybe Text
name :: Maybe T.Text
, LanguagePackInfo -> Maybe Text
native_name :: Maybe T.Text
, LanguagePackInfo -> Maybe Text
plural_code :: Maybe T.Text
, LanguagePackInfo -> Maybe Bool
is_official :: Maybe Bool
, LanguagePackInfo -> Maybe Bool
is_rtl :: Maybe Bool
, LanguagePackInfo -> Maybe Bool
is_beta :: Maybe Bool
, LanguagePackInfo -> Maybe Bool
is_installed :: Maybe Bool
, LanguagePackInfo -> Maybe Int
total_string_count :: Maybe Int
, LanguagePackInfo -> Maybe Int
translated_string_count :: Maybe Int
, LanguagePackInfo -> Maybe Int
local_string_count :: Maybe Int
, LanguagePackInfo -> Maybe Text
translation_url :: Maybe T.Text
}
deriving (LanguagePackInfo -> LanguagePackInfo -> Bool
(LanguagePackInfo -> LanguagePackInfo -> Bool)
-> (LanguagePackInfo -> LanguagePackInfo -> Bool)
-> Eq LanguagePackInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LanguagePackInfo -> LanguagePackInfo -> Bool
== :: LanguagePackInfo -> LanguagePackInfo -> Bool
$c/= :: LanguagePackInfo -> LanguagePackInfo -> Bool
/= :: LanguagePackInfo -> LanguagePackInfo -> Bool
Eq, Int -> LanguagePackInfo -> ShowS
[LanguagePackInfo] -> ShowS
LanguagePackInfo -> String
(Int -> LanguagePackInfo -> ShowS)
-> (LanguagePackInfo -> String)
-> ([LanguagePackInfo] -> ShowS)
-> Show LanguagePackInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LanguagePackInfo -> ShowS
showsPrec :: Int -> LanguagePackInfo -> ShowS
$cshow :: LanguagePackInfo -> String
show :: LanguagePackInfo -> String
$cshowList :: [LanguagePackInfo] -> ShowS
showList :: [LanguagePackInfo] -> ShowS
Show)
instance I.ShortShow LanguagePackInfo where
shortShow :: LanguagePackInfo -> String
shortShow LanguagePackInfo
{ _id :: LanguagePackInfo -> Maybe Text
_id = Maybe Text
_id_
, base_language_pack_id :: LanguagePackInfo -> Maybe Text
base_language_pack_id = Maybe Text
base_language_pack_id_
, name :: LanguagePackInfo -> Maybe Text
name = Maybe Text
name_
, native_name :: LanguagePackInfo -> Maybe Text
native_name = Maybe Text
native_name_
, plural_code :: LanguagePackInfo -> Maybe Text
plural_code = Maybe Text
plural_code_
, is_official :: LanguagePackInfo -> Maybe Bool
is_official = Maybe Bool
is_official_
, is_rtl :: LanguagePackInfo -> Maybe Bool
is_rtl = Maybe Bool
is_rtl_
, is_beta :: LanguagePackInfo -> Maybe Bool
is_beta = Maybe Bool
is_beta_
, is_installed :: LanguagePackInfo -> Maybe Bool
is_installed = Maybe Bool
is_installed_
, total_string_count :: LanguagePackInfo -> Maybe Int
total_string_count = Maybe Int
total_string_count_
, translated_string_count :: LanguagePackInfo -> Maybe Int
translated_string_count = Maybe Int
translated_string_count_
, local_string_count :: LanguagePackInfo -> Maybe Int
local_string_count = Maybe Int
local_string_count_
, translation_url :: LanguagePackInfo -> Maybe Text
translation_url = Maybe Text
translation_url_
}
= String
"LanguagePackInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
_id_
, String
"base_language_pack_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
base_language_pack_id_
, String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
, String
"native_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
native_name_
, String
"plural_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
plural_code_
, String
"is_official" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_official_
, String
"is_rtl" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_rtl_
, String
"is_beta" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_beta_
, String
"is_installed" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_installed_
, String
"total_string_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
total_string_count_
, String
"translated_string_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
translated_string_count_
, String
"local_string_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
local_string_count_
, String
"translation_url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
translation_url_
]
instance AT.FromJSON LanguagePackInfo where
parseJSON :: Value -> Parser LanguagePackInfo
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
"languagePackInfo" -> Value -> Parser LanguagePackInfo
parseLanguagePackInfo Value
v
String
_ -> Parser LanguagePackInfo
forall a. Monoid a => a
mempty
where
parseLanguagePackInfo :: A.Value -> AT.Parser LanguagePackInfo
parseLanguagePackInfo :: Value -> Parser LanguagePackInfo
parseLanguagePackInfo = String
-> (Object -> Parser LanguagePackInfo)
-> Value
-> Parser LanguagePackInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"LanguagePackInfo" ((Object -> Parser LanguagePackInfo)
-> Value -> Parser LanguagePackInfo)
-> (Object -> Parser LanguagePackInfo)
-> Value
-> Parser LanguagePackInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
_id_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe Text
base_language_pack_id_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"base_language_pack_id"
Maybe Text
name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"name"
Maybe Text
native_name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"native_name"
Maybe Text
plural_code_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"plural_code"
Maybe Bool
is_official_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_official"
Maybe Bool
is_rtl_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_rtl"
Maybe Bool
is_beta_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_beta"
Maybe Bool
is_installed_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_installed"
Maybe Int
total_string_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"total_string_count"
Maybe Int
translated_string_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"translated_string_count"
Maybe Int
local_string_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"local_string_count"
Maybe Text
translation_url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"translation_url"
LanguagePackInfo -> Parser LanguagePackInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (LanguagePackInfo -> Parser LanguagePackInfo)
-> LanguagePackInfo -> Parser LanguagePackInfo
forall a b. (a -> b) -> a -> b
$ LanguagePackInfo
{ _id :: Maybe Text
_id = Maybe Text
_id_
, base_language_pack_id :: Maybe Text
base_language_pack_id = Maybe Text
base_language_pack_id_
, name :: Maybe Text
name = Maybe Text
name_
, native_name :: Maybe Text
native_name = Maybe Text
native_name_
, plural_code :: Maybe Text
plural_code = Maybe Text
plural_code_
, is_official :: Maybe Bool
is_official = Maybe Bool
is_official_
, is_rtl :: Maybe Bool
is_rtl = Maybe Bool
is_rtl_
, is_beta :: Maybe Bool
is_beta = Maybe Bool
is_beta_
, is_installed :: Maybe Bool
is_installed = Maybe Bool
is_installed_
, total_string_count :: Maybe Int
total_string_count = Maybe Int
total_string_count_
, translated_string_count :: Maybe Int
translated_string_count = Maybe Int
translated_string_count_
, local_string_count :: Maybe Int
local_string_count = Maybe Int
local_string_count_
, translation_url :: Maybe Text
translation_url = Maybe Text
translation_url_
}
parseJSON Value
_ = Parser LanguagePackInfo
forall a. Monoid a => a
mempty
instance AT.ToJSON LanguagePackInfo where
toJSON :: LanguagePackInfo -> Value
toJSON LanguagePackInfo
{ _id :: LanguagePackInfo -> Maybe Text
_id = Maybe Text
_id_
, base_language_pack_id :: LanguagePackInfo -> Maybe Text
base_language_pack_id = Maybe Text
base_language_pack_id_
, name :: LanguagePackInfo -> Maybe Text
name = Maybe Text
name_
, native_name :: LanguagePackInfo -> Maybe Text
native_name = Maybe Text
native_name_
, plural_code :: LanguagePackInfo -> Maybe Text
plural_code = Maybe Text
plural_code_
, is_official :: LanguagePackInfo -> Maybe Bool
is_official = Maybe Bool
is_official_
, is_rtl :: LanguagePackInfo -> Maybe Bool
is_rtl = Maybe Bool
is_rtl_
, is_beta :: LanguagePackInfo -> Maybe Bool
is_beta = Maybe Bool
is_beta_
, is_installed :: LanguagePackInfo -> Maybe Bool
is_installed = Maybe Bool
is_installed_
, total_string_count :: LanguagePackInfo -> Maybe Int
total_string_count = Maybe Int
total_string_count_
, translated_string_count :: LanguagePackInfo -> Maybe Int
translated_string_count = Maybe Int
translated_string_count_
, local_string_count :: LanguagePackInfo -> Maybe Int
local_string_count = Maybe Int
local_string_count_
, translation_url :: LanguagePackInfo -> Maybe Text
translation_url = Maybe Text
translation_url_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"languagePackInfo"
, Key
"id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_id_
, Key
"base_language_pack_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
base_language_pack_id_
, Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
, Key
"native_name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
native_name_
, Key
"plural_code" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
plural_code_
, Key
"is_official" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_official_
, Key
"is_rtl" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_rtl_
, Key
"is_beta" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_beta_
, Key
"is_installed" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_installed_
, Key
"total_string_count" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
total_string_count_
, Key
"translated_string_count" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
translated_string_count_
, Key
"local_string_count" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
local_string_count_
, Key
"translation_url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
translation_url_
]
defaultLanguagePackInfo :: LanguagePackInfo
defaultLanguagePackInfo :: LanguagePackInfo
defaultLanguagePackInfo =
LanguagePackInfo
{ _id :: Maybe Text
_id = Maybe Text
forall a. Maybe a
Nothing
, base_language_pack_id :: Maybe Text
base_language_pack_id = Maybe Text
forall a. Maybe a
Nothing
, name :: Maybe Text
name = Maybe Text
forall a. Maybe a
Nothing
, native_name :: Maybe Text
native_name = Maybe Text
forall a. Maybe a
Nothing
, plural_code :: Maybe Text
plural_code = Maybe Text
forall a. Maybe a
Nothing
, is_official :: Maybe Bool
is_official = Maybe Bool
forall a. Maybe a
Nothing
, is_rtl :: Maybe Bool
is_rtl = Maybe Bool
forall a. Maybe a
Nothing
, is_beta :: Maybe Bool
is_beta = Maybe Bool
forall a. Maybe a
Nothing
, is_installed :: Maybe Bool
is_installed = Maybe Bool
forall a. Maybe a
Nothing
, total_string_count :: Maybe Int
total_string_count = Maybe Int
forall a. Maybe a
Nothing
, translated_string_count :: Maybe Int
translated_string_count = Maybe Int
forall a. Maybe a
Nothing
, local_string_count :: Maybe Int
local_string_count = Maybe Int
forall a. Maybe a
Nothing
, translation_url :: Maybe Text
translation_url = Maybe Text
forall a. Maybe a
Nothing
}