diff --git a/src/main/kotlin/com/stevesoltys/applemusic/AppleMusic.kt b/src/main/kotlin/com/stevesoltys/applemusic/AppleMusic.kt index a4019ca..f728ef5 100644 --- a/src/main/kotlin/com/stevesoltys/applemusic/AppleMusic.kt +++ b/src/main/kotlin/com/stevesoltys/applemusic/AppleMusic.kt @@ -114,6 +114,15 @@ class AppleMusic( return call(appleMusicService.getAlbumById(id, include?.toTypedArray())) } + /** + * Get a set of albums by their identifiers. + */ + fun getAlbumsById( + ids: Array + ): AlbumResponse { + return call(appleMusicService.getAlbumsById(ids)) + } + /** * Get albums for a given artist. */ diff --git a/src/test/kotlin/com/stevesoltys/applemusic/AppleMusicE2ETest.kt b/src/test/kotlin/com/stevesoltys/applemusic/AppleMusicE2ETest.kt index 81d30bf..2200385 100644 --- a/src/test/kotlin/com/stevesoltys/applemusic/AppleMusicE2ETest.kt +++ b/src/test/kotlin/com/stevesoltys/applemusic/AppleMusicE2ETest.kt @@ -29,6 +29,8 @@ class AppleMusicE2ETest { private const val TEST_ALBUM_IDENTIFIER = "259814641" private const val TEST_ALBUM_NAME = "An Innocent Man" + + private const val TEST_ALBUM_IDENTIFIER_2 = "1440903530" } private lateinit var appleMusic: AppleMusic @@ -65,13 +67,26 @@ class AppleMusicE2ETest { } @Test - fun `can get artist albums by identifier`() { + fun `can get a single album by identifier`() { val result = appleMusic.getAllAlbumsByArtistId(TEST_ARTIST_IDENTIFIER) val albums = result.data albums.shouldNotBeNull().shouldNotBeEmpty() } + @Test + fun `can get multiple albums by their identifiers`() { + val result = appleMusic.getAlbumsById( + arrayOf(TEST_ALBUM_IDENTIFIER, TEST_ALBUM_IDENTIFIER_2) + ) + + val albums = result.data + albums.shouldNotBeNull().shouldNotBeEmpty() + + albums.first().attributes?.artistName.shouldNotBeNull() + albums.first().relationships?.artists?.data.shouldNotBeNull().shouldHaveSize(1) + } + @Test fun `can get album by identifier`() { val result = appleMusic.getAlbumById(TEST_ALBUM_IDENTIFIER)