diff --git a/libraries/joomla/github/issues.php b/libraries/joomla/github/issues.php index b844779cff..0c3e42028c 100644 --- a/libraries/joomla/github/issues.php +++ b/libraries/joomla/github/issues.php @@ -349,6 +349,65 @@ public function getComments($user, $repo, $issueId, $page = 0, $limit = 0) return json_decode($response->body); } + /** + * Method to get a specific label on an repo. + * + * @param string $user The name of the owner of the GitHub repository. + * @param string $repo The name of the GitHub repository. + * @param string $name The label name to get. + * + * @return object + * + * @since 12.1 + */ + public function getLabel($user, $repo, $name) + { + // Build the request path. + $path = '/repos/' . $user . '/' . $repo . '/labels/' . $name; + + // Send the request. + $response = $this->client->get($this->fetchUrl($path)); + + // Validate the response code. + if ($response->code != 200) + { + // Decode the error response and throw an exception. + $error = json_decode($response->body); + throw new DomainException($error->message, $response->code); + } + + return json_decode($response->body); + } + + /** + * Method to get the list of labels on an issue. + * + * @param string $user The name of the owner of the GitHub repository. + * @param string $repo The name of the GitHub repository. + * + * @return array + * + * @since 12.1 + */ + public function getLabels($user, $repo) + { + // Build the request path. + $path = '/repos/' . $user . '/' . $repo . '/labels/'; + + // Send the request. + $response = $this->client->get($this->fetchUrl($path)); + + // Validate the response code. + if ($response->code != 200) + { + // Decode the error response and throw an exception. + $error = json_decode($response->body); + throw new DomainException($error->message, $response->code); + } + + return json_decode($response->body); + } + /** * Method to list an authenticated user's issues. *