{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoFieldSelectors #-}

module WikiMusic.Servant.SongRoutes
  ( fetchSongsRoute,
    insertSongsRoute,
    insertSongCommentsRoute,
    insertSongArtworksRoute,
    upsertSongOpinionsRoute,
    deleteSongsByIdentifierRoute,
    deleteSongCommentsByIdentifierRoute,
    deleteSongOpinionsByIdentifierRoute,
    deleteSongArtworksByIdentifierRoute,
    updateSongArtworksOrderRoute,
    updateSongRoute,
    insertArtistOfSongRoute,
    fetchSongRoute,
    updateSongContentsRoute,
    insertSongContentsRoute,
    deleteSongContentsByIdentifierRoute,
    searchSongsRoute,
    deleteArtistOfSongRoute,
  )
where

import Servant
import WikiMusic.Console.Logger ()
import WikiMusic.Free.Logger
import WikiMusic.Free.SongCommand
import WikiMusic.Free.SongQuery
import WikiMusic.Interaction.Model.Song
import WikiMusic.Interaction.Song
import WikiMusic.Model.Env
import WikiMusic.Model.Other
import WikiMusic.Protolude
import WikiMusic.Servant.Utilities
import WikiMusic.Sqlite.SongCommand ()
import WikiMusic.Sqlite.SongQuery ()

fetchSongsRoute :: Env -> Maybe Text -> Maybe Int -> Maybe Int -> Maybe Text -> Maybe Text -> Handler GetSongsQueryResponse
fetchSongsRoute :: Env
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Handler GetSongsQueryResponse
fetchSongsRoute Env
env Maybe Text
authToken Maybe Int
limit Maybe Int
offset Maybe Text
sort' Maybe Text
include =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler GetSongsQueryResponse)
-> Handler GetSongsQueryResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError GetSongsQueryResponse)
-> Handler (Either SongError GetSongsQueryResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @(SongQuery :+: SongCommand) (Free
   (SongQuery :+: SongCommand)
   (Either SongError GetSongsQueryResponse)
 -> IO (Either SongError GetSongsQueryResponse))
-> Free
     (SongQuery :+: SongCommand)
     (Either SongError GetSongsQueryResponse)
-> IO (Either SongError GetSongsQueryResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> Limit
-> Offset
-> Maybe Text
-> Maybe Text
-> Free
     (SongQuery :+: SongCommand)
     (Either SongError GetSongsQueryResponse)
forall (f :: * -> *).
(SongQuery :<: f, SongCommand :<: f) =>
Env
-> WikiMusicUser
-> Limit
-> Offset
-> Maybe Text
-> Maybe Text
-> Free f (Either SongError GetSongsQueryResponse)
fetchSongsAction Env
env WikiMusicUser
authUser (Limit -> (Int -> Limit) -> Maybe Int -> Limit
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Int -> Limit
Limit Int
25) Int -> Limit
Limit Maybe Int
limit) (Offset -> (Int -> Offset) -> Maybe Int -> Offset
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Int -> Offset
Offset Int
0) Int -> Offset
Offset Maybe Int
offset) Maybe Text
sort' Maybe Text
include) Handler (Either SongError GetSongsQueryResponse)
-> (Either SongError GetSongsQueryResponse
    -> Handler GetSongsQueryResponse)
-> Handler GetSongsQueryResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError GetSongsQueryResponse
-> Handler GetSongsQueryResponse
forall s b. Show s => Either s b -> Handler b
maybe200
    )

