From 8f0a61e6e13886624c6be1f59aeca7a303b217dc Mon Sep 17 00:00:00 2001 From: Mathieu REHO Date: Tue, 31 Aug 2021 03:27:37 +0200 Subject: [PATCH 1/5] Fixed createShare Added missing `expireDate` parameter Ref.: https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html#create-a-new-share --- src/NextcloudApiWrapper/SharesClient.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NextcloudApiWrapper/SharesClient.php b/src/NextcloudApiWrapper/SharesClient.php index bfc358b..844f08c 100644 --- a/src/NextcloudApiWrapper/SharesClient.php +++ b/src/NextcloudApiWrapper/SharesClient.php @@ -62,7 +62,8 @@ public function createShare(array $params) { ])->setDefaults([ 'publicUpload' => null, 'password' => null, - 'permissions' => null + 'permissions' => null, + 'expireDate' => null ]); }); @@ -94,4 +95,4 @@ public function updateShare($shareid, $key, $value) { $key => $value ]); } -} \ No newline at end of file +} From e2f435bffa1abd9df235d39ca034b137d08dd7a7 Mon Sep 17 00:00:00 2001 From: Mathieu REHO Date: Tue, 31 Aug 2021 06:50:57 +0200 Subject: [PATCH 2/5] Fixed getSharesFromFileOrFolder Fixed broken `getSharesFromFileOrFolder` function --- src/NextcloudApiWrapper/SharesClient.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NextcloudApiWrapper/SharesClient.php b/src/NextcloudApiWrapper/SharesClient.php index 844f08c..7114f81 100644 --- a/src/NextcloudApiWrapper/SharesClient.php +++ b/src/NextcloudApiWrapper/SharesClient.php @@ -20,21 +20,21 @@ public function getAllShares() { /** * Get all shares from a given file/folder * @param $path - * @param array $params, can have keys 'reshares' (bool), 'subfiles' (bool) + * @param array $params, optional, can have keys 'reshares' (bool), 'subfiles' (bool) * @return NextcloudResponse */ - public function getSharesFromFileOrFolder($path, array $params) { + public function getSharesFromFileOrFolder($path, array $params = []) { $params = $this->resolve($params, function(OptionsResolver $resolver) { $resolver->setDefaults([ - 'reshares', - 'subfiles' + 'reshares' => null, + 'subfiles' => null ]); }); $params = array_merge($params, ['path' => $path]); - return $this->connection->request(Connection::GET, self::SHARE_PART . '/' . $this->buildUriParams($params)); + return $this->connection->request(Connection::GET, self::SHARE_PART . $this->buildUriParams($params)); } /** From fe3feb86ce1e7c7a5574fc85ed9c059bbbb4bd98 Mon Sep 17 00:00:00 2001 From: Mathieu REHO Date: Tue, 31 Aug 2021 07:59:38 +0200 Subject: [PATCH 3/5] Fixed `getSharesFromFileOrFolder()`, added field `note` to `updateShare()` --- src/NextcloudApiWrapper/SharesClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NextcloudApiWrapper/SharesClient.php b/src/NextcloudApiWrapper/SharesClient.php index 7114f81..ef06995 100644 --- a/src/NextcloudApiWrapper/SharesClient.php +++ b/src/NextcloudApiWrapper/SharesClient.php @@ -34,7 +34,7 @@ public function getSharesFromFileOrFolder($path, array $params = []) { $params = array_merge($params, ['path' => $path]); - return $this->connection->request(Connection::GET, self::SHARE_PART . $this->buildUriParams($params)); + return $this->connection->pushDataRequest(Connection::GET, self::SHARE_PART . $this->buildUriParams($params)); } /** @@ -89,7 +89,7 @@ public function deleteShare($shareid) { */ public function updateShare($shareid, $key, $value) { - $this->inArray($key, ['permissions', 'password', 'publicUpload', 'expireDate']); + $this->inArray($key, ['permissions', 'password', 'publicUpload', 'expireDate', 'note']); return $this->connection->pushDataRequest(Connection::PUT, self::SHARE_PART . '/' . $shareid, [ $key => $value From e8bf69c63981368cd94e77c1d0d65a8dc0efb784 Mon Sep 17 00:00:00 2001 From: Mathieu REHO Date: Wed, 1 Sep 2021 01:01:30 +0200 Subject: [PATCH 4/5] Fixed `updateShare()` --- src/NextcloudApiWrapper/SharesClient.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NextcloudApiWrapper/SharesClient.php b/src/NextcloudApiWrapper/SharesClient.php index ef06995..d534d61 100644 --- a/src/NextcloudApiWrapper/SharesClient.php +++ b/src/NextcloudApiWrapper/SharesClient.php @@ -27,8 +27,8 @@ public function getSharesFromFileOrFolder($path, array $params = []) { $params = $this->resolve($params, function(OptionsResolver $resolver) { $resolver->setDefaults([ - 'reshares' => null, - 'subfiles' => null + 'reshares' => null, + 'subfiles' => null ]); }); @@ -91,7 +91,7 @@ public function updateShare($shareid, $key, $value) { $this->inArray($key, ['permissions', 'password', 'publicUpload', 'expireDate', 'note']); - return $this->connection->pushDataRequest(Connection::PUT, self::SHARE_PART . '/' . $shareid, [ + return $this->connection->submitRequest(Connection::PUT, self::SHARE_PART . '/' . $shareid, [ $key => $value ]); } From 9111656aedd8df75562236f56a6335274f233c40 Mon Sep 17 00:00:00 2001 From: Mathieu REHO Date: Wed, 1 Sep 2021 01:04:33 +0200 Subject: [PATCH 5/5] `Guzzle` and `Options Resolver` version bump Tested and working as expected on PHP 8.0.9, NC 21 :) --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4af4790..0913d67 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ } ], "require": { - "guzzlehttp/guzzle": "^6.3", - "symfony/options-resolver": "^3.4" + "guzzlehttp/guzzle": "^7.3", + "symfony/options-resolver": "^5.3" }, "autoload": { "psr-4": {"NextcloudApiWrapper\\": "src/NextcloudApiWrapper"}