Skip to content

Commit 2bc5ff4

Browse files
author
Artur (Seti) Łabudziński
committed
Added ScriptRunner Service
1 parent 83369a4 commit 2bc5ff4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/ScriptRunner/Custom.php

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: AP_514
5+
* Date: 2017-11-14
6+
* Time: 11:43
7+
*/
8+
9+
namespace Jira\Api\ScriptRunner;
10+
11+
class Custom extends \Jira\Api\Client
12+
{
13+
/**
14+
* JIRA REST API URI
15+
*
16+
* @var string
17+
*/
18+
private $api_uri = '/rest/scriptrunner/latest/custom';
19+
20+
/**
21+
* Get URL by context
22+
*
23+
* @param string $context
24+
*
25+
* @return string
26+
*/
27+
protected function createUrlByContext($context)
28+
{
29+
$host = $this->getConfiguration()->getJiraHost();
30+
31+
if (substr($context, 0, 1) === '*') {
32+
$context = substr($context, 1);
33+
34+
return $host . '/rest' . '/' . preg_replace('/\//', '', $context, 1);
35+
}
36+
37+
return $host . $this->api_uri . '/' . preg_replace('/\//', '', $context, 1);
38+
}
39+
40+
/**
41+
* Execute REST request
42+
*
43+
* @param string $context Rest API context (ex.:issue, search, etc..)
44+
* @param null $post_data
45+
* @param null $custom_request
46+
*
47+
* @return array|object
48+
* @throws Exception
49+
*/
50+
public function exec($context, $post_data = null, $custom_request = null, $tries = 3)
51+
{
52+
$ret = parent::exec($context, $post_data, $custom_request, $tries);
53+
if ($ret) {
54+
return json_decode($ret);
55+
}
56+
57+
return $ret;
58+
}
59+
}

0 commit comments

Comments
 (0)