searchSongsRoute :: Env -> Maybe Text -> Text -> Maybe Int -> Maybe Int -> Maybe Text -> Maybe Text -> Handler GetSongsQueryResponse
searchSongsRoute :: Env
-> Maybe Text
-> Text
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Handler GetSongsQueryResponse
searchSongsRoute Env
env Maybe Text
authToken Text
searchInput Maybe Int
limit Maybe Int
offset Maybe Text
sort' Maybe Text
include =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler GetSongsQueryResponse)
-> Handler GetSongsQueryResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError GetSongsQueryResponse)
-> Handler (Either SongError GetSongsQueryResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @(SongQuery :+: SongCommand) (Free
   (SongQuery :+: SongCommand)
   (Either SongError GetSongsQueryResponse)
 -> IO (Either SongError GetSongsQueryResponse))
-> Free
     (SongQuery :+: SongCommand)
     (Either SongError GetSongsQueryResponse)
-> IO (Either SongError GetSongsQueryResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> Limit
-> Offset
-> Maybe Text
-> Maybe Text
-> Text
-> Free
     (SongQuery :+: SongCommand)
     (Either SongError GetSongsQueryResponse)
forall (f :: * -> *).
(SongQuery :<: f, SongCommand :<: f) =>
Env
-> WikiMusicUser
-> Limit
-> Offset
-> Maybe Text
-> Maybe Text
-> Text
-> Free f (Either SongError GetSongsQueryResponse)
searchSongsAction Env
env WikiMusicUser
authUser (Limit -> (Int -> Limit) -> Maybe Int -> Limit
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Int -> Limit
Limit Int
25) Int -> Limit
Limit Maybe Int
limit) (Offset -> (Int -> Offset) -> Maybe Int -> Offset
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Int -> Offset
Offset Int
0) Int -> Offset
Offset Maybe Int
offset) Maybe Text
sort' Maybe Text
include Text
searchInput) Handler (Either SongError GetSongsQueryResponse)
-> (Either SongError GetSongsQueryResponse
    -> Handler GetSongsQueryResponse)
-> Handler GetSongsQueryResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError GetSongsQueryResponse
-> Handler GetSongsQueryResponse
forall s b. Show s => Either s b -> Handler b
maybe200
    )

fetchSongRoute :: Env -> Maybe Text -> UUID -> Handler GetSongsQueryResponse
fetchSongRoute :: Env -> Maybe Text -> UUID -> Handler GetSongsQueryResponse
fetchSongRoute Env
env Maybe Text
authToken UUID
identifier =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler GetSongsQueryResponse)
-> Handler GetSongsQueryResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError GetSongsQueryResponse)
-> Handler (Either SongError GetSongsQueryResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @(SongQuery :+: SongCommand) (Free
   (SongQuery :+: SongCommand)
   (Either SongError GetSongsQueryResponse)
 -> IO (Either SongError GetSongsQueryResponse))
-> Free
     (SongQuery :+: SongCommand)
     (Either SongError GetSongsQueryResponse)
-> IO (Either SongError GetSongsQueryResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> UUID
-> Maybe Text
-> Maybe Text
-> Free
     (SongQuery :+: SongCommand)
     (Either SongError GetSongsQueryResponse)
forall (f :: * -> *).
(SongQuery :<: f, SongCommand :<: f) =>
Env
-> WikiMusicUser
-> UUID
-> Maybe Text
-> Maybe Text
-> Free f (Either SongError GetSongsQueryResponse)
fetchSongAction Env
env WikiMusicUser
authUser UUID
identifier (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"created-at-desc") (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"artworks,opinions,comments,contents")) Handler (Either SongError GetSongsQueryResponse)
-> (Either SongError GetSongsQueryResponse
    -> Handler GetSongsQueryResponse)
-> Handler GetSongsQueryResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError GetSongsQueryResponse
-> Handler GetSongsQueryResponse
forall s b. Show s => Either s b -> Handler b
maybe200
    )

