module TD.Query.GetLocalizationTargetInfo
  (GetLocalizationTargetInfo(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Returns information about the current localization target. This is an offline request if only_local is true. Can be called before authorization. Returns 'TD.Data.LocalizationTargetInfo.LocalizationTargetInfo'
data GetLocalizationTargetInfo
  = GetLocalizationTargetInfo
    { GetLocalizationTargetInfo -> Maybe Bool
only_local :: Maybe Bool -- ^ Pass true to get only locally available information without sending network requests
    }
  deriving (GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool
(GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool)
-> (GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool)
-> Eq GetLocalizationTargetInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool
== :: GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool
$c/= :: GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool
/= :: GetLocalizationTargetInfo -> GetLocalizationTargetInfo -> Bool
Eq, Int -> GetLocalizationTargetInfo -> ShowS
[GetLocalizationTargetInfo] -> ShowS
GetLocalizationTargetInfo -> String
(Int -> GetLocalizationTargetInfo -> ShowS)
-> (GetLocalizationTargetInfo -> String)
-> ([GetLocalizationTargetInfo] -> ShowS)
-> Show GetLocalizationTargetInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetLocalizationTargetInfo -> ShowS
showsPrec :: Int -> GetLocalizationTargetInfo -> ShowS
$cshow :: GetLocalizationTargetInfo -> String
show :: GetLocalizationTargetInfo -> String
$cshowList :: [GetLocalizationTargetInfo] -> ShowS
showList :: [GetLocalizationTargetInfo] -> ShowS
Show)

instance I.ShortShow GetLocalizationTargetInfo where
  shortShow :: GetLocalizationTargetInfo -> String
shortShow
    GetLocalizationTargetInfo
      { only_local :: GetLocalizationTargetInfo -> Maybe Bool
only_local = Maybe Bool
only_local_
      }
        = String
"GetLocalizationTargetInfo"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"only_local" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_local_
          ]

instance AT.ToJSON GetLocalizationTargetInfo where
  toJSON :: GetLocalizationTargetInfo -> Value
toJSON
    GetLocalizationTargetInfo
      { only_local :: GetLocalizationTargetInfo -> Maybe Bool
only_local = Maybe Bool
only_local_
      }
        = [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
"getLocalizationTargetInfo"
          , Key
"only_local" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_local_
          ]