From 0918ff1cae21dc809d908afe55ae8b8344ef40f8 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Thu, 17 Feb 2022 17:13:36 +0545 Subject: [PATCH] construct filters from array (#48) Signed-off-by: Artur Neumann --- lib/Service/OpenProjectAPIService.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Service/OpenProjectAPIService.php b/lib/Service/OpenProjectAPIService.php index 9e5ebd7ac..1935c6d42 100644 --- a/lib/Service/OpenProjectAPIService.php +++ b/lib/Service/OpenProjectAPIService.php @@ -244,6 +244,7 @@ public function getNotifications(string $url, string $accessToken, string $authT * @param int $offset * @param int $limit * @return array + * @throws \Safe\Exceptions\JsonException */ public function searchWorkPackage(string $url, string $accessToken, string $authType, string $refreshToken, string $clientID, string $clientSecret, string $userId, @@ -251,8 +252,12 @@ public function searchWorkPackage(string $url, string $accessToken, string $auth $resultsById = []; // search by description + $filters = [ + ["description" => ["operator" => "~", "values" => [$query]]], + ["status" => ["operator" => "!", "values" => ["14"]]] + ]; $params = [ - 'filters' => '[{"description":{"operator":"~","values":["' . $query . '"]}},{"status":{"operator":"!","values":["14"]}}]', + 'filters' => \Safe\json_encode($filters), 'sortBy' => '[["updatedAt", "desc"]]', // 'limit' => $limit, ]; @@ -266,8 +271,12 @@ public function searchWorkPackage(string $url, string $accessToken, string $auth } } // search by subject + $filters = [ + ["subject" => ["operator" => "~", "values" => [$query]]], + ["status" => ["operator" => "!", "values" => ["14"]]] + ]; $params = [ - 'filters' => '[{"subject":{"operator":"~","values":["' . $query . '"]}},{"status":{"operator":"!","values":["14"]}}]', + 'filters' => \Safe\json_encode($filters), 'sortBy' => '[["updatedAt", "desc"]]', // 'limit' => $limit, ];