jikan-rest/app/Features/QueryRecommendationsHandler.php
pushrbx 49ebc8f581 wip - mediator refactor
- anime schedules - validation and corrections
- refactorings around "augmentResponse" - macro usage instead
2023-05-21 11:14:34 +01:00

31 lines
989 B
PHP

<?php
namespace App\Features;
use App\Contracts\DataRequest;
use App\Http\Resources\V4\ResultsResource;
use Illuminate\Support\Collection;
use App\Support\CachedData;
use Jikan\MyAnimeList\MalClient;
use Jikan\Request\Recommendations\RecentRecommendationsRequest;
/**
* @template TRequest of DataRequest<ResultsResource>
* @extends RequestHandlerWithScraperCache<TRequest, ResultsResource>
*/
abstract class QueryRecommendationsHandler extends RequestHandlerWithScraperCache
{
protected abstract function recommendationType(): string;
protected function getScraperData(string $requestFingerPrint, Collection $requestParams): CachedData
{
return $this->scraperService->findList(
$requestFingerPrint,
fn(MalClient $jikan, ?int $page = null) => $jikan->getRecentRecommendations(new RecentRecommendationsRequest(
$this->recommendationType(), $page
)),
$requestParams->get("page", 1)
);
}
}