File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments