Create spoonacular integration

- Find recipes by ingredients
This commit is contained in:
2024-06-22 11:13:14 +01:00
parent 50fc714895
commit fadb1bc00a
8 changed files with 312 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?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,
];
}
}