diff --git a/src/AccessToken.php b/src/AccessToken.php index 9c4c37b..85fb47b 100644 --- a/src/AccessToken.php +++ b/src/AccessToken.php @@ -241,7 +241,7 @@ private static function validateRefreshTokenExpiresIn($responseArray) /** * Specify data format for json_encode() */ - public function jsonSerialize() + public function jsonSerialize(): mixed { return [ 'token' => $this->getToken(), diff --git a/src/Client.php b/src/Client.php index 9d1edc7..315c335 100644 --- a/src/Client.php +++ b/src/Client.php @@ -597,6 +597,38 @@ public function delete($endpoint, array $params = []) return $this->api($endpoint, $params, Method::DELETE); } + /** + * Make API call to LinkedIn using PUT method + * + * @param string $endpoint + * @param resource $resource + * + * @return array + * @throws \LinkedIn\Exception + */ + public function put($endpoint, $resource) + { + if (false === is_resource($resource)) { + throw new \InvalidArgumentException( + sprintf('Argument must be a valid resource type. %s given.', gettype($resource)) + ); + } + + try { + (new GuzzleClient())->put( + $endpoint, + [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $this->accessToken->getToken() + ], + 'body' => $resource + ] + ); + } catch (RequestException $requestException) { + throw Exception::fromRequestException($requestException); + } + } + /** * @param $path * @return array