module TD.Query.SetProfileAudioPosition
  (SetProfileAudioPosition(..)
  , defaultSetProfileAudioPosition
  ) where

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

-- | Changes position of an audio file in the profile audio files of the current user. Returns 'TD.Data.Ok.Ok'
data SetProfileAudioPosition
  = SetProfileAudioPosition
    { SetProfileAudioPosition -> Maybe Int
file_id       :: Maybe Int -- ^ Identifier of the file from profile audio files, which position will be changed
    , SetProfileAudioPosition -> Maybe Int
after_file_id :: Maybe Int -- ^ Identifier of the file from profile audio files after which the file will be positioned; pass 0 to move the file to the beginning of the list
    }
  deriving (SetProfileAudioPosition -> SetProfileAudioPosition -> Bool
(SetProfileAudioPosition -> SetProfileAudioPosition -> Bool)
-> (SetProfileAudioPosition -> SetProfileAudioPosition -> Bool)
-> Eq SetProfileAudioPosition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetProfileAudioPosition -> SetProfileAudioPosition -> Bool
== :: SetProfileAudioPosition -> SetProfileAudioPosition -> Bool
$c/= :: SetProfileAudioPosition -> SetProfileAudioPosition -> Bool
/= :: SetProfileAudioPosition -> SetProfileAudioPosition -> Bool
Eq, Int -> SetProfileAudioPosition -> ShowS
[SetProfileAudioPosition] -> ShowS
SetProfileAudioPosition -> String
(Int -> SetProfileAudioPosition -> ShowS)
-> (SetProfileAudioPosition -> String)
-> ([SetProfileAudioPosition] -> ShowS)
-> Show SetProfileAudioPosition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetProfileAudioPosition -> ShowS
showsPrec :: Int -> SetProfileAudioPosition -> ShowS
$cshow :: SetProfileAudioPosition -> String
show :: SetProfileAudioPosition -> String
$cshowList :: [SetProfileAudioPosition] -> ShowS
showList :: [SetProfileAudioPosition] -> ShowS
Show)

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

instance AT.ToJSON SetProfileAudioPosition where
  toJSON :: SetProfileAudioPosition -> Value
toJSON
    SetProfileAudioPosition
      { file_id :: SetProfileAudioPosition -> Maybe Int
file_id       = Maybe Int
file_id_
      , after_file_id :: SetProfileAudioPosition -> Maybe Int
after_file_id = Maybe Int
after_file_id_
      }
        = [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
"setProfileAudioPosition"
          , 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
"after_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
after_file_id_
          ]

defaultSetProfileAudioPosition :: SetProfileAudioPosition
defaultSetProfileAudioPosition :: SetProfileAudioPosition
defaultSetProfileAudioPosition =
  SetProfileAudioPosition
    { file_id :: Maybe Int
file_id       = Maybe Int
forall a. Maybe a
Nothing
    , after_file_id :: Maybe Int
after_file_id = Maybe Int
forall a. Maybe a
Nothing
    }