insertSongsRoute :: Env -> Maybe Text -> InsertSongsRequest -> Handler InsertSongsCommandResponse
insertSongsRoute :: Env
-> Maybe Text
-> InsertSongsRequest
-> Handler InsertSongsCommandResponse
insertSongsRoute Env
env Maybe Text
authToken InsertSongsRequest
req =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler InsertSongsCommandResponse)
-> Handler InsertSongsCommandResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError InsertSongsCommandResponse)
-> Handler (Either SongError InsertSongsCommandResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @(SongCommand :+: SongQuery :+: Logger) (Free
   (SongCommand :+: (SongQuery :+: Logger))
   (Either SongError InsertSongsCommandResponse)
 -> IO (Either SongError InsertSongsCommandResponse))
-> Free
     (SongCommand :+: (SongQuery :+: Logger))
     (Either SongError InsertSongsCommandResponse)
-> IO (Either SongError InsertSongsCommandResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> InsertSongsRequest
-> Free
     (SongCommand :+: (SongQuery :+: Logger))
     (Either SongError InsertSongsCommandResponse)
forall (f :: * -> *).
(SongQuery :<: f, SongCommand :<: f, Logger :<: f) =>
Env
-> WikiMusicUser
-> InsertSongsRequest
-> Free f (Either SongError InsertSongsCommandResponse)
insertSongsAction Env
env WikiMusicUser
authUser InsertSongsRequest
req) Handler (Either SongError InsertSongsCommandResponse)
-> (Either SongError InsertSongsCommandResponse
    -> Handler InsertSongsCommandResponse)
-> Handler InsertSongsCommandResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError InsertSongsCommandResponse
-> Handler InsertSongsCommandResponse
forall s b. Show s => Either s b -> Handler b
maybe204
    )

insertSongCommentsRoute :: Env -> Maybe Text -> InsertSongCommentsRequest -> Handler InsertSongCommentsCommandResponse
insertSongCommentsRoute :: Env
-> Maybe Text
-> InsertSongCommentsRequest
-> Handler InsertSongCommentsCommandResponse
insertSongCommentsRoute Env
env Maybe Text
authToken InsertSongCommentsRequest
req =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler InsertSongCommentsCommandResponse)
-> Handler InsertSongCommentsCommandResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError InsertSongCommentsCommandResponse)
-> Handler (Either SongError InsertSongCommentsCommandResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free
   SongCommand (Either SongError InsertSongCommentsCommandResponse)
 -> IO (Either SongError InsertSongCommentsCommandResponse))
-> Free
     SongCommand (Either SongError InsertSongCommentsCommandResponse)
-> IO (Either SongError InsertSongCommentsCommandResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> InsertSongCommentsRequest
-> Free
     SongCommand (Either SongError InsertSongCommentsCommandResponse)
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> InsertSongCommentsRequest
-> Free f (Either SongError InsertSongCommentsCommandResponse)
insertSongCommentsAction Env
env WikiMusicUser
authUser InsertSongCommentsRequest
req) Handler (Either SongError InsertSongCommentsCommandResponse)
-> (Either SongError InsertSongCommentsCommandResponse
    -> Handler InsertSongCommentsCommandResponse)
-> Handler InsertSongCommentsCommandResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError InsertSongCommentsCommandResponse
-> Handler InsertSongCommentsCommandResponse
forall s b. Show s => Either s b -> Handler b
maybe204
    )

upsertSongOpinionsRoute :: Env -> Maybe Text -> UpsertSongOpinionsRequest -> Handler UpsertSongOpinionsCommandResponse
upsertSongOpinionsRoute :: Env
-> Maybe Text
-> UpsertSongOpinionsRequest
-> Handler UpsertSongOpinionsCommandResponse
upsertSongOpinionsRoute Env
env Maybe Text
authToken UpsertSongOpinionsRequest
req =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler UpsertSongOpinionsCommandResponse)
-> Handler UpsertSongOpinionsCommandResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError UpsertSongOpinionsCommandResponse)
-> Handler (Either SongError UpsertSongOpinionsCommandResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free
   SongCommand (Either SongError UpsertSongOpinionsCommandResponse)
 -> IO (Either SongError UpsertSongOpinionsCommandResponse))
