Skip to content

Commit a0ffd97

Browse files
committed
fixed #18 to change the item name to JIRAAPI_v3 prefix
1 parent c8dcd8d commit a0ffd97

6 files changed

Lines changed: 69 additions & 63 deletions

File tree

.env.example

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11

2-
JIRA_HOST="https://your-jira.atlassian.net"
3-
JIRA_USER="your@email.here"
4-
PERSONAL_ACCESS_TOKEN="your-token-here"
2+
JIRAAPI_V3_HOST="https://your-jira.atlassian.net"
3+
JIRAAPI_V3_USER="your@email.here"
4+
JIRAAPI_V3_PERSONAL_ACCESS_TOKEN="your-token-here"
5+
#JIRAAPI_V3_SERVICE_DESK_ID=
56

6-
JIRA_LOG_FILE="jira-rest-client.log"
7-
JIRA_LOG_LEVEL="DEBUG"
8-
COOKIE_AUTH_ENABLED=false
9-
CURLOPT_VERBOSE=false
7+
JIRAAPI_V3_LOG_FILE="jira-rest-client.log"
8+
JIRAAPI_V3_LOG_LEVEL="DEBUG"
9+
JIRAAPI_V3_COOKIE_AUTH_ENABLED=false
10+
JIRAAPI_V3_CURLOPT_VERBOSE=false
1011

11-
JIRA_LOG_ENABLED=true
12+
JIRAAPI_V3_LOG_ENABLED=true
1213

14+
#JIRAAPI_V3_PROXY_SERVER=
15+
#JIRAAPI_V3_PROXY_PORT=
16+
#JIRAAPI_V3_PROXY_USER=
17+
#JIRAAPI_V3_PROXY_PASSWORD=

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ you can choose loads environment variables either 'dotenv' or 'array'.
6565
copy .env.example file to .env on your project root.
6666

6767
```sh
68-
JIRA_HOST='https://your-jira.atlassian.net'
69-
JIRA_USER='jira-username'
68+
JIRAAPI_V3_HOST='https://your-jira.atlassian.net'
69+
JIRAAPI_V3_USER='jira-username'
7070
PERSONAL_ACCESS_TOKEN='your-access-token-here'
71-
# to enable session cookie authorization
72-
# COOKIE_AUTH_ENABLED=true
73-
# COOKIE_FILE=storage/jira-cookie.txt
74-
# if you are behind a proxy, add proxy settings
75-
PROXY_SERVER='your-proxy-server'
76-
PROXY_PORT='proxy-port'
77-
PROXY_USER='proxy-username'
78-
PROXY_PASSWORD='proxy-password'
71+
## to enable session cookie authorization
72+
# JIRAAPI_V3_COOKIE_AUTH_ENABLED=true
73+
# JIRAAPI_V3_COOKIE_FILE=storage/jira-cookie.txt
74+
## if you are behind a proxy, add proxy settings
75+
JIRAAPI_V3_PROXY_SERVER='your-proxy-server'
76+
JIRAAPI_V3_PROXY_PORT='proxy-port'
77+
JIRAAPI_V3_PROXY_USER='proxy-username'
78+
JIRAAPI_V3_PROXY_PASSWORD='proxy-password'
7979
```
8080
**CAUTION**
8181
this library not fully supported JIRA REST API V3 yet.
@@ -647,7 +647,7 @@ CODE;
647647
$descV3 = new AtlassianDocumentFormat($doc);
648648

