Skip to content

Commit f61995e

Browse files
committed
Correct SpotifyWebAPI::deleteMy* request bodies
1 parent 07a1de0 commit f61995e

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

src/SpotifyWebAPI.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,9 @@ public function currentUserFollows(string $type, string|array $ids): array
442442
public function deleteMyAlbums(string|array $albums): bool
443443
{
444444
$albums = $this->uriToId($albums, 'album');
445-
$albums = json_encode((array) $albums);
445+
$albums = json_encode([
446+
'ids' => (array) $albums,
447+
]);
446448

447449
$headers = [
448450
'Content-Type' => 'application/json',
@@ -466,7 +468,9 @@ public function deleteMyAlbums(string|array $albums): bool
466468
public function deleteMyEpisodes(string|array $episodes): bool
467469
{
468470
$episodes = $this->uriToId($episodes, 'episode');
469-
$episodes = json_encode((array) $episodes);
471+
$episodes = json_encode([
472+
'ids' => (array) $episodes,
473+
]);
470474

471475
$headers = [
472476
'Content-Type' => 'application/json',
@@ -490,7 +494,9 @@ public function deleteMyEpisodes(string|array $episodes): bool
490494
public function deleteMyShows(string|array $shows): bool
491495
{
492496
$shows = $this->uriToId($shows, 'show');
493-
$shows = json_encode((array) $shows);
497+
$shows = json_encode([
498+
'ids' => (array) $shows,
499+
]);
494500

495501
$headers = [
496502
'Content-Type' => 'application/json',
@@ -514,7 +520,9 @@ public function deleteMyShows(string|array $shows): bool
514520
public function deleteMyTracks(string|array $tracks): bool
515521
{
516522
$tracks = $this->uriToId($tracks, 'track');
517-
$tracks = json_encode((array) $tracks);
523+
$tracks = json_encode([
524+
'ids' => (array) $tracks,
525+
]);
518526

519527
$headers = [
520528
'Content-Type' => 'application/json',

tests/SpotifyWebAPITest.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,15 @@ public function testDeleteMyAlbums()
437437
$albums = [
438438
'1oR3KrPIp4CbagPa3PhtPp',
439439
'6lPb7Eoon6QPbscWbMsk6a',
440-
'spotify:album:1oR3KrPIp4CbagPa3PhtPp'
440+
'spotify:album:1oR3KrPIp4CbagPa3PhtPp',
441441
];
442442

443443
$expected = json_encode([
444-
'1oR3KrPIp4CbagPa3PhtPp',
445-
'6lPb7Eoon6QPbscWbMsk6a',
446-
'1oR3KrPIp4CbagPa3PhtPp'
444+
'ids' => [
445+
'1oR3KrPIp4CbagPa3PhtPp',
446+
'6lPb7Eoon6QPbscWbMsk6a',
447+
'1oR3KrPIp4CbagPa3PhtPp',
448+
],
447449
]);
448450

449451
$headers = ['Content-Type' => 'application/json'];
@@ -470,9 +472,11 @@ public function testDeleteMyEpisodes()
470472
];
471473

472474
$expected = json_encode([
473-
'0zov0kd6MA3BqT1FKpOeYO',
474-
'3pLx6LaVQbWl5IfW8nxq56',
475-
'6kSGLgKWhBg8AoCzylVfc2',
475+
'ids' => [
476+
'0zov0kd6MA3BqT1FKpOeYO',
477+
'3pLx6LaVQbWl5IfW8nxq56',
478+
'6kSGLgKWhBg8AoCzylVfc2',
479+
],
476480
]);
477481

478482
$headers = ['Content-Type' => 'application/json'];
@@ -499,9 +503,11 @@ public function testDeleteMyShows()
499503
];
500504

501505
$expected = json_encode([
502-
'1oR3KrPIp4CbagPa3PhtPp',
503-
'6lPb7Eoon6QPbscWbMsk6a',
504-
'1oR3KrPIp4CbagPa3PhtPp'
506+
'ids' => [
507+
'1oR3KrPIp4CbagPa3PhtPp',
508+
'6lPb7Eoon6QPbscWbMsk6a',
509+
'1oR3KrPIp4CbagPa3PhtPp',
510+
],
505511
]);
506512

507513
$headers = ['Content-Type' => 'application/json'];
@@ -528,9 +534,11 @@ public function testDeleteMyTracks()
528534
];
529535

530536
$expected = json_encode([
531-
'1id6H6vcwSB9GGv9NXh5cl',
532-
'3mqRLlD9j92BBv1ueFhJ1l',
533-
'1id6H6vcwSB9GGv9NXh5cl',
537+
'ids' => [
538+
'1id6H6vcwSB9GGv9NXh5cl',
539+
'3mqRLlD9j92BBv1ueFhJ1l',
540+
'1id6H6vcwSB9GGv9NXh5cl',
541+
],
534542
]);
535543

536544
$headers = ['Content-Type' => 'application/json'];

0 commit comments

Comments
 (0)