-> Free
     SongCommand (Either SongError UpsertSongOpinionsCommandResponse)
-> IO (Either SongError UpsertSongOpinionsCommandResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> UpsertSongOpinionsRequest
-> Free
     SongCommand (Either SongError UpsertSongOpinionsCommandResponse)
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> UpsertSongOpinionsRequest
-> Free f (Either SongError UpsertSongOpinionsCommandResponse)
upsertSongOpinionsAction Env
env WikiMusicUser
authUser UpsertSongOpinionsRequest
req) Handler (Either SongError UpsertSongOpinionsCommandResponse)
-> (Either SongError UpsertSongOpinionsCommandResponse
    -> Handler UpsertSongOpinionsCommandResponse)
-> Handler UpsertSongOpinionsCommandResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError UpsertSongOpinionsCommandResponse
-> Handler UpsertSongOpinionsCommandResponse
forall s b. Show s => Either s b -> Handler b
maybe204
    )

insertSongArtworksRoute :: Env -> Maybe Text -> InsertSongArtworksRequest -> Handler InsertSongArtworksCommandResponse
insertSongArtworksRoute :: Env
-> Maybe Text
-> InsertSongArtworksRequest
-> Handler InsertSongArtworksCommandResponse
insertSongArtworksRoute Env
env Maybe Text
authToken InsertSongArtworksRequest
req =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler InsertSongArtworksCommandResponse)
-> Handler InsertSongArtworksCommandResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError InsertSongArtworksCommandResponse)
-> Handler (Either SongError InsertSongArtworksCommandResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free
   SongCommand (Either SongError InsertSongArtworksCommandResponse)
 -> IO (Either SongError InsertSongArtworksCommandResponse))
-> Free
     SongCommand (Either SongError InsertSongArtworksCommandResponse)
-> IO (Either SongError InsertSongArtworksCommandResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> InsertSongArtworksRequest
-> Free
     SongCommand (Either SongError InsertSongArtworksCommandResponse)
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> InsertSongArtworksRequest
-> Free f (Either SongError InsertSongArtworksCommandResponse)
insertSongArtworksAction Env
env WikiMusicUser
authUser InsertSongArtworksRequest
req) Handler (Either SongError InsertSongArtworksCommandResponse)
-> (Either SongError InsertSongArtworksCommandResponse
    -> Handler InsertSongArtworksCommandResponse)
-> Handler InsertSongArtworksCommandResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError InsertSongArtworksCommandResponse
-> Handler InsertSongArtworksCommandResponse
forall s b. Show s => Either s b -> Handler b
maybe204
    )

deleteSongsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongsByIdentifierRoute Env
env Maybe Text
authToken UUID
uid =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser -> UUID -> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env -> WikiMusicUser -> UUID -> Free f (Either SongError ())
deleteSongsByIdentifierAction Env
env WikiMusicUser
authUser UUID
uid) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

deleteSongCommentsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongCommentsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongCommentsByIdentifierRoute Env
env Maybe Text
authToken UUID
uid =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser -> UUID -> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env -> WikiMusicUser -> UUID -> Free f (Either SongError ())
deleteSongCommentsByIdentifierAction Env
env WikiMusicUser
authUser UUID
uid) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

deleteSongOpinionsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongOpinionsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongOpinionsByIdentifierRoute Env
env Maybe Text
authToken UUID
uid =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser -> UUID -> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env -> WikiMusicUser -> UUID -> Free f (Either SongError ())
deleteSongOpinionsByIdentifierAction Env
env WikiMusicUser
authUser UUID
uid) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

deleteSongArtworksByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongArtworksByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongArtworksByIdentifierRoute Env
env Maybe Text
authToken UUID
uid =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser -> UUID -> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env -> WikiMusicUser -> UUID -> Free f (Either SongError ())
deleteSongArtworksByIdentifierAction Env
env WikiMusicUser
authUser UUID
uid) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

