module TD.Query.AddSavedAnimation
  (AddSavedAnimation(..)
  ) where

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

-- | Manually adds a new animation to the list of saved animations. The new animation is added to the beginning of the list. If the animation was already in the list, it is removed first. Only non-secret video animations with MIME type "video/mp4" can be added to the list. Returns 'TD.Data.Ok.Ok'
data AddSavedAnimation
  = AddSavedAnimation
    { AddSavedAnimation -> Maybe InputFile
animation :: Maybe InputFile.InputFile -- ^ The animation file to be added. Only animations known to the server (i.e., successfully sent via a message) can be added to the list
    }
  deriving (AddSavedAnimation -> AddSavedAnimation -> Bool
(AddSavedAnimation -> AddSavedAnimation -> Bool)
-> (AddSavedAnimation -> AddSavedAnimation -> Bool)
-> Eq AddSavedAnimation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddSavedAnimation -> AddSavedAnimation -> Bool
== :: AddSavedAnimation -> AddSavedAnimation -> Bool
$c/= :: AddSavedAnimation -> AddSavedAnimation -> Bool
/= :: AddSavedAnimation -> AddSavedAnimation -> Bool
Eq, Int -> AddSavedAnimation -> ShowS
[AddSavedAnimation] -> ShowS
AddSavedAnimation -> String
(Int -> AddSavedAnimation -> ShowS)
-> (AddSavedAnimation -> String)
-> ([AddSavedAnimation] -> ShowS)
-> Show AddSavedAnimation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddSavedAnimation -> ShowS
showsPrec :: Int -> AddSavedAnimation -> ShowS
$cshow :: AddSavedAnimation -> String
show :: AddSavedAnimation -> String
$cshowList :: [AddSavedAnimation] -> ShowS
showList :: [AddSavedAnimation] -> ShowS
Show)

instance I.ShortShow AddSavedAnimation where
  shortShow :: AddSavedAnimation -> String
shortShow
    AddSavedAnimation
      { animation :: AddSavedAnimation -> Maybe InputFile
animation = Maybe InputFile
animation_
      }
        = String
"AddSavedAnimation"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"animation" String -> Maybe InputFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputFile
animation_
          ]

instance AT.ToJSON AddSavedAnimation where
  toJSON :: AddSavedAnimation -> Value
toJSON
    AddSavedAnimation
      { animation :: AddSavedAnimation -> Maybe InputFile
animation = Maybe InputFile
animation_
      }
        = [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
"addSavedAnimation"
          , Key
"animation" Key -> Maybe InputFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputFile
animation_
          ]