module TD.Query.EditStoryMusic
  (EditStoryMusic(..)
  , defaultEditStoryMusic
  ) 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.InputAudio as InputAudio

-- | Changes music attached to a story. Can be called only if story.can_be_edited == true and the story isn't being edited now. Returns 'TD.Data.Ok.Ok'
data EditStoryMusic
  = EditStoryMusic
    { EditStoryMusic -> Maybe Int
story_poster_chat_id :: Maybe Int                   -- ^ Identifier of the chat that posted the story
    , EditStoryMusic -> Maybe Int
story_id             :: Maybe Int                   -- ^ Identifier of the story to edit
    , EditStoryMusic -> Maybe InputAudio
music                :: Maybe InputAudio.InputAudio -- ^ The new music; pass null to remove music from the story. The music can be up to 60 seconds long
    }
  deriving (EditStoryMusic -> EditStoryMusic -> Bool
(EditStoryMusic -> EditStoryMusic -> Bool)
-> (EditStoryMusic -> EditStoryMusic -> Bool) -> Eq EditStoryMusic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditStoryMusic -> EditStoryMusic -> Bool
== :: EditStoryMusic -> EditStoryMusic -> Bool
$c/= :: EditStoryMusic -> EditStoryMusic -> Bool
/= :: EditStoryMusic -> EditStoryMusic -> Bool
Eq, Int -> EditStoryMusic -> ShowS
[EditStoryMusic] -> ShowS
EditStoryMusic -> String
(Int -> EditStoryMusic -> ShowS)
-> (EditStoryMusic -> String)
-> ([EditStoryMusic] -> ShowS)
-> Show EditStoryMusic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditStoryMusic -> ShowS
showsPrec :: Int -> EditStoryMusic -> ShowS
$cshow :: EditStoryMusic -> String
show :: EditStoryMusic -> String
$cshowList :: [EditStoryMusic] -> ShowS
showList :: [EditStoryMusic] -> ShowS
Show)

instance I.ShortShow EditStoryMusic where
  shortShow :: EditStoryMusic -> String
shortShow
    EditStoryMusic
      { story_poster_chat_id :: EditStoryMusic -> Maybe Int
story_poster_chat_id = Maybe Int
story_poster_chat_id_
      , story_id :: EditStoryMusic -> Maybe Int
story_id             = Maybe Int
story_id_
      , music :: EditStoryMusic -> Maybe InputAudio
music                = Maybe InputAudio
music_
      }
        = String
"EditStoryMusic"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_poster_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_poster_chat_id_
          , String
"story_id"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"music"                String -> Maybe InputAudio -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputAudio
music_
          ]

instance AT.ToJSON EditStoryMusic where
  toJSON :: EditStoryMusic -> Value
toJSON
    EditStoryMusic
      { story_poster_chat_id :: EditStoryMusic -> Maybe Int
story_poster_chat_id = Maybe Int
story_poster_chat_id_
      , story_id :: EditStoryMusic -> Maybe Int
story_id             = Maybe Int
story_id_
      , music :: EditStoryMusic -> Maybe InputAudio
music                = Maybe InputAudio
music_
      }
        = [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
"editStoryMusic"
          , Key
"story_poster_chat_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
story_poster_chat_id_
          , Key
"story_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
story_id_
          , Key
"music"                Key -> Maybe InputAudio -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputAudio
music_
          ]

defaultEditStoryMusic :: EditStoryMusic
defaultEditStoryMusic :: EditStoryMusic
defaultEditStoryMusic =
  EditStoryMusic
    { story_poster_chat_id :: Maybe Int
story_poster_chat_id = Maybe Int
forall a. Maybe a
Nothing
    , story_id :: Maybe Int
story_id             = Maybe Int
forall a. Maybe a
Nothing
    , music :: Maybe InputAudio
music                = Maybe InputAudio
forall a. Maybe a
Nothing
    }