module TD.Query.SetCustomLanguagePackString
  (SetCustomLanguagePackString(..)
  , defaultSetCustomLanguagePackString
  ) 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
import qualified TD.Data.LanguagePackString as LanguagePackString

-- | Adds, edits or deletes a string in a custom local language pack. Can be called before authorization. Returns 'TD.Data.Ok.Ok'
data SetCustomLanguagePackString
  = SetCustomLanguagePackString
    { SetCustomLanguagePackString -> Maybe Text
language_pack_id :: Maybe T.Text                                -- ^ Identifier of a previously added custom local language pack in the current localization target
    , SetCustomLanguagePackString -> Maybe LanguagePackString
new_string       :: Maybe LanguagePackString.LanguagePackString -- ^ New language pack string
    }
  deriving (SetCustomLanguagePackString -> SetCustomLanguagePackString -> Bool
(SetCustomLanguagePackString
 -> SetCustomLanguagePackString -> Bool)
-> (SetCustomLanguagePackString
    -> SetCustomLanguagePackString -> Bool)
-> Eq SetCustomLanguagePackString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCustomLanguagePackString -> SetCustomLanguagePackString -> Bool
== :: SetCustomLanguagePackString -> SetCustomLanguagePackString -> Bool
$c/= :: SetCustomLanguagePackString -> SetCustomLanguagePackString -> Bool
/= :: SetCustomLanguagePackString -> SetCustomLanguagePackString -> Bool
Eq, Int -> SetCustomLanguagePackString -> ShowS
[SetCustomLanguagePackString] -> ShowS
SetCustomLanguagePackString -> String
(Int -> SetCustomLanguagePackString -> ShowS)
-> (SetCustomLanguagePackString -> String)
-> ([SetCustomLanguagePackString] -> ShowS)
-> Show SetCustomLanguagePackString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCustomLanguagePackString -> ShowS
showsPrec :: Int -> SetCustomLanguagePackString -> ShowS
$cshow :: SetCustomLanguagePackString -> String
show :: SetCustomLanguagePackString -> String
$cshowList :: [SetCustomLanguagePackString] -> ShowS
showList :: [SetCustomLanguagePackString] -> ShowS
Show)

instance I.ShortShow SetCustomLanguagePackString where
  shortShow :: SetCustomLanguagePackString -> String
shortShow
    SetCustomLanguagePackString
      { language_pack_id :: SetCustomLanguagePackString -> Maybe Text
language_pack_id = Maybe Text
language_pack_id_
      , new_string :: SetCustomLanguagePackString -> Maybe LanguagePackString
new_string       = Maybe LanguagePackString
new_string_
      }
        = String
"SetCustomLanguagePackString"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"language_pack_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_pack_id_
          , String
"new_string"       String -> Maybe LanguagePackString -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe LanguagePackString
new_string_
          ]

instance AT.ToJSON SetCustomLanguagePackString where
  toJSON :: SetCustomLanguagePackString -> Value
toJSON
    SetCustomLanguagePackString
      { language_pack_id :: SetCustomLanguagePackString -> Maybe Text
language_pack_id = Maybe Text
language_pack_id_
      , new_string :: SetCustomLanguagePackString -> Maybe LanguagePackString
new_string       = Maybe LanguagePackString
new_string_
      }
        = [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
"setCustomLanguagePackString"
          , 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
"new_string"       Key -> Maybe LanguagePackString -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe LanguagePackString
new_string_
          ]

defaultSetCustomLanguagePackString :: SetCustomLanguagePackString
defaultSetCustomLanguagePackString :: SetCustomLanguagePackString
defaultSetCustomLanguagePackString =
  SetCustomLanguagePackString
    { language_pack_id :: Maybe Text
language_pack_id = Maybe Text
forall a. Maybe a
Nothing
    , new_string :: Maybe LanguagePackString
new_string       = Maybe LanguagePackString
forall a. Maybe a
Nothing
    }