Webhook
This commit is contained in:
parent
7dc5ded56f
commit
38066dd0cb
|
@ -73,10 +73,13 @@ class Connect
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return json_decode(
|
$response = $client->request($method, $url, $config);
|
||||||
$client->request($method, $url, $config)->getBody(),
|
$body = (string) $response->getBody();
|
||||||
true
|
|
||||||
);
|
if ($response->getStatusCode() !== 200)
|
||||||
|
throw new ConnectException($body);
|
||||||
|
|
||||||
|
return json_decode($body, true);
|
||||||
|
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->deleteAccessToken();
|
$this->deleteAccessToken();
|
||||||
|
@ -271,7 +274,18 @@ class Connect
|
||||||
|
|
||||||
$model = $this->synchronized[$data['connectResourceType']];
|
$model = $this->synchronized[$data['connectResourceType']];
|
||||||
$method = $this->getEventMethod($data['connectEventType']);
|
$method = $this->getEventMethod($data['connectEventType']);
|
||||||
$data = $data['connectResourceData'];
|
|
||||||
|
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);
|
$model::$method($data['id'], $data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue