Client PHP minimal
<?php
class TsImmoClient
{
public function __construct(private string $apiKey, private string $baseUrl = 'https://api.ts-immo.org') {}
public function listings(array $params = []): array
{
$query = http_build_query($params);
$url = "{$this->baseUrl}/v1/listings?{$query}";
$ctx = stream_context_create([
'http' => [
'header' => "Authorization: Bearer {$this->apiKey}\r\n",
],
]);
$body = file_get_contents($url, false, $ctx);
return json_decode($body, true);
}
}Laravel — Service Provider + cache
Encapsuler le client dans un Service Provider et utiliser Cache::remember() pour économiser les appels API.