Permalink
Browse files

Add support for barcodes for releases

  • Loading branch information...
1 parent 057388e commit cda2d0e3e18c14645190be5f541e2517d717d1a7 @ocharles ocharles committed Feb 18, 2013
Showing with 11 additions and 1 deletion.
  1. +1 −1 musicbrainz-data
  2. +9 −0 src/MusicBrainz/API/Release.hs
  3. +1 −0 test/suite/Tests.hs
@@ -3,6 +3,7 @@
module MusicBrainz.API.Release where
import Control.Applicative
+import Control.Lens
import Data.Text (Text)
import Text.Digestive
@@ -32,12 +33,20 @@ tree = ReleaseTree <$> "release" .: release
<*> "language" .: languageRef
<*> "packaging" .: releasePackagingRef
<*> "status" .: releaseStatusRef
+ <*> "barcode" .: barcodeF
where
scriptRef = optionalRef "Invalid script reference"
releaseStatusRef = optionalRef "Invalid release status reference"
countryRef = optionalRef "Invalid country reference"
releasePackagingRef = optionalRef "Invalid country reference"
languageRef = optionalRef "Invalid country reference"
+ barcodeF = validate toBarcode $ (,) <$> "no-barcode" .: bool Nothing
+ <*> "barcode" .: string Nothing
+ where toBarcode (True, _) = Success (Just NoBarcode)
+ toBarcode (False, b) =
+ maybe (Error "Invalid barcode")
+ (Success . Just)
+ (b ^? barcode)
labels = "labels" .: setOf releaseLabel
where
View
@@ -240,6 +240,7 @@ testReleaseFindLatest c = testCase "/find-latest" $ testMb c $ do
, releaseStatus = Nothing
, releasePackaging = Nothing
, releaseReleaseGroup = coreRef rg
+ , releaseBarcode = Nothing
}
, releaseAnnotation = mempty
, releaseLabels = mempty

0 comments on commit cda2d0e

Please sign in to comment.