-
Notifications
You must be signed in to change notification settings - Fork 0
Stan errors fixes #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| parameters: | ||
| level: 5 | ||
| paths: | ||
| - src | ||
| treatPhpDocTypesAsCertain: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| use EXACTSports\Spotify\Facade\SpotifyHttpClient; | ||
| use EXACTSports\Spotify\Request\Dto\TrackToPlaylistDto; | ||
| use EXACTSports\Spotify\Response\BaseSpotifyResponse; | ||
| use EXACTSports\Spotify\Response\ResponseInterface; | ||
|
|
||
| class AddTrackToPlaylistRequest implements RequestInterface | ||
| { | ||
|
|
@@ -16,11 +17,18 @@ public function __construct(private TrackToPlaylistDto $trackToPlaylistDto, priv | |
|
|
||
| public function execute(): BaseSpotifyResponse | ||
| { | ||
| return SpotifyHttpClient::postApiCall( | ||
| $response = SpotifyHttpClient::postApiCall( | ||
| 'v1/playlists/'.$this->trackToPlaylistDto->playlistId.'/tracks', | ||
| $this->headers->toArray(), | ||
| $this->trackToPlaylistDto->toArray() | ||
| ); | ||
| if ($response instanceof BaseSpotifyResponse) { | ||
| return $response; | ||
| } elseif ($response instanceof ResponseInterface) { | ||
| return new BaseSpotifyResponse($response->getData()); | ||
| } else { | ||
| return new BaseSpotifyResponse([]); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should throw an exception here rather than an empty response |
||
| } | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| use EXACTSports\Spotify\Facade\SpotifyHttpClient; | ||
| use EXACTSports\Spotify\Request\Dto\NewPlaylistDto; | ||
| use EXACTSports\Spotify\Response\BaseSpotifyResponse; | ||
| use EXACTSports\Spotify\Response\ResponseInterface; | ||
|
|
||
| class CreateNewPlaylistRequest implements RequestInterface | ||
| { | ||
|
|
@@ -16,11 +17,18 @@ public function __construct(private NewPlaylistDto $newPlaylistDto, private Spot | |
|
|
||
| public function execute(): BaseSpotifyResponse | ||
| { | ||
| return SpotifyHttpClient::postApiCall( | ||
| $response = SpotifyHttpClient::postApiCall( | ||
| 'v1/users/' . $this->newPlaylistDto->spotifyId . '/playlists', | ||
| $this->headers->toArray(), | ||
| $this->newPlaylistDto->toArray() | ||
| ); | ||
| if ($response instanceof BaseSpotifyResponse) { | ||
| return $response; | ||
| } elseif ($response instanceof ResponseInterface) { | ||
| return new BaseSpotifyResponse($response->getData()); | ||
| } else { | ||
| return new BaseSpotifyResponse([]); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal as AddTrackTo.... |
||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| use EXACTSports\Spotify\Client\SpotifyHeaders; | ||
| use EXACTSports\Spotify\Facade\SpotifyHttpClient; | ||
| use EXACTSports\Spotify\Response\BaseSpotifyResponse; | ||
| use EXACTSports\Spotify\Response\ResponseInterface; | ||
|
|
||
| class GetArtistRequest implements RequestInterface | ||
| { | ||
|
|
@@ -17,6 +18,13 @@ public function __construct( | |
| public function execute(): BaseSpotifyResponse | ||
| { | ||
| $endpoint = 'v1/artists/' . $this->id; | ||
| return SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| $response = SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| if ($response instanceof BaseSpotifyResponse) { | ||
| return $response; | ||
| } elseif ($response instanceof ResponseInterface) { | ||
| return new BaseSpotifyResponse($response->getData()); | ||
| } else { | ||
| return new BaseSpotifyResponse([]); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the comment for the other if statements |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| use EXACTSports\Spotify\Client\SpotifyHeaders; | ||
| use EXACTSports\Spotify\Facade\SpotifyHttpClient; | ||
| use EXACTSports\Spotify\Response\BaseSpotifyResponse; | ||
| use EXACTSports\Spotify\Response\ResponseInterface; | ||
|
|
||
| class GetTrackRequest implements RequestInterface | ||
| { | ||
|
|
@@ -17,6 +18,14 @@ public function __construct( | |
| public function execute(): BaseSpotifyResponse | ||
| { | ||
| $endpoint = 'v1/tracks/' . $this->id; | ||
| return SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| $response = SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
|
|
||
| if ($response instanceof BaseSpotifyResponse) { | ||
| return $response; | ||
| } elseif ($response instanceof ResponseInterface) { | ||
| return new BaseSpotifyResponse($response->getData()); | ||
| } else { | ||
| return new BaseSpotifyResponse([]); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| use EXACTSports\Spotify\Facade\SpotifyHttpClient; | ||
| use EXACTSports\Spotify\Request\Dto\SearchTrackRequestDto; | ||
| use EXACTSports\Spotify\Response\BaseSpotifyResponse; | ||
| use EXACTSports\Spotify\Response\ResponseInterface; | ||
|
|
||
| class SearchTrackRequest implements RequestInterface | ||
| { | ||
|
|
@@ -20,6 +21,13 @@ public function execute(): BaseSpotifyResponse | |
| $endpoint = 'v1/search?query=' . $this->requestDto->search . | ||
| '&type=track&limit=' . $this->requestDto->limit . | ||
| '&include_external=' . $this->requestDto->includeExternal; | ||
| return SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| $response = SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| if ($response instanceof BaseSpotifyResponse) { | ||
| return $response; | ||
| } elseif ($response instanceof ResponseInterface) { | ||
| return new BaseSpotifyResponse($response->getData()); | ||
| } else { | ||
| return new BaseSpotifyResponse([]); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| use EXACTSports\Spotify\Facade\SpotifyHttpClient; | ||
| use EXACTSports\Spotify\Request\Dto\TopItemsRequestDto; | ||
| use EXACTSports\Spotify\Response\BaseSpotifyResponse; | ||
| use EXACTSports\Spotify\Response\ResponseInterface; | ||
|
|
||
| class TopItemsRequest implements RequestInterface | ||
| { | ||
|
|
@@ -20,6 +21,13 @@ public function execute(): BaseSpotifyResponse | |
| $endpoint = 'v1/me/top/tracks?limit=' . $this->requestDto->limit . | ||
| '&offset=' . $this->requestDto->offset . | ||
| '&time_range=' . $this->requestDto->timeRange; | ||
| return SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| $response = SpotifyHttpClient::getApiCall($endpoint, $this->headers->toArray()); | ||
| if ($response instanceof BaseSpotifyResponse) { | ||
| return $response; | ||
| } elseif ($response instanceof ResponseInterface) { | ||
| return new BaseSpotifyResponse($response->getData()); | ||
| } else { | ||
| return new BaseSpotifyResponse([]); | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,11 @@ public function __construct(private array $tracks = []) | |
|
|
||
| public function getTracks(): array | ||
| { | ||
| return $this->tracks; | ||
| return $this->tracks; | ||
| } | ||
|
|
||
| public function getData(): array | ||
| { | ||
| return $this->tracks; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. two methods returning same thing? |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since BaseSpotifyResponse implements ResponseInterface, we can change these if statements to just
if $response instanceof ResponseInterface