mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fix request to France Travail Api to accomodate for new request limit
A new limit was set to allow a maximum amount of request in a certain timeframe. We need to wait 1 sec to make next request.
This commit is contained in:
parent
00ceee1fd5
commit
b100792a34
@ -87,20 +87,27 @@ class PartenaireRomeAppellation
|
|||||||
{
|
{
|
||||||
$bearer = $this->getBearer();
|
$bearer = $this->getBearer();
|
||||||
|
|
||||||
try {
|
while (true) {
|
||||||
$response = $this->httpClient->request('GET', sprintf(self::BASE.'appellation/%s', $code), [
|
try {
|
||||||
'headers' => [
|
$response = $this->httpClient->request('GET', sprintf(self::BASE.'appellation/%s', $code), [
|
||||||
'Authorization' => 'Bearer '.$bearer,
|
'headers' => [
|
||||||
'Accept' => 'application/json',
|
'Authorization' => 'Bearer ' . $bearer,
|
||||||
],
|
'Accept' => 'application/json',
|
||||||
'query' => [
|
],
|
||||||
'champs' => 'code,libelle,metier(code,libelle)',
|
'query' => [
|
||||||
],
|
'champs' => 'code,libelle,metier(code,libelle)',
|
||||||
]);
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
return $response->toArray();
|
return $response->toArray();
|
||||||
} catch (HttpExceptionInterface $exception) {
|
} catch (HttpExceptionInterface $exception) {
|
||||||
throw $exception;
|
if ($exception->getResponse()->getStatusCode() === 429) {
|
||||||
|
$retryAfter = $exception->getResponse()->getHeaders(false)['retry-after'][0] ?? 1;
|
||||||
|
sleep((int)$retryAfter);
|
||||||
|
} else {
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user