$endpoint =
sprintf('https://%s/v1/events/trigger',
$this->
getEndpoint());
$response =
$this->client->
request('POST',
$endpoint,
[ 'body' =>
$body,
'headers' =>
[ 'Authorization' =>
sprintf('ApiKey %s',
$this->apiKey
),
'Content-Type' => 'application/json',
],
]);
try { $statusCode =
$response->
getStatusCode();
} catch (TransportExceptionInterface
$e) { throw new TransportException('Could not reach the remote Novu server.',
$response, 0,
$e);
} if (201 !==
$statusCode) { $originalContent =
$message->
getSubject();
$result =
$response->
toArray(false
);
$error =
$result['message'
];
throw new TransportException(sprintf('Unable to post the Novu message: "%s" (%d: "%s").',
$originalContent,
$statusCode,
$error),
$response);
}