649649
$issueField->setProjectKey('TEST')
650-
->setSummary('something's wrong')
650+
->setSummary('something\'s wrong')
651651
->setAssigneeNameAsString('lesstif')
652652
->setPriorityNameAsString('Highest')
653653
->setIssueTypeAsString('Story')
@@ -689,7 +689,7 @@ try {
689689
$descV3 = new AtlassianDocumentFormat($doc);
690690

691691
$issueField->setProjectKey('TEST')
692-
->setSummary('something's wrong')
692+
->setSummary('something\'s wrong')
693693
->setAssigneeNameAsString('lesstif')
694694
->setPriorityNameAsString('Critical')
695695
->setIssueTypeAsString('Bug')
@@ -740,7 +740,7 @@ try {
740740
$descV3 = new AtlassianDocumentFormat($doc);
741741

742742
$issueFieldOne->setProjectKey('TEST')
743-
->setSummary('something's wrong')
743+
->setSummary('something\'s wrong')
744744
->setPriorityNameAsString('Critical')
745745
->setIssueTypeAsString('Bug')
746746
->setDescription($descV3);
@@ -804,7 +804,7 @@ try {
804804
$descV3 = new AtlassianDocumentFormat(doc);
805805

806806
$issueField->setProjectKey('TEST')
807-
->setSummary('something's wrong')
807+
->setSummary('something\'s wrong')
808808
->setAssigneeNameAsString('lesstif')
809809
->setPriorityNameAsString('Critical')
810810
->setDescription($descV3)
@@ -878,7 +878,7 @@ try {
878878
$issueField = new IssueField();
879879

880880
$issueField->setProjectKey('TEST')
881-
->setSummary('something's wrong')
881+
->setSummary('something\'s wrong')
882882
->setAssigneeNameAsString('lesstif')
883883
->setPriorityNameAsString('Critical')
884884
->setIssueTypeAsString('Bug')
@@ -1305,7 +1305,7 @@ you should pass that status name to `setTransitionName`
13051305

13061306
i.e. `$transition->setTransitionName('Some Status')`
13071307

1308-
[See Jira API reference](https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-doTransition)
1308+
[See Jira API reference](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-post)
13091309

13101310
```php
13111311
<?php
@@ -1319,7 +1319,7 @@ $issueKey = 'TEST-879';
13191319

13201320
try {
13211321
$transition = new Transition();
1322-
$transition->setTransitionName('Resolved');
1322+
$transition->setTransitionName('In Progress');
13231323
$transition->setCommentBody('performing the transition via REST API.');
13241324

13251325
$issueService = new IssueService();
@@ -1627,7 +1627,7 @@ try {
16271627
<?php
16281628
require 'vendor/autoload.php';
16291629

1630-
// Worklog example for API V3 assumes JIRA_REST_API_V3=true is configured in
1630+
// Worklog example for API V3 assumes JIRAAPI_V3_REST_API_V3=true is configured in
16311631
// your .env file.
16321632

16331633
use JiraCloud\Issue\ContentField;

src/Configuration/DotEnvConfiguration.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@ public function __construct(string $path = '.')
1818
{
1919
$this->loadDotEnv($path);
2020

21-
$this->jiraHost = $this->env('JIRA_HOST');
22-
$this->jiraUser = $this->env('JIRA_USER');
23-
24-
$this->oauthAccessToken = $this->env('OAUTH_ACCESS_TOKEN');
25-
$this->cookieAuthEnabled = $this->env('COOKIE_AUTH_ENABLED', false);
26-
$this->cookieFile = $this->env('COOKIE_FILE', 'jira-cookie.txt');
27-
$this->jiraLogEnabled = $this->env('JIRA_LOG_ENABLED', true);
28-
$this->jiraLogFile = $this->env('JIRA_LOG_FILE', 'jira-rest-client.log');
29-
$this->jiraLogLevel = $this->env('JIRA_LOG_LEVEL', 'WARNING');
30-
$this->curlOptSslVerifyHost = $this->env('CURLOPT_SSL_VERIFYHOST', false);
31-
$this->curlOptSslVerifyPeer = $this->env('CURLOPT_SSL_VERIFYPEER', false);
32-
$this->curlOptSslCert = $this->env('CURLOPT_SSL_CERT');
33-
$this->curlOptSslCertPassword = $this->env('CURLOPT_SSL_CERT_PASSWORD');
34-
$this->curlOptSslKey = $this->env('CURLOPT_SSL_KEY');
35-
$this->curlOptSslKeyPassword = $this->env('CURLOPT_SSL_KEY_PASSWORD');
36-
$this->curlOptUserAgent = $this->env('CURLOPT_USERAGENT', $this->getDefaultUserAgentString());
37-
$this->curlOptVerbose = $this->env('CURLOPT_VERBOSE', false);
38-
$this->proxyServer = $this->env('PROXY_SERVER');
39-
$this->proxyPort = $this->env('PROXY_PORT');
40-
$this->proxyUser = $this->env('PROXY_USER');
41-
$this->proxyPassword = $this->env('PROXY_PASSWORD');
42-
43-
$this->timeout = $this->env('JIRA_TIMEOUT', 30);
44-
45-
$this->personalAccessToken = $this->env('PERSONAL_ACCESS_TOKEN', false);
46-
$this->serviceDeskId = $this->env('JIRA_SERVICE_DESK_ID', null);
21+
$this->jiraHost = $this->env('JIRAAPI_V3_HOST');
22+
$this->jiraUser = $this->env('JIRAAPI_V3_USER');
23+
24+
$this->oauthAccessToken = $this->env('JIRAAPI_V3_OAUTH_ACCESS_TOKEN');
25+
$this->cookieAuthEnabled = $this->env('JIRAAPI_V3_COOKIE_AUTH_ENABLED', false);
26+
$this->cookieFile = $this->env('JIRAAPI_V3_COOKIE_FILE', 'jira-cookie.txt');
27+
$this->jiraLogEnabled = $this->env('JIRAAPI_V3_LOG_ENABLED', true);
28+
$this->jiraLogFile = $this->env('JIRAAPI_V3_LOG_FILE', 'jira-rest-client.log');
29+
$this->jiraLogLevel = $this->env('JIRAAPI_V3_LOG_LEVEL', 'WARNING');
30+
$this->curlOptSslVerifyHost = $this->env('JIRAAPI_V3_CURLOPT_SSL_VERIFYHOST', false);
31+
$this->curlOptSslVerifyPeer = $this->env('JIRAAPI_V3_CURLOPT_SSL_VERIFYPEER', false);
32+
$this->curlOptSslCert = $this->env('JIRAAPI_V3_CURLOPT_SSL_CERT');
33+
$this->curlOptSslCertPassword = $this->env('JIRAAPI_V3_CURLOPT_SSL_CERT_PASSWORD');
34+
$this->curlOptSslKey = $this->env('JIRAAPI_V3_CURLOPT_SSL_KEY');
35+
$this->curlOptSslKeyPassword = $this->env('JIRAAPI_V3_CURLOPT_SSL_KEY_PASSWORD');
36+
$this->curlOptUserAgent = $this->env('JIRAAPI_V3_CURLOPT_USERAGENT', $this->getDefaultUserAgentString());
37+
$this->curlOptVerbose = $this->env('JIRAAPI_V3_CURLOPT_VERBOSE', false);
38+
$this->proxyServer = $this->env('JIRAAPI_V3_PROXY_SERVER');
39+
$this->proxyPort = $this->env('JIRAAPI_V3_PROXY_PORT');
40+
$this->proxyUser = $this->env('JIRAAPI_V3_PROXY_USER');
41+
$this->proxyPassword = $this->env('JIRAAPI_V3_PROXY_PASSWORD');
42+
43+
$this->timeout = $this->env('JIRAAPI_V3_TIMEOUT', 30);
44+
45+
$this->personalAccessToken = $this->env('JIRAAPI_V3_PERSONAL_ACCESS_TOKEN', false);
46+
$this->serviceDeskId = $this->env('JIRAAPI_V3_SERVICE_DESK_ID', null);
4747
}
4848

4949
/**
@@ -116,7 +116,7 @@ public function endsWith(string $haystack, array|string $needles): bool
116116
private function loadDotEnv(string $path)
117117
{
118118
$requireParam = [
119-
'JIRA_HOST', 'JIRA_USER', 'PERSONAL_ACCESS_TOKEN',
119+
'JIRAAPI_V3_HOST', 'JIRAAPI_V3_USER', 'JIRAAPI_V3_PERSONAL_ACCESS_TOKEN',
120120
];
121121

122122
// support for dotenv 1.x and 2.x. see also https://github.com/lesstif/php-jira-rest-client/issues/102

src/Issue/IssueService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace JiraCloud\Issue;
44

55
use ArrayObject;
6+
use JiraCloud\Dumper;
67
use JiraCloud\JiraException;
78
use JiraCloud\Project\ProjectService;
89

@@ -461,14 +462,11 @@ public function findTransitonId(string|int $issueIdOrKey, string $transitionToNa
461462
* @param string|int $issueIdOrKey Issue id or key
462463
* @param Transition $transition
463464
*
464-
* @throws JiraException
465-
*
466465
* @return string|null nothing - if transition was successful return http 204(no contents)
466+
* @throws JiraException
467467
*/
468-
public function transition(string|int $issueIdOrKey, string $transition): ?string
468+
public function transition(string|int $issueIdOrKey, Transition $transition): ?string
469469
{
470-
$this->log->debug('transition='.var_export($transition, true));
471-
472470
if (!isset($transition->transition['id'])) {
473471
if (isset($transition->transition['untranslatedName'])) {
474472
$transition->transition['id'] = $this->findTransitonIdByUntranslatedName($issueIdOrKey, $transition->transition['untranslatedName']);

src/Issue/Transition.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace JiraCloud\Issue;
44

5+
use JiraCloud\ADF\AtlassianDocumentFormat;
6+
57
/**
68
* Issue Transition mapping class.
79
*/
@@ -17,9 +19,9 @@ class Transition implements \JsonSerializable
1719

1820
public IssueField $issueFields;
1921

20-
public ?array $transition;
22+
public ?array $transition = null;
2123

22-
public ?array $update;
24+
public ?array $update = null;
2325

2426
public function setTransitionName($name): void
2527
{
@@ -51,15 +53,16 @@ public function setTransitionId(string $id): void
5153
$this->transition['id'] = $id;
5254
}
5355

54-
public function setCommentBody(string $commentBody): void
56+
public function setCommentBody(AtlassianDocumentFormat $commentBody): void
5557
{
5658
if (is_null($this->update)) {
5759
$this->update = [];
5860
$this->update['comment'] = [];
5961
}
6062

6163
$ar = [];
62-
$ar['add']['body'] = $commentBody;
64+
$ar['add']['body'] = $commentBody->jsonSerialize();
65+
6366
array_push($this->update['comment'], $ar);
6467
}
6568

src/ServiceDesk/Comment/CommentService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class CommentService
1616
{
1717
private ServiceDeskClient $client;
18-
private string $uri = '/servicedeskapi/request';
18+
private string $uri = '/request';
1919
private LoggerInterface $logger;
2020
private JsonMapper $jsonMapper;
2121

0 commit comments

Comments
 (0)