public function ContentHubCommonActions::requestRemoteEntity in Acquia Content Hub 8.2
Request a Remote Entity via Webhook.
Parameters
string $webhook_url: Webhook url.
string $uri: File URI requested.
string $uuid: UUID of file entity.
string $scheme: File scheme.
Return value
string File as a stream.
Throws
\GuzzleHttp\Exception\GuzzleException
File
- src/
ContentHubCommonActions.php, line 485
Class
- ContentHubCommonActions
- Common actions across the entirety of Content Hub.
Namespace
Drupal\acquia_contenthubCode
public function requestRemoteEntity(string $webhook_url, string $uri, string $uuid, string $scheme) {
$url = $webhook_url;
$settings = $this->factory
->getClient()
->getSettings();
$remote_settings = new Settings("getFile", $settings
->getUuid(), $settings
->getApiKey(), $settings
->getSecretKey(), $url, $settings
->getSharedSecret(), [
"uuid" => $settings
->getWebhook('uuid'),
"url" => $settings
->getWebhook('url'),
"settings_url" => $settings
->getWebhook(),
]);
$client = $this->factory
->getClient($remote_settings);
$cdf = [
'uri' => $uri,
'uuid' => $uuid,
'scheme' => $scheme,
];
$payload = [
'status' => 'successful',
'uuid' => $uuid,
'crud' => 'getFile',
'initiator' => $remote_settings
->getUuid(),
'cdf' => $cdf,
];
$response = $client
->request('post', $url, [
'body' => json_encode($payload),
]);
return (string) $response
->getBody();
}