module TD.Query.EditProxy
  (EditProxy(..)
  , defaultEditProxy
  ) 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.Proxy as Proxy

-- | Edits an existing proxy server for network requests. Can be called before authorization. Returns 'TD.Data.AddedProxy.AddedProxy'
data EditProxy
  = EditProxy
    { EditProxy -> Maybe Int
proxy_id :: Maybe Int         -- ^ Proxy identifier
    , EditProxy -> Maybe Proxy
proxy    :: Maybe Proxy.Proxy -- ^ The new information about the proxy
    , EditProxy -> Maybe Bool
enable   :: Maybe Bool        -- ^ Pass true to immediately enable the proxy
    }
  deriving (EditProxy -> EditProxy -> Bool
(EditProxy -> EditProxy -> Bool)
-> (EditProxy -> EditProxy -> Bool) -> Eq EditProxy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditProxy -> EditProxy -> Bool
== :: EditProxy -> EditProxy -> Bool
$c/= :: EditProxy -> EditProxy -> Bool
/= :: EditProxy -> EditProxy -> Bool
Eq, Int -> EditProxy -> ShowS
[EditProxy] -> ShowS
EditProxy -> String
(Int -> EditProxy -> ShowS)
-> (EditProxy -> String)
-> ([EditProxy] -> ShowS)
-> Show EditProxy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditProxy -> ShowS
showsPrec :: Int -> EditProxy -> ShowS
$cshow :: EditProxy -> String
show :: EditProxy -> String
$cshowList :: [EditProxy] -> ShowS
showList :: [EditProxy] -> ShowS
Show)

instance I.ShortShow EditProxy where
  shortShow :: EditProxy -> String
shortShow
    EditProxy
      { proxy_id :: EditProxy -> Maybe Int
proxy_id = Maybe Int
proxy_id_
      , proxy :: EditProxy -> Maybe Proxy
proxy    = Maybe Proxy
proxy_
      , enable :: EditProxy -> Maybe Bool
enable   = Maybe Bool
enable_
      }
        = String
"EditProxy"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"proxy_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
proxy_id_
          , String
"proxy"    String -> Maybe Proxy -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Proxy
proxy_
          , String
"enable"   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
enable_
          ]

instance AT.ToJSON EditProxy where
  toJSON :: EditProxy -> Value
toJSON
    EditProxy
      { proxy_id :: EditProxy -> Maybe Int
proxy_id = Maybe Int
proxy_id_
      , proxy :: EditProxy -> Maybe Proxy
proxy    = Maybe Proxy
proxy_
      , enable :: EditProxy -> Maybe Bool
enable   = Maybe Bool
enable_
      }
        = [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
"editProxy"
          , Key
"proxy_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
proxy_id_
          , Key
"proxy"    Key -> Maybe Proxy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Proxy
proxy_
          , Key
"enable"   Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
enable_
          ]

defaultEditProxy :: EditProxy
defaultEditProxy :: EditProxy
defaultEditProxy =
  EditProxy
    { proxy_id :: Maybe Int
proxy_id = Maybe Int
forall a. Maybe a
Nothing
    , proxy :: Maybe Proxy
proxy    = Maybe Proxy
forall a. Maybe a
Nothing
    , enable :: Maybe Bool
enable   = Maybe Bool
forall a. Maybe a
Nothing
    }