From 787e38a69037a2df2c3e9c1890e5a4ba19485323 Mon Sep 17 00:00:00 2001 From: fu Date: Tue, 30 Dec 2025 15:36:24 +0800 Subject: [PATCH 1/2] feat: withoutQuery --- src/http-client/src/Request.php | 11 +++++++++++ tests/ApiClient/ApiRequestTest.php | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/http-client/src/Request.php b/src/http-client/src/Request.php index 0c5339df2..8bc3f0de8 100644 --- a/src/http-client/src/Request.php +++ b/src/http-client/src/Request.php @@ -214,6 +214,17 @@ public function withQuery(array $query = []): Request return $this; } + public function withoutQuery(array $keys = []): Request + { + $query = $this->query(); + foreach ($keys as $key) { + unset($query[$key]); + } + $this->request = $this->request->withUri($this->request->getUri()->withQuery(http_build_query($query))); + + return $this; + } + /** * Get the underlying PSR compliant request instance. */ diff --git a/tests/ApiClient/ApiRequestTest.php b/tests/ApiClient/ApiRequestTest.php index 45d32877b..3ebfef431 100644 --- a/tests/ApiClient/ApiRequestTest.php +++ b/tests/ApiClient/ApiRequestTest.php @@ -183,4 +183,13 @@ public function testWithQuery(): void $this->assertSame('param1=value1¶m2=value2', $request->toPsrRequest()->getUri()->getQuery()); } + + public function testWithoutQuery(): void + { + + $request = $this->request->withQuery(['param1' => 'value1', 'param2' => 'value2']); + $request->withoutQuery(['param1']); + + $this->assertSame('param2=value2', $request->toPsrRequest()->getUri()->getQuery()); + } } From 891f57759285a532a2c809bafd7f7e3446788ace Mon Sep 17 00:00:00 2001 From: fu Date: Tue, 30 Dec 2025 16:23:10 +0800 Subject: [PATCH 2/2] style: lint --- tests/ApiClient/ApiRequestTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ApiClient/ApiRequestTest.php b/tests/ApiClient/ApiRequestTest.php index 3ebfef431..c1ed00038 100644 --- a/tests/ApiClient/ApiRequestTest.php +++ b/tests/ApiClient/ApiRequestTest.php @@ -186,7 +186,6 @@ public function testWithQuery(): void public function testWithoutQuery(): void { - $request = $this->request->withQuery(['param1' => 'value1', 'param2' => 'value2']); $request->withoutQuery(['param1']);