if (!
$message instanceof ChatMessage
) { throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::
class,
$message);
} if (($options =
$message->
getOptions()) && !
$options instanceof LinkedInOptions
) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, LinkedInOptions::
class));
} if (!
$options &&
$notification =
$message->
getNotification()) { $options = LinkedInOptions::
fromNotification($notification);
$options->
author(new AuthorShare($this->accountId
));
} $endpoint =
sprintf('https://%s/v2/ugcPosts',
$this->
getEndpoint());
$response =
$this->client->
request('POST',
$endpoint,
[ 'auth_bearer' =>
$this->authToken,
'headers' =>
['X-Restli-Protocol-Version' => '2.0.0'
],
'json' =>
array_filter($options?->
toArray() ??
$this->
bodyFromMessageWithNoOption($message)),
]);
try {