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();
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('GET', sprintf(self::BASE.'appellation/%s', $code), [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer '.$bearer,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'query' => [
|
||||
'champs' => 'code,libelle,metier(code,libelle)',
|
||||
],
|
||||
]);
|
||||
while (true) {
|
||||
try {
|
||||
$response = $this->httpClient->request('GET', sprintf(self::BASE.'appellation/%s', $code), [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . $bearer,
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'query' => [
|
||||
'champs' => 'code,libelle,metier(code,libelle)',
|
||||
],
|
||||
]);
|
||||
|
||||
return $response->toArray();
|
||||
} catch (HttpExceptionInterface $exception) {
|
||||
throw $exception;
|
||||
return $response->toArray();
|
||||
} catch (HttpExceptionInterface $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