Skip to content

Commit 53d548e

Browse files
author
Artur (Seti) Łabudziński
committed
Changelog field added
1 parent f1e1543 commit 53d548e

File tree

9 files changed

+185
-7
lines changed

9 files changed

+185
-7
lines changed

src/Client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function exec($context, $post_data = null, $custom_request = null, $tries
164164

165165
$url = $this->createUrlByContext($context);
166166
$this->log->addDebug("Curl [".($custom_request ? $custom_request : 'GET')."] $url JsonData=" . $post_data);
167-
// echo "Curl [".($custom_request ? $custom_request : 'GET')."] $url JsonData=" . $post_data, "\n";
167+
// echo "Curl [".($custom_request ? $custom_request : 'GET')."] $url JsonData=" . $post_data, "\n";
168168
$ch = curl_init();
169169
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
170170

@@ -193,7 +193,7 @@ public function exec($context, $post_data = null, $custom_request = null, $tries
193193
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->getConfiguration()->isCurlOptSslVerifyHost());
194194
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->getConfiguration()->isCurlOptSslVerifyPeer());
195195
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
196-
curl_setopt($ch, CURLOPT_USERAGENT, self::$UserAgent . ($this->getConfiguration()->getUserAgent() ? ' []' : ''));
196+
curl_setopt($ch, CURLOPT_USERAGENT, self::$UserAgent . ($this->getConfiguration()->getUserAgent() ? ' ['.$this->getConfiguration()->getUserAgent().']' : ''));
197197
curl_setopt($ch, CURLOPT_HTTPHEADER,
198198
array('Accept: */*', 'Content-Type: application/json'));
199199
curl_setopt($ch, CURLOPT_VERBOSE, $this->getConfiguration()->isCurlOptVerbose());
@@ -215,6 +215,7 @@ public function exec($context, $post_data = null, $custom_request = null, $tries
215215
$post_data = null;
216216
curl_setopt($ch, CURLOPT_POST, false);
217217
curl_setopt($ch, CURLOPT_URL, $url);
218+
// echo $url;
218219
}
219220

