mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
- updated api docs - fixed top reviews endpoint - fixed reviews parsing - added "contextual" boolean query string parameters, so params without value can be interpreted as "boolean". E.g. ?sfw or ?kid in the url would add "true" value to their corresponding field in the DTO - fixed typesense issues
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Features;
|
|
|
|
use App\Dto\QueryTopReviewsCommand;
|
|
use App\Enums\TopReviewsTypeEnum;
|
|
use App\Support\CachedData;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Support\Collection;
|
|
use Jikan\Helper\Constants;
|
|
use Jikan\MyAnimeList\MalClient;
|
|
use Jikan\Request\Reviews\ReviewsRequest;
|
|
|
|
/**
|
|
* @extends RequestHandlerWithScraperCache<QueryTopReviewsCommand, JsonResponse>
|
|
*/
|
|
final class QueryTopReviewsHandler extends RequestHandlerWithScraperCache
|
|
{
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function requestClass(): string
|
|
{
|
|
return QueryTopReviewsCommand::class;
|
|
}
|
|
|
|
protected function getScraperData(string $requestFingerPrint, Collection $requestParams): CachedData
|
|
{
|
|
$type = $requestParams->get("type", TopReviewsTypeEnum::anime()->value);
|
|
$spoilers = $requestParams->get("spoilers", true);
|
|
$preliminary = $requestParams->get("preliminary", true);
|
|
return $this->scraperService->findList(
|
|
$requestFingerPrint,
|
|
fn (MalClient $jikan, ?int $page = null) => $jikan->getReviews(new ReviewsRequest($type, $page, $spoilers, $preliminary)),
|
|
$requestParams->get("page"));
|
|
}
|
|
}
|