updateSongArtworksOrderRoute :: Env -> Maybe Text -> SongArtworkOrderUpdateRequest -> Handler ()
updateSongArtworksOrderRoute :: Env -> Maybe Text -> SongArtworkOrderUpdateRequest -> Handler ()
updateSongArtworksOrderRoute Env
env Maybe Text
authToken SongArtworkOrderUpdateRequest
req =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> SongArtworkOrderUpdateRequest
-> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> SongArtworkOrderUpdateRequest
-> Free f (Either SongError ())
updateSongArtworksOrderAction Env
env WikiMusicUser
authUser SongArtworkOrderUpdateRequest
req) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

updateSongRoute :: Env -> Maybe Text -> SongDeltaRequest -> Handler ()
updateSongRoute :: Env -> Maybe Text -> SongDeltaRequest -> Handler ()
updateSongRoute Env
env Maybe Text
authToken SongDeltaRequest
req =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @(SongCommand :+: SongQuery) (Free (SongCommand :+: SongQuery) (Either SongError ())
 -> IO (Either SongError ()))
-> Free (SongCommand :+: SongQuery) (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> SongDeltaRequest
-> Free (SongCommand :+: SongQuery) (Either SongError ())
forall (f :: * -> *).
(SongQuery :<: f, SongCommand :<: f) =>
Env
-> WikiMusicUser
-> SongDeltaRequest
-> Free f (Either SongError ())
updateSongAction Env
env WikiMusicUser
authUser SongDeltaRequest
req) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

insertArtistOfSongRoute :: Env -> Maybe Text -> InsertArtistsOfSongsRequest -> Handler InsertArtistsOfSongCommandResponse
insertArtistOfSongRoute :: Env
-> Maybe Text
-> InsertArtistsOfSongsRequest
-> Handler InsertArtistsOfSongCommandResponse
insertArtistOfSongRoute Env
env Maybe Text
authToken InsertArtistsOfSongsRequest
req =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler InsertArtistsOfSongCommandResponse)
-> Handler InsertArtistsOfSongCommandResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError InsertArtistsOfSongCommandResponse)
-> Handler (Either SongError InsertArtistsOfSongCommandResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free
   SongCommand (Either SongError InsertArtistsOfSongCommandResponse)
 -> IO (Either SongError InsertArtistsOfSongCommandResponse))
-> Free
     SongCommand (Either SongError InsertArtistsOfSongCommandResponse)
-> IO (Either SongError InsertArtistsOfSongCommandResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> InsertArtistsOfSongsRequest
-> Free
     SongCommand (Either SongError InsertArtistsOfSongCommandResponse)
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> InsertArtistsOfSongsRequest
-> Free f (Either SongError InsertArtistsOfSongCommandResponse)
insertArtistsOfSongAction Env
env WikiMusicUser
authUser InsertArtistsOfSongsRequest
req) Handler (Either SongError InsertArtistsOfSongCommandResponse)
-> (Either SongError InsertArtistsOfSongCommandResponse
    -> Handler InsertArtistsOfSongCommandResponse)
-> Handler InsertArtistsOfSongCommandResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError InsertArtistsOfSongCommandResponse
-> Handler InsertArtistsOfSongCommandResponse
forall s b. Show s => Either s b -> Handler b
maybe204
    )

deleteArtistOfSongRoute :: Env -> Maybe Text -> InsertArtistsOfSongsRequest -> Handler ()
deleteArtistOfSongRoute :: Env -> Maybe Text -> InsertArtistsOfSongsRequest -> Handler ()
deleteArtistOfSongRoute Env
env Maybe Text
authToken InsertArtistsOfSongsRequest
req =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> InsertArtistsOfSongsRequest
-> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> InsertArtistsOfSongsRequest
-> Free f (Either SongError ())
deleteArtistsOfSongAction Env
env WikiMusicUser
authUser InsertArtistsOfSongsRequest
req) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

