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,49 @@
<?php
namespace App\Http\Integrations\Spoonacular;
use Saloon\Http\Auth\QueryAuthenticator;
use Saloon\Http\Connector;
use Saloon\Traits\Plugins\AcceptsJson;
class SpoonacularConnector extends Connector
{
use AcceptsJson;
/**
* The Base URL of the API
*/
public function resolveBaseUrl(): string
{
return config('services.spoonacular.api_url');
}
/**
* Default headers for every request
*/
protected function defaultHeaders(): array
{
return [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
];
}
/**
* Default HTTP client options
*/
protected function defaultConfig(): array
{
return [];
}
protected function defaultQuery(): array
{
return [];
}
protected function defaultAuth(): QueryAuthenticator
{
return new QueryAuthenticator('apiKey', config('services.spoonacular.api_key'));
}
}