diff --git a/README.md b/README.md index ef1ee61..a69be2e 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ $iss = new IssueService(new ArrayConfiguration( - [Delete Project](#delete-project) - [Get Project Info](#get-project-info) - [Get All Project list](#get-all-project-list) +- [Get Project Components](#get-project-components) - [Get Project Type](#get-project-type) - [Get Project Version](#get-project-version) @@ -377,6 +378,32 @@ try { ``` +#### Get Project Components + +[See Jira API reference (Get project components)](https://docs.atlassian.com/software/jira/docs/api/REST/latest/#project-getProjectComponents) + +```php +getAllProjects(); + + // Extract and show Project Components for every Jira Project + foreach ($prjs as $p) { + var_export($proj->getProjectComponents($p->id)); + } +} catch (JiraRestApi\JiraException $e) { + print("Error Occured! " . $e->getMessage()); +} + +``` + #### Get Project type [See Jira API reference (get all types)](https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/project/type-getAllProjectTypes) diff --git a/src/Project/ProjectService.php b/src/Project/ProjectService.php index 22d6493..c261849 100644 --- a/src/Project/ProjectService.php +++ b/src/Project/ProjectService.php @@ -2,6 +2,7 @@ namespace JiraRestApi\Project; +use JiraRestApi\Component\Component; use JiraRestApi\Issue\IssueType; use JiraRestApi\Issue\Reporter; use JiraRestApi\Issue\Version; @@ -97,6 +98,26 @@ public function getStatuses($projectIdOrKey) return $results; } + /** + * Get the Components defined in a Jira Project. + * + * @param string|int $projectIdOrKey + * + * @throws \JiraRestApi\JiraException + * + * @return \JiraRestApi\Component\Component[] + */ + public function getProjectComponents($projectIdOrKey) + { + $ret = $this->exec($this->uri."/$projectIdOrKey/components", null); + $json = json_decode($ret); + $results = array_map(function ($elem) { + return $this->json_mapper->map($elem, new Component()); + }, $json); + + return $results; + } + /** * make transition info array for project issue transition. *