Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Method to create new label

  • Loading branch information...
commit 612eedbb2cbc0b29362f7e668943afe230f9ee1f 1 parent 6d6c331
@nprasath002 authored
Showing with 39 additions and 0 deletions.
  1. +39 −0 libraries/joomla/github/issues.php
View
39 libraries/joomla/github/issues.php
@@ -108,6 +108,45 @@ public function createComment($user, $repo, $issueId, $body)
}
/**
+ * Method to create a label on a 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.
+ * @param string $color The label color.
+ *
+ * @return object
+ *
+ * @since 12.1
+ */
+ public function createLabel($user, $repo, $name, $color)
+ {
+ // Build the request path.
+ $path = '/repos/' . $user . '/' . $repo . '/labels';
+
+ // Build the request data.
+ $data = json_encode(
+ array(
+ 'name' => $name,
+ 'color' => $color
+ )
+ );
+
+ // Send the request.
+ $response = $this->client->post($this->fetchUrl($path), $data);
+
+ // Validate the response code.
+ if ($response->code != 201)
+ {
+ // 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 delete a comment on an issue.
*
* @param string $user The name of the owner of the GitHub repository.
Please sign in to comment.
Something went wrong with that request. Please try again.