module TD.Query.ToggleDownloadIsPaused
  (ToggleDownloadIsPaused(..)
  , defaultToggleDownloadIsPaused
  ) where

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

-- | Changes pause state of a file in the file download list. Returns 'TD.Data.Ok.Ok'
data ToggleDownloadIsPaused
  = ToggleDownloadIsPaused
    { ToggleDownloadIsPaused -> Maybe Int
file_id   :: Maybe Int  -- ^ Identifier of the downloaded file
    , ToggleDownloadIsPaused -> Maybe Bool
is_paused :: Maybe Bool -- ^ Pass true if the download is paused
    }
  deriving (ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool
(ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool)
-> (ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool)
-> Eq ToggleDownloadIsPaused
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool
== :: ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool
$c/= :: ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool
/= :: ToggleDownloadIsPaused -> ToggleDownloadIsPaused -> Bool
Eq, Int -> ToggleDownloadIsPaused -> ShowS
[ToggleDownloadIsPaused] -> ShowS
ToggleDownloadIsPaused -> String
(Int -> ToggleDownloadIsPaused -> ShowS)
-> (ToggleDownloadIsPaused -> String)
-> ([ToggleDownloadIsPaused] -> ShowS)
-> Show ToggleDownloadIsPaused
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleDownloadIsPaused -> ShowS
showsPrec :: Int -> ToggleDownloadIsPaused -> ShowS
$cshow :: ToggleDownloadIsPaused -> String
show :: ToggleDownloadIsPaused -> String
$cshowList :: [ToggleDownloadIsPaused] -> ShowS
showList :: [ToggleDownloadIsPaused] -> ShowS
Show)

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

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

defaultToggleDownloadIsPaused :: ToggleDownloadIsPaused
defaultToggleDownloadIsPaused :: ToggleDownloadIsPaused
defaultToggleDownloadIsPaused =
  ToggleDownloadIsPaused
    { file_id :: Maybe Int
file_id   = Maybe Int
forall a. Maybe a
Nothing
    , is_paused :: Maybe Bool
is_paused = Maybe Bool
forall a. Maybe a
Nothing
    }