module TD.Query.AddSavedNotificationSound
  (AddSavedNotificationSound(..)
  ) 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

-- | Adds a new notification sound to the list of saved notification sounds. The new notification sound is added to the top of the list. If it is already in the list, its position isn't changed. Returns 'TD.Data.NotificationSound.NotificationSound'
data AddSavedNotificationSound
  = AddSavedNotificationSound
    { AddSavedNotificationSound -> Maybe InputFile
sound :: Maybe InputFile.InputFile -- ^ Notification sound file to add
    }
  deriving (AddSavedNotificationSound -> AddSavedNotificationSound -> Bool
(AddSavedNotificationSound -> AddSavedNotificationSound -> Bool)
-> (AddSavedNotificationSound -> AddSavedNotificationSound -> Bool)
-> Eq AddSavedNotificationSound
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddSavedNotificationSound -> AddSavedNotificationSound -> Bool
== :: AddSavedNotificationSound -> AddSavedNotificationSound -> Bool
$c/= :: AddSavedNotificationSound -> AddSavedNotificationSound -> Bool
/= :: AddSavedNotificationSound -> AddSavedNotificationSound -> Bool
Eq, Int -> AddSavedNotificationSound -> ShowS
[AddSavedNotificationSound] -> ShowS
AddSavedNotificationSound -> String
(Int -> AddSavedNotificationSound -> ShowS)
-> (AddSavedNotificationSound -> String)
-> ([AddSavedNotificationSound] -> ShowS)
-> Show AddSavedNotificationSound
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddSavedNotificationSound -> ShowS
showsPrec :: Int -> AddSavedNotificationSound -> ShowS
$cshow :: AddSavedNotificationSound -> String
show :: AddSavedNotificationSound -> String
$cshowList :: [AddSavedNotificationSound] -> ShowS
showList :: [AddSavedNotificationSound] -> ShowS
Show)

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

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