module TD.Query.RemoveFileFromDownloads
  (RemoveFileFromDownloads(..)
  , defaultRemoveFileFromDownloads
  ) where

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

-- | Removes a file from the file download list. Returns 'TD.Data.Ok.Ok'
data RemoveFileFromDownloads
  = RemoveFileFromDownloads
    { RemoveFileFromDownloads -> Maybe Int
file_id           :: Maybe Int  -- ^ Identifier of the downloaded file
    , RemoveFileFromDownloads -> Maybe Bool
delete_from_cache :: Maybe Bool -- ^ Pass true to delete the file from the TDLib file cache
    }
  deriving (RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool
(RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool)
-> (RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool)
-> Eq RemoveFileFromDownloads
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool
== :: RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool
$c/= :: RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool
/= :: RemoveFileFromDownloads -> RemoveFileFromDownloads -> Bool
Eq, Int -> RemoveFileFromDownloads -> ShowS
[RemoveFileFromDownloads] -> ShowS
RemoveFileFromDownloads -> String
(Int -> RemoveFileFromDownloads -> ShowS)
-> (RemoveFileFromDownloads -> String)
-> ([RemoveFileFromDownloads] -> ShowS)
-> Show RemoveFileFromDownloads
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveFileFromDownloads -> ShowS
showsPrec :: Int -> RemoveFileFromDownloads -> ShowS
$cshow :: RemoveFileFromDownloads -> String
show :: RemoveFileFromDownloads -> String
$cshowList :: [RemoveFileFromDownloads] -> ShowS
showList :: [RemoveFileFromDownloads] -> ShowS
Show)

instance I.ShortShow RemoveFileFromDownloads where
  shortShow :: RemoveFileFromDownloads -> String
shortShow
    RemoveFileFromDownloads
      { file_id :: RemoveFileFromDownloads -> Maybe Int
file_id           = Maybe Int
file_id_
      , delete_from_cache :: RemoveFileFromDownloads -> Maybe Bool
delete_from_cache = Maybe Bool
delete_from_cache_
      }
        = String
"RemoveFileFromDownloads"
          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
"delete_from_cache" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
delete_from_cache_
          ]

instance AT.ToJSON RemoveFileFromDownloads where
  toJSON :: RemoveFileFromDownloads -> Value
toJSON
    RemoveFileFromDownloads
      { file_id :: RemoveFileFromDownloads -> Maybe Int
file_id           = Maybe Int
file_id_
      , delete_from_cache :: RemoveFileFromDownloads -> Maybe Bool
delete_from_cache = Maybe Bool
delete_from_cache_
      }
        = [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
"removeFileFromDownloads"
          , 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
"delete_from_cache" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
delete_from_cache_
          ]

defaultRemoveFileFromDownloads :: RemoveFileFromDownloads
defaultRemoveFileFromDownloads :: RemoveFileFromDownloads
defaultRemoveFileFromDownloads =
  RemoveFileFromDownloads
    { file_id :: Maybe Int
file_id           = Maybe Int
forall a. Maybe a
Nothing
    , delete_from_cache :: Maybe Bool
delete_from_cache = Maybe Bool
forall a. Maybe a
Nothing
    }