This commit is contained in:
Maxime Renou 2020-05-12 13:37:30 +02:00
parent 7dc5ded56f
commit 38066dd0cb
1 changed files with 19 additions and 5 deletions

View File

@ -73,10 +73,13 @@ class Connect
}
try {
return json_decode(
$client->request($method, $url, $config)->getBody(),
true
);
$response = $client->request($method, $url, $config);
$body = (string) $response->getBody();
if ($response->getStatusCode() !== 200)
throw new ConnectException($body);
return json_decode($body, true);
} catch(\Exception $e) {
$this->deleteAccessToken();
@ -271,7 +274,18 @@ class Connect
$model = $this->synchronized[$data['connectResourceType']];
$method = $this->getEventMethod($data['connectEventType']);
if ($data['connectEventType'] != 'deleted') {
try {
$data = $this->get($data['connectResourceType'], $data['connectResourceData']['id']);
} catch (\Exception $e) {
abort(404, "Could not retrieve this resource.");
}
}
else {
$data = $data['connectResourceData'];
}
$model::$method($data['id'], $data);
return true;