insertSongContentsRoute :: Env -> Maybe Text -> InsertSongContentsRequest -> Handler InsertSongContentsCommandResponse
insertSongContentsRoute :: Env
-> Maybe Text
-> InsertSongContentsRequest
-> Handler InsertSongContentsCommandResponse
insertSongContentsRoute Env
env Maybe Text
authToken InsertSongContentsRequest
req =
  Env
-> Maybe Text
-> (WikiMusicUser -> Handler InsertSongContentsCommandResponse)
-> Handler InsertSongContentsCommandResponse
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError InsertSongContentsCommandResponse)
-> Handler (Either SongError InsertSongContentsCommandResponse)
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @(SongCommand :+: SongQuery) (Free
   (SongCommand :+: SongQuery)
   (Either SongError InsertSongContentsCommandResponse)
 -> IO (Either SongError InsertSongContentsCommandResponse))
-> Free
     (SongCommand :+: SongQuery)
     (Either SongError InsertSongContentsCommandResponse)
-> IO (Either SongError InsertSongContentsCommandResponse)
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> InsertSongContentsRequest
-> Free
     (SongCommand :+: SongQuery)
     (Either SongError InsertSongContentsCommandResponse)
forall (f :: * -> *).
(SongQuery :<: f, SongCommand :<: f) =>
Env
-> WikiMusicUser
-> InsertSongContentsRequest
-> Free f (Either SongError InsertSongContentsCommandResponse)
insertSongContentsAction Env
env WikiMusicUser
authUser InsertSongContentsRequest
req) Handler (Either SongError InsertSongContentsCommandResponse)
-> (Either SongError InsertSongContentsCommandResponse
    -> Handler InsertSongContentsCommandResponse)
-> Handler InsertSongContentsCommandResponse
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError InsertSongContentsCommandResponse
-> Handler InsertSongContentsCommandResponse
forall s b. Show s => Either s b -> Handler b
maybe204
    )

deleteSongContentsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongContentsByIdentifierRoute :: Env -> Maybe Text -> UUID -> Handler ()
deleteSongContentsByIdentifierRoute Env
env Maybe Text
authToken UUID
uid =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser -> UUID -> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env -> WikiMusicUser -> UUID -> Free f (Either SongError ())
deleteSongContentsByIdentifierAction Env
env WikiMusicUser
authUser UUID
uid) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )

updateSongContentsRoute :: Env -> Maybe Text -> SongContentDeltaRequest -> Handler ()
updateSongContentsRoute :: Env -> Maybe Text -> SongContentDeltaRequest -> Handler ()
updateSongContentsRoute Env
env Maybe Text
authToken SongContentDeltaRequest
req =
  Env -> Maybe Text -> (WikiMusicUser -> Handler ()) -> Handler ()
forall a.
Env -> Maybe Text -> (WikiMusicUser -> Handler a) -> Handler a
doWithAuth
    Env
env
    Maybe Text
authToken
    ( \WikiMusicUser
authUser ->
        IO (Either SongError ()) -> Handler (Either SongError ())
forall a. IO a -> Handler a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongCommand (Free SongCommand (Either SongError ())
 -> IO (Either SongError ()))
-> Free SongCommand (Either SongError ())
-> IO (Either SongError ())
forall a b. (a -> b) -> a -> b
$ Env
-> WikiMusicUser
-> SongContentDeltaRequest
-> Free SongCommand (Either SongError ())
forall (f :: * -> *).
(SongCommand :<: f) =>
Env
-> WikiMusicUser
-> SongContentDeltaRequest
-> Free f (Either SongError ())
updateSongContentsAction Env
env WikiMusicUser
authUser SongContentDeltaRequest
req) Handler (Either SongError ())
-> (Either SongError () -> Handler ()) -> Handler ()
forall a b. Handler a -> (a -> Handler b) -> Handler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either SongError () -> Handler ()
forall s b. Show s => Either s b -> Handler b
maybe204
    )