module TD.Query.GetProxyLink
  (GetProxyLink(..)
  ) where

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

-- | Returns an HTTPS link, which can be used to add a proxy. Available only for SOCKS5 and MTProto proxies. Can be called before authorization. Returns 'TD.Data.HttpUrl.HttpUrl'
data GetProxyLink
  = GetProxyLink
    { GetProxyLink -> Maybe Int
proxy_id :: Maybe Int -- ^ Proxy identifier
    }
  deriving (GetProxyLink -> GetProxyLink -> Bool
(GetProxyLink -> GetProxyLink -> Bool)
-> (GetProxyLink -> GetProxyLink -> Bool) -> Eq GetProxyLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetProxyLink -> GetProxyLink -> Bool
== :: GetProxyLink -> GetProxyLink -> Bool
$c/= :: GetProxyLink -> GetProxyLink -> Bool
/= :: GetProxyLink -> GetProxyLink -> Bool
Eq, Int -> GetProxyLink -> ShowS
[GetProxyLink] -> ShowS
GetProxyLink -> String
(Int -> GetProxyLink -> ShowS)
-> (GetProxyLink -> String)
-> ([GetProxyLink] -> ShowS)
-> Show GetProxyLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetProxyLink -> ShowS
showsPrec :: Int -> GetProxyLink -> ShowS
$cshow :: GetProxyLink -> String
show :: GetProxyLink -> String
$cshowList :: [GetProxyLink] -> ShowS
showList :: [GetProxyLink] -> ShowS
Show)

instance I.ShortShow GetProxyLink where
  shortShow :: GetProxyLink -> String
shortShow
    GetProxyLink
      { proxy_id :: GetProxyLink -> Maybe Int
proxy_id = Maybe Int
proxy_id_
      }
        = String
"GetProxyLink"
          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_
          ]

instance AT.ToJSON GetProxyLink where
  toJSON :: GetProxyLink -> Value
toJSON
    GetProxyLink
      { proxy_id :: GetProxyLink -> Maybe Int
proxy_id = Maybe Int
proxy_id_
      }
        = [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
"getProxyLink"
          , 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_
          ]