module TD.Query.GetFile
  (GetFile(..)
  ) where

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

-- | Returns information about a file; this is an offline request. Returns 'TD.Data.File.File'
data GetFile
  = GetFile
    { GetFile -> Maybe Int
file_id :: Maybe Int -- ^ Identifier of the file to get
    }
  deriving (GetFile -> GetFile -> Bool
(GetFile -> GetFile -> Bool)
-> (GetFile -> GetFile -> Bool) -> Eq GetFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetFile -> GetFile -> Bool
== :: GetFile -> GetFile -> Bool
$c/= :: GetFile -> GetFile -> Bool
/= :: GetFile -> GetFile -> Bool
Eq, Int -> GetFile -> ShowS
[GetFile] -> ShowS
GetFile -> String
(Int -> GetFile -> ShowS)
-> (GetFile -> String) -> ([GetFile] -> ShowS) -> Show GetFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetFile -> ShowS
showsPrec :: Int -> GetFile -> ShowS
$cshow :: GetFile -> String
show :: GetFile -> String
$cshowList :: [GetFile] -> ShowS
showList :: [GetFile] -> ShowS
Show)

instance I.ShortShow GetFile where
  shortShow :: GetFile -> String
shortShow
    GetFile
      { file_id :: GetFile -> Maybe Int
file_id = Maybe Int
file_id_
      }
        = String
"GetFile"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"file_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
file_id_
          ]

instance AT.ToJSON GetFile where
  toJSON :: GetFile -> Value
toJSON
    GetFile
      { file_id :: GetFile -> Maybe Int
file_id = Maybe Int
file_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
"getFile"
          , Key
"file_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
file_id_
          ]