module TD.Query.GetLanguagePackString
  (GetLanguagePackString(..)
  , defaultGetLanguagePackString
  ) 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

-- | Returns a string stored in the local database from the specified localization target and language pack by its key. Returns a 404 error if the string is not found. Can be called synchronously. Returns 'TD.Data.LanguagePackStringValue.LanguagePackStringValue'
data GetLanguagePackString
  = GetLanguagePackString
    { GetLanguagePackString -> Maybe Text
language_pack_database_path :: Maybe T.Text -- ^ Path to the language pack database in which strings are stored
    , GetLanguagePackString -> Maybe Text
localization_target         :: Maybe T.Text -- ^ Localization target to which the language pack belongs
    , GetLanguagePackString -> Maybe Text
language_pack_id            :: Maybe T.Text -- ^ Language pack identifier
    , GetLanguagePackString -> Maybe Text
key                         :: Maybe T.Text -- ^ Language pack key of the string to be returned
    }
  deriving (GetLanguagePackString -> GetLanguagePackString -> Bool
(GetLanguagePackString -> GetLanguagePackString -> Bool)
-> (GetLanguagePackString -> GetLanguagePackString -> Bool)
-> Eq GetLanguagePackString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetLanguagePackString -> GetLanguagePackString -> Bool
== :: GetLanguagePackString -> GetLanguagePackString -> Bool
$c/= :: GetLanguagePackString -> GetLanguagePackString -> Bool
/= :: GetLanguagePackString -> GetLanguagePackString -> Bool
Eq, Int -> GetLanguagePackString -> ShowS
[GetLanguagePackString] -> ShowS
GetLanguagePackString -> String
(Int -> GetLanguagePackString -> ShowS)
-> (GetLanguagePackString -> String)
-> ([GetLanguagePackString] -> ShowS)
-> Show GetLanguagePackString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetLanguagePackString -> ShowS
showsPrec :: Int -> GetLanguagePackString -> ShowS
$cshow :: GetLanguagePackString -> String
show :: GetLanguagePackString -> String
$cshowList :: [GetLanguagePackString] -> ShowS
showList :: [GetLanguagePackString] -> ShowS
Show)

instance I.ShortShow GetLanguagePackString where
  shortShow :: GetLanguagePackString -> String
shortShow
    GetLanguagePackString
      { language_pack_database_path :: GetLanguagePackString -> Maybe Text
language_pack_database_path = Maybe Text
language_pack_database_path_
      , localization_target :: GetLanguagePackString -> Maybe Text
localization_target         = Maybe Text
localization_target_
      , language_pack_id :: GetLanguagePackString -> Maybe Text
language_pack_id            = Maybe Text
language_pack_id_
      , key :: GetLanguagePackString -> Maybe Text
key                         = Maybe Text
key_
      }
        = String
"GetLanguagePackString"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"language_pack_database_path" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_pack_database_path_
          , String
"localization_target"         String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
localization_target_
          , String
"language_pack_id"            String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_pack_id_
          , String
"key"                         String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
key_
          ]

instance AT.ToJSON GetLanguagePackString where
  toJSON :: GetLanguagePackString -> Value
toJSON
    GetLanguagePackString
      { language_pack_database_path :: GetLanguagePackString -> Maybe Text
language_pack_database_path = Maybe Text
language_pack_database_path_
      , localization_target :: GetLanguagePackString -> Maybe Text
localization_target         = Maybe Text
localization_target_
      , language_pack_id :: GetLanguagePackString -> Maybe Text
language_pack_id            = Maybe Text
language_pack_id_
      , key :: GetLanguagePackString -> Maybe Text
key                         = Maybe Text
key_
      }
        = [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
"getLanguagePackString"
          , Key
"language_pack_database_path" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
language_pack_database_path_
          , Key
"localization_target"         Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
localization_target_
          , Key
"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
language_pack_id_
          , Key
"key"                         Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
key_
          ]

defaultGetLanguagePackString :: GetLanguagePackString
defaultGetLanguagePackString :: GetLanguagePackString
defaultGetLanguagePackString =
  GetLanguagePackString
    { language_pack_database_path :: Maybe Text
language_pack_database_path = Maybe Text
forall a. Maybe a
Nothing
    , localization_target :: Maybe Text
localization_target         = Maybe Text
forall a. Maybe a
Nothing
    , language_pack_id :: Maybe Text
language_pack_id            = Maybe Text
forall a. Maybe a
Nothing
    , key :: Maybe Text
key                         = Maybe Text
forall a. Maybe a
Nothing
    }