Files
scraps/app/Http/Integrations/Spoonacular/Requests/FindRecipesByIngredients.php
kevin-DL fadb1bc00a Create spoonacular integration
- Find recipes by ingredients
2024-06-22 11:13:14 +01:00

40 lines
802 B
PHP

<?php
namespace App\Http\Integrations\Spoonacular\Requests;
use Saloon\Enums\Method;
use Saloon\Http\Request;
class FindRecipesByIngredients extends Request
{
/**
* The HTTP method of the request
*/
protected Method $method = Method::GET;
public function __construct(
protected array $ingredients,
protected int $ranking = 1,
protected int $number = 10
)
{
}
/**
* The endpoint for the request
*/
public function resolveEndpoint(): string
{
return '/recipes/findByIngredients';
}
public function defaultQuery(): array
{
return [
'ingredients' => join(",", $this->ingredients),
'ranking' => $this->ranking,
'number' => $this->number,
];
}
}