lesstif / php-jira-rest-client

PHP classes interact Jira with the REST API.
Other
510 stars 261 forks source link

IssueService::getCustomFields() does not get custom fields #526

Closed AlexHowansky closed 6 months ago

AlexHowansky commented 7 months ago

The method IssueService::getCustomFields() appears to have been cut-and-pasted from the immediate preceding method getPriority(). It takes the wrong arguments, hits the wrong endpoint, and returns the wrong data. It looks like it should be hitting the field endpoint instead:

--- a/src/Issue/IssueService.php
+++ b/src/Issue/IssueService.php
@@ -831,7 +831,7 @@ class IssueService extends \JiraRestApi\JiraClient
      */
     public function getCustomFields(int $priorityId): Priority
     {
-        $ret = $this->exec("priority/$priorityId", null);
+        $ret = $this->exec('field');

         $this->log->info('Result='.$ret);

There is likely also a change that needs to be made to the subsequent json_mapper call, but I am not entirely sure what that should look like.

lesstif commented 6 months ago

Hi @AlexHowansky sorry for to late reply. I've released a new version and you can call this function like below.

$iss = new IssueService();

$paramArray = [
    'startAt' => 1,
    'maxResults' => 50,
    'search' => null,
    'projectIds' => [1, 2, 3],
    'screenIds' => null,
    'types' => null,

    'sortOrder' => null,
    'sortColumn' => null,
    'lastValueUpdate' => null,
];
$customerFieldSearchResult = $iss->getCustomFields($paramArray);

// all custom fields
var_dump($customerFieldSearchResult->values);