module TD.Query.GetInternalLinkType
  (GetInternalLinkType(..)
  ) 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

-- | Returns information about the type of internal link. Returns a 404 error if the link is not internal. Can be called before authorization. Returns 'TD.Data.InternalLinkType.InternalLinkType'
data GetInternalLinkType
  = GetInternalLinkType
    { GetInternalLinkType -> Maybe Text
link :: Maybe T.Text -- ^ The link
    }
  deriving (GetInternalLinkType -> GetInternalLinkType -> Bool
(GetInternalLinkType -> GetInternalLinkType -> Bool)
-> (GetInternalLinkType -> GetInternalLinkType -> Bool)
-> Eq GetInternalLinkType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetInternalLinkType -> GetInternalLinkType -> Bool
== :: GetInternalLinkType -> GetInternalLinkType -> Bool
$c/= :: GetInternalLinkType -> GetInternalLinkType -> Bool
/= :: GetInternalLinkType -> GetInternalLinkType -> Bool
Eq, Int -> GetInternalLinkType -> ShowS
[GetInternalLinkType] -> ShowS
GetInternalLinkType -> String
(Int -> GetInternalLinkType -> ShowS)
-> (GetInternalLinkType -> String)
-> ([GetInternalLinkType] -> ShowS)
-> Show GetInternalLinkType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetInternalLinkType -> ShowS
showsPrec :: Int -> GetInternalLinkType -> ShowS
$cshow :: GetInternalLinkType -> String
show :: GetInternalLinkType -> String
$cshowList :: [GetInternalLinkType] -> ShowS
showList :: [GetInternalLinkType] -> ShowS
Show)

instance I.ShortShow GetInternalLinkType where
  shortShow :: GetInternalLinkType -> String
shortShow
    GetInternalLinkType
      { link :: GetInternalLinkType -> Maybe Text
link = Maybe Text
link_
      }
        = String
"GetInternalLinkType"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"link" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
link_
          ]

instance AT.ToJSON GetInternalLinkType where
  toJSON :: GetInternalLinkType -> Value
toJSON
    GetInternalLinkType
      { link :: GetInternalLinkType -> Maybe Text
link = Maybe Text
link_
      }
        = [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
"getInternalLinkType"
          , Key
"link"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
link_
          ]