Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some documentation, return type for createIssue() changed
  • Loading branch information
fmancardi committed Dec 1, 2013
commit c94ec8e47f31f9c2b89e7d5be8506b50e8a6fa8d
67 changes: 61 additions & 6 deletions src/JiraApi/Jira.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* JIRA Rest Client
*
* @author Original Author https://github.com/FayP / http://faypickering.com
* @author Francisco Mancardi <francisco.mancardi@gmail.com>
*/

namespace JiraApi;

Expand All @@ -25,6 +31,9 @@ public function __construct(array $config = array())

}

/**
*
*/
private function configCheck()
{
if(is_null($this->host) || $this->host == '')
Expand All @@ -41,6 +50,9 @@ private function configCheck()
}
}

/**
*
*/
public function testLogin()
{
$user = $this->getUser($this->request->username);
Expand All @@ -51,6 +63,9 @@ public function testLogin()
return false;
}

/**
*
*/
public function getUser($username)
{
$this->request->openConnect($this->host . 'user/search/?username=' . $username, 'GET');
Expand All @@ -60,6 +75,9 @@ public function getUser($username)
return $user;
}

/**
*
*/
public function getStatuses()
{
$this->request->openConnect($this->host . 'status', 'GET');
Expand Down Expand Up @@ -156,14 +174,46 @@ function createPairs($obj) {
return false;
}

public function createIssue($json)
/**
*
* @param array $issueFields using 'fields' member
*
* Here's an example:
*
* $issueFields = array('fields' =>
* array('project' => array('key' => (string)'ZOFF'),
* 'summary' => 'My First JIRA Issue via REST',
* 'description' => '',
* 'issuetype' => array( 'id' => 1)
* )
* );
*
* For more details about fields:
* https://developer.atlassian.com/display/JIRADEV/
* JIRA+REST+API+Example+-+Create+Issue#JIRARESTAPIExample-CreateIssue-Examplesofcreatinganissue
*
* https://developer.atlassian.com/display/JIRADEV/
* JIRA+REST+API+Example+-+Discovering+meta-data+for+creating+issues
*
*
* @return object reponse body (ATTENTION: can be null if something wrong has happened)
* properties: id,key,self
* Example:
* {"id":"12505","key":"ZOFF-186","self":"https://testlink.atlassian.net/rest/api/latest/issue/12505"}
*
*/
public function createIssue($issueFields)
{
$this->request->openConnect($this->host . 'issue/', 'POST', $json);
$this->request->openConnect($this->host . 'issue/', 'POST', $issueFields);
$this->request->execute();

return $this->request->lastRequestStatus();
return json_decode($this->request->getResponseBody());
}

/**
*
*
*/
public function addAttachment($filename, $issueKey)
{
$this->request->openConnect($this->host . 'issue/' . $issueKey . '/attachments', 'POST', null, $filename);
Expand All @@ -172,9 +222,14 @@ public function addAttachment($filename, $issueKey)
return $this->request->lastRequestStatus();
}

public function updateIssue($json, $issueKey)
/**
*
* @param array $issueFields using 'fields' member
*
*/
public function updateIssue($issueFields, $issueKey)
{
$this->request->openConnect($this->host . 'issue/' . $issueKey, 'PUT', $json);
$this->request->openConnect($this->host . 'issue/' . $issueKey, 'PUT', $issueFields);
$this->request->execute();

return $this->request->lastRequestStatus();
Expand Down Expand Up @@ -210,4 +265,4 @@ public function getIssue($issueKey)

return $item;
}
}
}