Webhook
This commit is contained in:
parent
7dc5ded56f
commit
38066dd0cb
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue