mirror of
https://github.com/kevin-DL/scraps.git
synced 2026-01-12 02:05:14 +00:00
Create spoonacular integration
- Find recipes by ingredients
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user