diff --git a/src/Keys.php b/src/Keys.php index fc7b0008..4327f7dc 100644 --- a/src/Keys.php +++ b/src/Keys.php @@ -58,7 +58,7 @@ public function generateScopedSearchKey( string $searchKey, array $parameters ): string { - $paramStr = json_encode($parameters, JSON_THROW_ON_ERROR); + $paramStr = json_encode((object)$parameters, JSON_THROW_ON_ERROR); $digest = base64_encode( hash_hmac( 'sha256', diff --git a/tests/Feature/KeysTest.php b/tests/Feature/KeysTest.php index 658d0393..24783383 100644 --- a/tests/Feature/KeysTest.php +++ b/tests/Feature/KeysTest.php @@ -73,4 +73,13 @@ public function testCanGenerateScopedSearchKey(): void ]); $this->assertEquals($scopedSearchKey, $result); } + + public function testGenerateScopedSearchKeyWithoutParams(): void + { + $searchKey = "RN23GFr1s6jQ9kgSNg2O7fYcAUXU7127"; + $scopedSearchKey = + "R2pFZkxSemhGZmEvOXd2WWpYNWVSTzF2N2xRSk9jQmlpZ2NpdnloUTFGYz1STjIze30="; + $result = $this->client()->keys->generateScopedSearchKey($searchKey, []); + $this->assertEquals($scopedSearchKey, $result); + } }