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

-- | Adds or changes a custom local language pack to the current localization target. Returns 'TD.Data.Ok.Ok'
data SetCustomLanguagePack
  = SetCustomLanguagePack
    { SetCustomLanguagePack -> Maybe LanguagePackInfo
info    :: Maybe LanguagePackInfo.LanguagePackInfo       -- ^ Information about the language pack. Language pack identifier must start with 'X', consist only of English letters, digits and hyphens, and must not exceed 64 characters. Can be called before authorization
    , SetCustomLanguagePack -> Maybe [LanguagePackString]
strings :: Maybe [LanguagePackString.LanguagePackString] -- ^ Strings of the new language pack
    }
  deriving (SetCustomLanguagePack -> SetCustomLanguagePack -> Bool
(SetCustomLanguagePack -> SetCustomLanguagePack -> Bool)
-> (SetCustomLanguagePack -> SetCustomLanguagePack -> Bool)
-> Eq SetCustomLanguagePack
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCustomLanguagePack -> SetCustomLanguagePack -> Bool
== :: SetCustomLanguagePack -> SetCustomLanguagePack -> Bool
$c/= :: SetCustomLanguagePack -> SetCustomLanguagePack -> Bool
/= :: SetCustomLanguagePack -> SetCustomLanguagePack -> Bool
Eq, Int -> SetCustomLanguagePack -> ShowS
[SetCustomLanguagePack] -> ShowS
SetCustomLanguagePack -> String
(Int -> SetCustomLanguagePack -> ShowS)
-> (SetCustomLanguagePack -> String)
-> ([SetCustomLanguagePack] -> ShowS)
-> Show SetCustomLanguagePack
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCustomLanguagePack -> ShowS
showsPrec :: Int -> SetCustomLanguagePack -> ShowS
$cshow :: SetCustomLanguagePack -> String
show :: SetCustomLanguagePack -> String
$cshowList :: [SetCustomLanguagePack] -> ShowS
showList :: [SetCustomLanguagePack] -> ShowS
Show)

instance I.ShortShow SetCustomLanguagePack where
  shortShow :: SetCustomLanguagePack -> String
shortShow
    SetCustomLanguagePack
      { info :: SetCustomLanguagePack -> Maybe LanguagePackInfo
info    = Maybe LanguagePackInfo
info_
      , strings :: SetCustomLanguagePack -> Maybe [LanguagePackString]
strings = Maybe [LanguagePackString]
strings_
      }
        = String
"SetCustomLanguagePack"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"info"    String -> Maybe LanguagePackInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe LanguagePackInfo
info_
          , String
"strings" String -> Maybe [LanguagePackString] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [LanguagePackString]
strings_
          ]

instance AT.ToJSON SetCustomLanguagePack where
  toJSON :: SetCustomLanguagePack -> Value
toJSON
    SetCustomLanguagePack
      { info :: SetCustomLanguagePack -> Maybe LanguagePackInfo
info    = Maybe LanguagePackInfo
info_
      , strings :: SetCustomLanguagePack -> Maybe [LanguagePackString]
strings = Maybe [LanguagePackString]
strings_
      }
        = [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
"setCustomLanguagePack"
          , Key
"info"    Key -> Maybe LanguagePackInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe LanguagePackInfo
info_
          , Key
"strings" Key -> Maybe [LanguagePackString] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [LanguagePackString]
strings_
          ]

defaultSetCustomLanguagePack :: SetCustomLanguagePack
defaultSetCustomLanguagePack :: SetCustomLanguagePack
defaultSetCustomLanguagePack =
  SetCustomLanguagePack
    { info :: Maybe LanguagePackInfo
info    = Maybe LanguagePackInfo
forall a. Maybe a
Nothing
    , strings :: Maybe [LanguagePackString]
strings = Maybe [LanguagePackString]
forall a. Maybe a
Nothing
    }