220221
$response = $this->curlExec($ch, $tries);
@@ -291,6 +292,7 @@ private function createUploadHandle($url, $upload_file)
291292
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->getConfiguration()->isCurlOptSslVerifyHost());
292293
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->getConfiguration()->isCurlOptSslVerifyPeer());
293294
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
295+
curl_setopt($ch, CURLOPT_USERAGENT, self::$UserAgent . ($this->getConfiguration()->getUserAgent() ? ' []' : ''));
294296
curl_setopt($ch, CURLOPT_HTTPHEADER,
295297
array(
296298
'Accept: */*',

src/Configuration/AbstractConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract class AbstractConfiguration implements \Jira\Api\Configuration\Configur
6767
protected $mapper = null;
6868

6969
protected $utf8support = false;
70-
70+
7171
/**
7272
* Name visible in userAgent (additional data apart from Library version).
7373
*

src/Issue/Changelog.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
namespace Jira\Api\Issue;
3+
4+
class Changelog implements \JsonSerializable
5+
{
6+
/**
7+
* @var Integer
8+
*/
9+
public $id;
10+
/** @var Reporter */
11+
public $author;
12+
/** @var \DateTime */
13+
public $created;
14+
/** @var ChangelogsList[\Jira\Api\Issue\Changelog] */
15+
public $histories;
16+
17+
public function jsonSerialize()
18+
{
19+
return array_filter(get_object_vars($this));
20+
}
21+
22+
23+
public function setHistories($wl)
24+
{
25+
if (is_null($this->histories)) {
26+
$this->histories = [];
27+
}
28+
if (!is_array($cl)) $cl = [$cl];
29+
30+
foreach ($cl as $c)
31+
$this->histories[] = new \Jira\Api\Issue\Changelog($c);
32+
}
33+
34+
// public function
35+
// public function __construct($obj) {
36+
// if (is_array($obj)) {}
37+
// elseif (is_object($obj))
38+
// {
39+
// $this->id
40+
// var_dump($this);
41+
// }
42+
// }
43+
}

src/Issue/ChangelogItem.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
namespace Jira\Api\Issue;
3+
4+
class ChangelogItem implements \JsonSerializable
5+
{
6+
/** @var string */
7+
public $field;
8+
/** @var string */
9+
public $fieldType;
10+
/** @var string */
11+
public $from;
12+
/** @var string */
13+
public $fromString;
14+
/** @var string */
15+
public $to;
16+
/** @var string */
17+
public $toString;
18+
19+
public function jsonSerialize()
20+
{
21+
return array_filter(get_object_vars($this));
22+
}
23+
24+
public function __construct($obj) {
25+
if (is_array($obj)) {}
26+
elseif (is_object($obj))
27+
{
28+
var_dump($obj);
29+
$this->field = $obj->field;
30+
$this->fieldType = $obj->fieldType;
31+
$this->from = $obj->from;
32+
$this->fromString = $obj->fromString;
33+
$this->to = $obj -> to;
34+
$this->toString = $obj->toString;
35+
}
36+
}
37+
}

src/Issue/Changelogs.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
namespace Jira\Api\Issue;
3+
4+
class Changelogs implements \JsonSerializable
5+
{
6+
/* @var int */
7+
public $startAt;
8+
9+
/* @var int */
10+
public $maxResults;
11+
12+
/* @var int */
13+
public $total;
14+
15+
/* @var WorklogList[\Jira\Api\Issue\Changelog] */
16+
public $histories;
17+
18+
/**
19+
* @return int
20+
*/
21+
public function getStartAt()
22+
{
23+
return $this->startAt;
24+
}
25+
26+
/**
27+
* @param int $startAt
28+
*/
29+
public function setStartAt($startAt)
30+
{
31+
$this->startAt = $startAt;
32+
}
33+
34+
/**
35+
* @return int
36+
*/
37+
public function getMaxResults()
38+
{
39+
return $this->maxResults;
40+
}
41+
42+
/**
43+
* @param int $maxResults
44+
*/
45+
public function setMaxResults($maxResults)
46+
{
47+
$this->maxResults = $maxResults;
48+
}
49+
50+
/**
51+
* @return int
52+
*/
53+
public function getTotal()
54+
{
55+
return $this->total;
56+
}
57+
58+
public function jsonSerialize()
59+
{
60+
return array_filter(get_object_vars($this));
61+
}
62+
/*
63+
public function setWorklogs($wl)
64+
{
65+
if (is_null($this->worklogs)) {
66+
$this->worklogs = [];
67+
}
68+
if (!is_array($wl)) $wl = [$wl];
69+
70+
foreach ($wl as $w)
71+
$this->worklogs[] = new \Jira\Api\Issue\Worklog($w);
72+
}
73+
*/
74+
public function addChangelog($wl) { $this->addChangelogs($wl); }
75+
public function addChangelogs($wl)
76+
{
77+
if (is_null($this->histories)) {
78+
$this->histories = [];
79+
}
80+
if (!is_array($wl)) $wl = [$wl];
81+
82+
foreach ($wl as $w)
83+
$this->histories[] = new \Jira\Api\Issue\Changelog($w);
84+
}
85+
}

src/Issue/Issue.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@ public function jsonSerialize()
3030
{
3131
return array_filter(get_object_vars($this));
3232
}
33+
34+
/** @var Changelogs */
35+
public $changelog;
36+
37+
// public function setChangelog($cl)
38+
// {
39+
// if (is_null($this->changelog)) {
40+
// $this->changelog = new \Jira\Api\Issue\Changelog($cl);
41+
// }
42+
//
43+
// }
3344
}

src/Issue/IssueField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function getIssueType()
246246
/** @var object */
247247
public $watches;
248248

249-
/** @var object */
249+
/** @var Worklogs */
250250
public $worklog;
251251

252252
/** @var Reporter */

src/Issue/IssueService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ public function search($jql, $startAt=0, $maxResults=15, $fields=[], $expand = [
229229
'jql' => $jql,
230230
'startAt' => $startAt,
231231
'maxResults' => $maxResults,
232-
'fields' => $fields,
232+
// 'fields' => $fields,
233+
'fields' => implode(',',$fields),
233234
'expand' => implode(',',$expand),
234235
));
235236
$ret = $this->exec("search", $data, 'GET');
236-
237237
$result = $this->json_mapper->map(
238238
json_decode($ret), new IssueSearchResult()
239239
);

src/Mapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function map($json, $object)
105105
}
106106

107107
list($hasProperty, $accessor, $type)
108-
= $this->arInspectedClasses[$strClassName][$key];
108+
= $this->arInspectedClasses[$strClassName][$key];
109109

110110
if (!$hasProperty) {
111111
if ($this->bExceptionOnUndefinedProperty) {

0 commit comments

Comments
 (0)