Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Expose /release/view-mediums

  • Loading branch information...
commit 872ebdcf2dcad88868120d7073ffad31835c62d1 1 parent a74748e
@ocharles ocharles authored
View
37 src/MusicBrainz/API/JSON.hs
@@ -82,6 +82,19 @@ instance ToJSON ArtistType where
toJSON ArtistType{..} = object [ "name" .= artistTypeName ]
+
+--------------------------------------------------------------------------------
+instance ToJSON Barcode where
+ toJSON = toJSON . review barcode
+
+
+--------------------------------------------------------------------------------
+instance ToJSON CdToc where
+ toJSON CdToc{..} = object [ "leadout-offset" .= cdTocLeadoutOffset
+ , "track-offsets" .= cdTocTrackOffsets
+ ]
+
+
--------------------------------------------------------------------------------
instance ToJSON Editor where
toJSON Editor{..} = object [ "name" .= editorName
@@ -129,6 +142,16 @@ instance ToJSON LinkedRelationship where
--------------------------------------------------------------------------------
+instance ToJSON Medium where
+ toJSON Medium{..} = object [ "name" .= mediumName
+ , "format" .= mediumFormat
+ , "position" .= mediumPosition
+ , "tracks" .= mediumTracks
+ , "cdtocs" .= mediumCdTocs
+ ]
+
+
+--------------------------------------------------------------------------------
instance ToJSON Recording where
toJSON Recording{..} = object [ "name" .= recordingName
, "comment" .= recordingComment
@@ -154,10 +177,6 @@ instance ToJSON Release where
--------------------------------------------------------------------------------
-instance ToJSON Barcode where
- toJSON = toJSON . review barcode
-
---------------------------------------------------------------------------------
instance ToJSON ReleaseGroup where
toJSON ReleaseGroup{..} = object
[ "name" .= releaseGroupName
@@ -181,6 +200,16 @@ instance ToJSON (Revision a) where
--------------------------------------------------------------------------------
+instance ToJSON Track where
+ toJSON Track{..} = object [ "name" .= trackName
+ , "recording" .= trackRecording
+ , "duration" .= trackDuration
+ , "artist-credit" .= trackArtistCredit
+ , "number" .= trackPosition
+ ]
+
+
+--------------------------------------------------------------------------------
instance ToJSON URI where
toJSON = toJSON . show
View
5 src/MusicBrainz/API/Release.hs
@@ -124,3 +124,8 @@ findByLabel = runApi $ MB.findByLabel <$> "label" .: coreRef
--------------------------------------------------------------------------------
viewReleaseLabels :: Form Text MusicBrainz (Map.Map (Ref (Revision Release)) (Set.Set ReleaseLabel))
viewReleaseLabels = runApi $ MB.viewReleaseLabels <$> setOf revisionRef
+
+
+--------------------------------------------------------------------------------
+viewMediums :: Form Text MusicBrainz (Map.Map (Ref (Revision Release)) [Medium])
+viewMediums = runApi $ MB.viewMediums <$> setOf revisionRef
View
1  src/MusicBrainz/Service.hs
@@ -292,6 +292,7 @@ serviceInit connInfo sessionStore =
, ("/release/merge", expose Release.merge)
, ("/release/update", expose Release.update)
, ("/release/view-annotation", expose Release.viewAnnotation)
+ , ("/release/view-mediums", expose Release.viewMediums)
, ("/release/view-release-labels", expose Release.viewReleaseLabels)
, ("/release/view-relationships", expose Release.viewRelationships)
, ("/release/view-revision", expose Release.viewRevision)
View
4 test/suite/Handlers.hs
@@ -63,6 +63,7 @@ tests = map testHandlerExists
, "/release/merge"
, "/release/update"
, "/release/view-annotation"
+ , "/release/view-mediums"
, "/release/view-relationships"
, "/release/view-release-labels"
, "/release/view-revision"
@@ -106,7 +107,8 @@ testHandlerExists path = testCase (Text.unpack $ (Encoding.decodeUtf8 path) `Tex
(return testSessionStore)
response <- runHandler (postRaw path "application/json" mempty) s
- assertBool "Response code is not 5xx" $ rspStatus response < 500
+ assertBool "Response code is >= 500" $ rspStatus response < 500
+ assertBool "Response code is 404" $ rspStatus response /= 404
liftIO tearDown
Please sign in to comment.
Something went wrong with that request. Please try again.