Skip to content

Commit 62df453

Browse files
committed
readme
1 parent 162a042 commit 62df453

File tree

6 files changed

+138
-13
lines changed

6 files changed

+138
-13
lines changed

README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
2+
# Installation
3+
4+
```
5+
composer require lesstif/php-jira-rest-client dev-master
6+
```
7+
8+
create config.jira.php file on your project root.
9+
````php
10+
<?php
11+
12+
/*
13+
* Description get Jira Host Configuration
14+
*
15+
* @return array
16+
*/
17+
function getHostConfig() {
18+
$jira_config = array ('host' => 'https://jira.example.com',
19+
'username' => 'username',
20+
'password' => 'secure_passwd');
21+
22+
return $jira_config;
23+
}
24+
25+
/**
26+
* Description get Client options
27+
*
28+
* @return array
29+
*/
30+
function getOptions() {
31+
$options = array(
32+
CURLOPT_SSL_VERIFYHOST => 0,
33+
CURLOPT_SSL_VERIFYPEER => 0,
34+
CURLOPT_VERBOSE => false,
35+
'LOG_FILE' => 'jira-rest-client.log',
36+
'LOG_LEVEL' => \Monolog\Logger::INFO
37+
);
38+
39+
return $options;
40+
}
41+
?>
42+
````
43+
44+
# Usage
45+
46+
## Get Project Info
47+
48+
````php
49+
try {
50+
$proj = new ProjectService();
51+
52+
$p = $proj->get('TEST');
53+
54+
print_r($p);
55+
} catch (HTTPException $e) {
56+
print("Error Occured! " . $e->getMessage());
57+
}
58+
````
59+
60+
## Get All Project list
61+
````php
62+
try {
63+
$proj = new ProjectService();
64+
65+
$prjs = $proj->getAllProjects();
66+
67+
$i = 0;
68+
foreach ($prjs as $p) {
69+
echo sprintf("Project Key:%s, Id:%s, Name:%s, projectCategory: %s\n",
70+
$p->key, $p->id, $p->name, $p->projectCategory['name']
71+
);
72+
73+
}
74+
} catch (HTTPException $e) {
75+
print("Error Occured! " . $e->getMessage());
76+
}
77+
````
78+
79+
## Get Issue Info
80+
81+
````php
82+
try {
83+
$issueService = new IssueService();
84+
85+
$issue = $issueService->get('TEST-867');
86+
87+
print_r($issue->fields);
88+
} catch (HTTPException $e) {
89+
print("Error Occured! " . $e->getMessage());
90+
}
91+
````
92+
93+
## Create Issue
94+
95+
````php
96+
try {
97+
$issueField = new IssueField();
98+
$issueField->setProjectId("12000");
99+
$issueField->setSummary("something's wrong");
100+
$issueField->setAssigneeName("lesstif");
101+
$issueField->setPriorityName("Critical");
102+
$issueField->setIssueType("Bug");
103+
$issueField->setDescription("Full description for issue");
104+
105+
$issueField->addVersion(null, "1.0.1");
106+
$issueField->addVersion(null, "1.0.3");
107+
108+
$issueService = new IssueService();
109+
110+
$ret = $issueService->create($issueField);
111+
112+
//If success, Returns a link to the created issue.
113+
print_r($ret);
114+
} catch (HTTPException $e) {
115+
print("Error Occured! " . $e->getMessage());
116+
}
117+
````
118+
119+
# License
120+
121+
Apache V2 License
122+
123+
# JIRA Rest API Documents
124+
* 6.2 - https://docs.atlassian.com/jira/REST/6.2/
125+
* latest - https://docs.atlassian.com/jira/REST/latest/
126+

src/issue/IssueField.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public function __construct() {
1414
}
1515

1616
public function setProjectName($name) {
17-
//$this->project->name = $name;
18-
$this->project->id = '12000';
17+
$this->project->name = $name;
1918
}
2019
public function setProjectId($id) {
2120
$this->project->id = $id;
@@ -32,7 +31,7 @@ public function setSummary($summary) {
3231
public function setReporterName($name) {
3332
if (is_null($this->reporter))
3433
$this->reporter = new \JiraRestApi\Issue\Reporter();
35-
34+
3635
$this->reporter->name = $name;
3736
}
3837

src/issue/IssueService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
class IssueService extends \JiraRestApi\JiraClient {
88
private $uri = "/issue";
99

10-
public function __construct($config, $opt_array = null) {
11-
parent::__construct($config, $opt_array);
10+
public function __construct() {
11+
parent::__construct(getHostConfig(), getOptions());
1212
}
1313

1414
/**

src/project/ProjectService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
class ProjectService extends \JiraRestApi\JiraClient {
88
private $uri = "/project";
99

10-
public function __construct($config, $opt_array = null) {
11-
parent::__construct($config, $opt_array);
10+
public function __construct() {
11+
parent::__construct(getHostConfig(), getOptions());
1212
}
1313

1414
/**

tests/IssueTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public function testIssue()
99
{
1010
$this->markTestIncomplete();
1111
try {
12-
$issueService = new IssueService(getHostConfig(), getOptions());
12+
$issueService = new IssueService();
1313

1414
$issue = $issueService->get('TEST-867');
1515

@@ -31,9 +31,8 @@ public function testCreateIssue()
3131
//$this->markTestIncomplete();
3232
try {
3333
$issueField = new IssueField();
34-
$issueField->setProjectName("TEST");
34+
$issueField->setProjectId("12000");
3535
$issueField->setSummary("something's wrong");
36-
//$issueField->setReporterName("smithers");
3736
$issueField->setAssigneeName("lesstif");
3837
$issueField->setPriorityName("Critical");
3938
$issueField->setIssueType("Bug");
@@ -42,10 +41,11 @@ public function testCreateIssue()
4241
$issueField->addVersion(null, "1.0.1");
4342
$issueField->addVersion(null, "1.0.3");
4443

45-
$issueService = new IssueService(getHostConfig(), getOptions());
44+
$issueService = new IssueService();
4645

4746
$ret = $issueService->create($issueField);
4847

48+
//If success, Returns a link to the created issue.
4949
print_r($ret);
5050
} catch (HTTPException $e) {
5151
$this->assertTrue(FALSE, "Create Failed : " . $e->getMessage());

tests/ProjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public function testGetProject()
88
{
99
//$this->markTestIncomplete();
1010
try {
11-
$proj = new ProjectService(getHostConfig(), getOptions());
11+
$proj = new ProjectService();
1212

1313
$p = $proj->get('TEST');
1414

@@ -25,7 +25,7 @@ public function testGetProjectLists()
2525
{
2626
//$this->markTestIncomplete();
2727
try {
28-
$proj = new ProjectService(getHostConfig(), getOptions());
28+
$proj = new ProjectService();
2929

3030
$prjs = $proj->getAllProjects();
3131

0 commit comments

Comments
 (0)