module TD.Query.RemoveAllFilesFromDownloads
  (RemoveAllFilesFromDownloads(..)
  , defaultRemoveAllFilesFromDownloads
  ) where

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

-- | Removes all files from the file download list. Returns 'TD.Data.Ok.Ok'
data RemoveAllFilesFromDownloads
  = RemoveAllFilesFromDownloads
    { RemoveAllFilesFromDownloads -> Maybe Bool
only_active       :: Maybe Bool -- ^ Pass true to remove only active downloads, including paused
    , RemoveAllFilesFromDownloads -> Maybe Bool
only_completed    :: Maybe Bool -- ^ Pass true to remove only completed downloads
    , RemoveAllFilesFromDownloads -> Maybe Bool
delete_from_cache :: Maybe Bool -- ^ Pass true to delete the file from the TDLib file cache
    }
  deriving (RemoveAllFilesFromDownloads -> RemoveAllFilesFromDownloads -> Bool
(RemoveAllFilesFromDownloads
 -> RemoveAllFilesFromDownloads -> Bool)
-> (RemoveAllFilesFromDownloads
    -> RemoveAllFilesFromDownloads -> Bool)
-> Eq RemoveAllFilesFromDownloads
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveAllFilesFromDownloads -> RemoveAllFilesFromDownloads -> Bool
== :: RemoveAllFilesFromDownloads -> RemoveAllFilesFromDownloads -> Bool
$c/= :: RemoveAllFilesFromDownloads -> RemoveAllFilesFromDownloads -> Bool
/= :: RemoveAllFilesFromDownloads -> RemoveAllFilesFromDownloads -> Bool
Eq, Int -> RemoveAllFilesFromDownloads -> ShowS
[RemoveAllFilesFromDownloads] -> ShowS
RemoveAllFilesFromDownloads -> String
(Int -> RemoveAllFilesFromDownloads -> ShowS)
-> (RemoveAllFilesFromDownloads -> String)
-> ([RemoveAllFilesFromDownloads] -> ShowS)
-> Show RemoveAllFilesFromDownloads
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveAllFilesFromDownloads -> ShowS
showsPrec :: Int -> RemoveAllFilesFromDownloads -> ShowS
$cshow :: RemoveAllFilesFromDownloads -> String
show :: RemoveAllFilesFromDownloads -> String
$cshowList :: [RemoveAllFilesFromDownloads] -> ShowS
showList :: [RemoveAllFilesFromDownloads] -> ShowS
Show)

instance I.ShortShow RemoveAllFilesFromDownloads where
  shortShow :: RemoveAllFilesFromDownloads -> String
shortShow
    RemoveAllFilesFromDownloads
      { only_active :: RemoveAllFilesFromDownloads -> Maybe Bool
only_active       = Maybe Bool
only_active_
      , only_completed :: RemoveAllFilesFromDownloads -> Maybe Bool
only_completed    = Maybe Bool
only_completed_
      , delete_from_cache :: RemoveAllFilesFromDownloads -> Maybe Bool
delete_from_cache = Maybe Bool
delete_from_cache_
      }
        = String
"RemoveAllFilesFromDownloads"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"only_active"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_active_
          , String
"only_completed"    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_completed_
          , 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 RemoveAllFilesFromDownloads where
  toJSON :: RemoveAllFilesFromDownloads -> Value
toJSON
    RemoveAllFilesFromDownloads
      { only_active :: RemoveAllFilesFromDownloads -> Maybe Bool
only_active       = Maybe Bool
only_active_
      , only_completed :: RemoveAllFilesFromDownloads -> Maybe Bool
only_completed    = Maybe Bool
only_completed_
      , delete_from_cache :: RemoveAllFilesFromDownloads -> 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
"removeAllFilesFromDownloads"
          , Key
"only_active"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_active_
          , Key
"only_completed"    Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_completed_
          , 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_
          ]

defaultRemoveAllFilesFromDownloads :: RemoveAllFilesFromDownloads
defaultRemoveAllFilesFromDownloads :: RemoveAllFilesFromDownloads
defaultRemoveAllFilesFromDownloads =
  RemoveAllFilesFromDownloads
    { only_active :: Maybe Bool
only_active       = Maybe Bool
forall a. Maybe a
Nothing
    , only_completed :: Maybe Bool
only_completed    = Maybe Bool
forall a. Maybe a
Nothing
    , delete_from_cache :: Maybe Bool
delete_from_cache = Maybe Bool
forall a. Maybe a
Nothing
    }