Merge branch 'add-project-api' into 'master'
Added function to search for Tickets in OpenProject See merge request fronk/thetool!824
This commit is contained in:
@@ -50,5 +50,42 @@ class XinonProject {
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search for support tickets using a global search in Xinon OpenProject.
|
||||
* @param string $search - The search query.
|
||||
* @param int $pageSize - The number of results to return.
|
||||
* @return array - The search results.
|
||||
*/
|
||||
public function searchSupportTickets(string $search, int $pageSize = 25): array {
|
||||
$curl = curl_init();
|
||||
|
||||
$baseUrl = 'https://project.xinon.at/api/v3/projects/10/work_packages';
|
||||
$queryParams = [
|
||||
'pageSize' => 25,
|
||||
'filters' => json_encode([['search' => ['operator' => '**', 'values' => [$search]]]])
|
||||
];
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $baseUrl . '?' . http_build_query($queryParams),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
|
||||
CURLOPT_USERPWD => 'apikey:' . PROJECT_API_KEY
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$json = json_decode($response, true);
|
||||
|
||||
return $json['_embedded']['elements'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user