Skip to content

Commit

Permalink
Allow specification of custom base URL
Browse files Browse the repository at this point in the history
  • Loading branch information
NateShoffner committed Dec 11, 2021
1 parent 3d3f7f1 commit b994000
Show file tree
Hide file tree
Showing 50 changed files with 155 additions and 146 deletions.
4 changes: 2 additions & 2 deletions request/Anime/AnimeCharactersAndStaffRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/characters_staff', $this->id);
return sprintf('%s/anime/%d/characters_staff', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeEpisodesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/episodes/%d', $this->id, $this->page);
return sprintf('%s/anime/%d/episodes/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeForumRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public function __construct(int $id, ?string $topic = null)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
$query = '';
if ($this->topic !== null && \in_array($this->topic, self::$validTypes, true)) {
$query = '?'.http_build_query(['topic' => $this->topic]);
}

// TODO: add support for filtering once it's added in the REST API
return sprintf(Constants::BASE_URL.'/anime/%d/forum', $this->id);
return sprintf('%s/anime/%d/forum', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeMoreInfoRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%s/moreinfo', $this->id);
return sprintf('%s/anime/%s/moreinfo', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeNewsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/news', $this->id);
return sprintf('%s/anime/%d/news', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimePicturesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/pictures', $this->id);
return sprintf('%s/anime/%d/pictures', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeRecentlyUpdatedByUsersRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/userupdates/%d', $this->id, $this->page);
return sprintf('%s/anime/%d/userupdates/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeRecommendationsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/recommendations', $this->id);
return sprintf('%s/anime/%d/recommendations', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d', $this->id);
return sprintf('%s/anime/%d', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeReviewsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/reviews/%d', $this->id, $this->page);
return sprintf('%s/anime/%d/reviews/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeStatsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/stats', $this->id);
return sprintf('%s/anime/%d/stats', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Anime/AnimeVideosRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/anime/%d/videos', $this->id);
return sprintf('%s/anime/%d/videos', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Character/CharacterPicturesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/character/%d/pictures', $this->id);
return sprintf('%s/character/%d/pictures', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Character/CharacterRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct(int $id)
*
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/character/%d', $this->id);
return sprintf('%s/character/%d', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Club/ClubRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function __construct(int $clubId)
*
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/club/%d', $this->clubId);
return sprintf('%s/club/%d', $baseUrl, $this->clubId);
}
}
4 changes: 2 additions & 2 deletions request/Club/UserListRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function __construct(int $clubId, int $page = 1)
*
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/club/%d/members/%d', $this->clubId, $this->page);
return sprintf('%s/club/%d/members/%d', $baseUrl, $this->clubId, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Genre/AnimeGenreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/genre/anime/%d/%d', $this->id, $this->page);
return sprintf('%s/genre/anime/%d/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Genre/MangaGenreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/genre/manga/%d/%d', $this->id, $this->page);
return sprintf('%s/genre/manga/%d/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Magazine/MagazineRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/magazine/%d/%d', $this->id, $this->page);
return sprintf('%s/magazine/%d/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaCharactersRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/characters', $this->id);
return sprintf('%s/manga/%d/characters', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaForumRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function __construct(int $id, ?string $topic = null)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
// TODO: add support for filtering once it's added in the REST API
return sprintf(Constants::BASE_URL.'/manga/%d/forum', $this->id);
return sprintf('%s/manga/%d/forum', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaMoreInfoRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/moreinfo', $this->id);
return sprintf('%s/manga/%d/moreinfo', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaNewsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/news', $this->id);
return sprintf('%s/manga/%d/news', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaPicturesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/pictures', $this->id);
return sprintf('%s/manga/%d/pictures', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaRecentlyUpdatedByUsersRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/userupdates/%d', $this->id, $this->page);
return sprintf('%s/manga/%d/userupdates/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaRecommendationsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/recommendations', $this->id);
return sprintf('%s/manga/%d/recommendations', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d', $this->id);
return sprintf('%s/manga/%d', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaReviewsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/reviews/%d', $this->id, $this->page);
return sprintf('%s/manga/%d/reviews/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 2 additions & 2 deletions request/Manga/MangaStatsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/manga/%d/stats', $this->id);
return sprintf('%s/manga/%d/stats', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Person/PersonPicturesRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(int $id)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/person/%d/pictures', $this->id);
return sprintf('%s/person/%d/pictures', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Person/PersonRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function __construct(int $id)
*
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/person/%d', $this->id);
return sprintf('%s/person/%d', $baseUrl, $this->id);
}
}
4 changes: 2 additions & 2 deletions request/Producer/ProducerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(int $id, int $page = 1)
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return sprintf(Constants::BASE_URL.'/producer/%d/%d', $this->id, $this->page);
return sprintf('%s/producer/%d/%d', $baseUrl, $this->id, $this->page);
}
}
4 changes: 3 additions & 1 deletion request/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ interface RequestInterface
/**
* Get the path to request
*
* @param string $baseUrl
*
* @return string
*/
public function getPath(): string;
public function getPath(string $baseUrl): string;
}
4 changes: 2 additions & 2 deletions request/Schedule/ScheduleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ScheduleRequest implements RequestInterface
/**
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{
return Constants::BASE_URL.'/schedule';
return sprintf('%s/schedule', $baseUrl);
}
}
4 changes: 2 additions & 2 deletions request/Search/AnimeSearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function __construct(?string $query = null, int $page = 1)
*
* @return string
*/
public function getPath(): string
public function getPath($baseUrl): string
{

// todo add `limit` (int)
Expand All @@ -124,7 +124,7 @@ public function getPath(): string
}
}

return Constants::BASE_URL.'/search/anime?'.$query;
return sprintf('%s/search/anime?%s', $baseUrl, $query);
}

/**
Expand Down
Loading

0 comments on commit b994000

Please sign in to comment.