This repository was archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47080ee
commit 4322425
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Tnapf\Spotify\Rest; | ||
|
||
use Tnapf\Spotify\Abstractions\Album\Album; | ||
use Tnapf\Spotify\Enums\Method; | ||
use Tnapf\Spotify\Http; | ||
|
||
class Albums extends RestBase | ||
{ | ||
public function get(string $id): Album | ||
{ | ||
return $this->http->mapRequest( | ||
Album::class, | ||
Method::GET, | ||
Http::BASE_URI."/albums/{$id}", | ||
headers: $this->http->mergeHeaders() | ||
); | ||
} | ||
|
||
/** @return Album[] */ | ||
public function getSeveral(string ...$ids): array | ||
{ | ||
return $this->http->arrayMapRequest( | ||
Album::class, | ||
Method::GET, | ||
Http::BASE_URI.'/albums?'.http_build_query(['ids' => implode(',', $ids)], '', '&'), | ||
headers: $this->http->mergeHeaders(), | ||
callback: static fn (array $array): array => $array['albums'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Tnapf\Spotify\Rest; | ||
|
||
use Tnapf\Spotify\Http; | ||
|
||
class RestBase | ||
{ | ||
public function __construct( | ||
protected readonly Http $http | ||
) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Tnapf\Spotify\Rest; | ||
|
||
use Tnapf\Spotify\Abstractions\Track; | ||
use Tnapf\Spotify\Enums\Method; | ||
use Tnapf\Spotify\Http; | ||
|
||
class Tracks extends RestBase | ||
{ | ||
public function getTrack(string $id): Track | ||
{ | ||
return $this->http->mapRequest( | ||
Track::class, | ||
Method::GET, | ||
Http::BASE_URI."tracks/{$id}", | ||
headers: $this->http->mergeHeaders() | ||
); | ||
} | ||
} |