module TD.Query.GetFileDownloadedPrefixSize
  (GetFileDownloadedPrefixSize(..)
  , defaultGetFileDownloadedPrefixSize
  ) where

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

-- | Returns file downloaded prefix size from a given offset, in bytes. Returns 'TD.Data.FileDownloadedPrefixSize.FileDownloadedPrefixSize'
data GetFileDownloadedPrefixSize
  = GetFileDownloadedPrefixSize
    { GetFileDownloadedPrefixSize -> Maybe Int
file_id :: Maybe Int -- ^ Identifier of the file
    , GetFileDownloadedPrefixSize -> Maybe Int
offset  :: Maybe Int -- ^ Offset from which downloaded prefix size needs to be calculated
    }
  deriving (GetFileDownloadedPrefixSize -> GetFileDownloadedPrefixSize -> Bool
(GetFileDownloadedPrefixSize
 -> GetFileDownloadedPrefixSize -> Bool)
-> (GetFileDownloadedPrefixSize
    -> GetFileDownloadedPrefixSize -> Bool)
-> Eq GetFileDownloadedPrefixSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetFileDownloadedPrefixSize -> GetFileDownloadedPrefixSize -> Bool
== :: GetFileDownloadedPrefixSize -> GetFileDownloadedPrefixSize -> Bool
$c/= :: GetFileDownloadedPrefixSize -> GetFileDownloadedPrefixSize -> Bool
/= :: GetFileDownloadedPrefixSize -> GetFileDownloadedPrefixSize -> Bool
Eq, Int -> GetFileDownloadedPrefixSize -> ShowS
[GetFileDownloadedPrefixSize] -> ShowS
GetFileDownloadedPrefixSize -> String
(Int -> GetFileDownloadedPrefixSize -> ShowS)
-> (GetFileDownloadedPrefixSize -> String)
-> ([GetFileDownloadedPrefixSize] -> ShowS)
-> Show GetFileDownloadedPrefixSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetFileDownloadedPrefixSize -> ShowS
showsPrec :: Int -> GetFileDownloadedPrefixSize -> ShowS
$cshow :: GetFileDownloadedPrefixSize -> String
show :: GetFileDownloadedPrefixSize -> String
$cshowList :: [GetFileDownloadedPrefixSize] -> ShowS
showList :: [GetFileDownloadedPrefixSize] -> ShowS
Show)

instance I.ShortShow GetFileDownloadedPrefixSize where
  shortShow :: GetFileDownloadedPrefixSize -> String
shortShow
    GetFileDownloadedPrefixSize
      { file_id :: GetFileDownloadedPrefixSize -> Maybe Int
file_id = Maybe Int
file_id_
      , offset :: GetFileDownloadedPrefixSize -> Maybe Int
offset  = Maybe Int
offset_
      }
        = String
"GetFileDownloadedPrefixSize"
          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_
          , String
"offset"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
offset_
          ]

instance AT.ToJSON GetFileDownloadedPrefixSize where
  toJSON :: GetFileDownloadedPrefixSize -> Value
toJSON
    GetFileDownloadedPrefixSize
      { file_id :: GetFileDownloadedPrefixSize -> Maybe Int
file_id = Maybe Int
file_id_
      , offset :: GetFileDownloadedPrefixSize -> Maybe Int
offset  = Maybe Int
offset_
      }
        = [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
"getFileDownloadedPrefixSize"
          , 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_
          , Key
"offset"  Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
offset_
          ]

defaultGetFileDownloadedPrefixSize :: GetFileDownloadedPrefixSize
defaultGetFileDownloadedPrefixSize :: GetFileDownloadedPrefixSize
defaultGetFileDownloadedPrefixSize =
  GetFileDownloadedPrefixSize
    { file_id :: Maybe Int
file_id = Maybe Int
forall a. Maybe a
Nothing
    , offset :: Maybe Int
offset  = Maybe Int
forall a. Maybe a
Nothing
    }