Permalink
Browse files

Expose /artist-credit/all-artist-credits

  • Loading branch information...
1 parent 501a2ba commit 400dc5464a3f5ce31ce195490789700379175b6d @ocharles ocharles committed Mar 4, 2013
Showing with 24 additions and 5 deletions.
  1. +1 −1 musicbrainz-data
  2. +11 −3 src/MusicBrainz/API/ArtistCredit.hs
  3. +10 −1 src/MusicBrainz/API/JSON.hs
  4. +1 −0 src/MusicBrainz/Service.hs
  5. +1 −0 test/suite/Handlers.hs
@@ -3,19 +3,27 @@
module MusicBrainz.API.ArtistCredit where
import Control.Applicative
-import Data.Text
+import Data.Text hiding (map)
import Text.Digestive
-import MusicBrainz hiding (coreRef, releaseLabel, partialDate)
+import MusicBrainz hiding (ArtistCredit, coreRef, releaseLabel, partialDate)
import MusicBrainz.API
+import MusicBrainz.API.JSON (ArtistCredit(..))
+import qualified MusicBrainz as MB
import qualified MusicBrainz.Data.ArtistCredit as MB
import qualified Data.Map as Map
import qualified Data.Set as Set
--------------------------------------------------------------------------------
expandCredits :: Form Text MusicBrainz
- (Map.Map (Ref ArtistCredit) [ArtistCreditName])
+ (Map.Map (Ref MB.ArtistCredit) [ArtistCreditName])
expandCredits =
runApi $ MB.expandCredits . Set.fromList <$>
listOf (const $ ref "Could not resolve artist credit") Nothing
+
+
+
+--------------------------------------------------------------------------------
+allCredits :: Form Text MusicBrainz [ArtistCredit]
+allCredits = fmap (map ArtistCredit) $ runApi $ MB.allArtistCredits <$> "artist" .: coreRef
@@ -5,6 +5,7 @@
{-# LANGUAGE OverloadedStrings #-}
module MusicBrainz.API.JSON
( Annotation(..)
+ , ArtistCredit(..)
, MaybeObject(..)
, RefObject(..)
, EligibleForCleanup(..)
@@ -21,7 +22,7 @@ import qualified Data.HashMap.Strict as HMap
import qualified Data.Map as Map
import qualified Data.Text as Text
-import MusicBrainz
+import MusicBrainz hiding (ArtistCredit)
import MusicBrainz.Data.Recording (RecordingUse(..))
--------------------------------------------------------------------------------
@@ -306,6 +307,13 @@ instance ToJSON EligibleForCleanup where
--------------------------------------------------------------------------------
+newtype ArtistCredit = ArtistCredit [ArtistCreditName]
+
+instance ToJSON ArtistCredit where
+ toJSON (ArtistCredit names) = toJSON names
+
+
+--------------------------------------------------------------------------------
class ToJSON a => TopLevel a
instance (Referenceable a, ToJSON (RefSpec a)) => TopLevel (RefObject a)
@@ -319,3 +327,4 @@ instance TopLevel Annotation
instance TopLevel EligibleForCleanup
instance TopLevel a => TopLevel [a]
instance TopLevel RecordingUse
+instance TopLevel ArtistCredit
@@ -252,6 +252,7 @@ serviceInit connInfo sessionStore =
, ("/artist/view-relationships", expose Artist.viewRelationships)
, ("/artist/view-revision", expose Artist.viewRevision)
+ , ("/artist-credit/all-artist-credits", expose ArtistCredit.allCredits)
, ("/artist-credit/expand", expose ArtistCredit.expandCredits)
, ("/artist-type/add", expose ArtistType.add)
View
@@ -32,6 +32,7 @@ tests = map testHandlerExists
, "/artist/view-ipi-codes"
, "/artist/view-relationships"
, "/artist/view-revision"
+ , "/artist-credit/all-artist-credits"
, "/artist-credit/expand"
, "/artist-type/add"
, "/edit/add-note"

0 comments on commit 400dc54

Please sign in to comment.