11<?php
2- /**
3- * Created by PhpStorm.
4- * User: meshulam
5- * Date: 11/08/2017
6- * Time: 17:28.
7- */
2+
3+ declare (strict_types=1 );
84
95namespace JiraCloud \Sprint ;
106
1612
1713class SprintService extends JiraClient
1814{
19- //https://jira01.devtools.intel.com/rest/agile/1.0/board?projectKeyOrId=34012
2015 private $ uri = '/sprint ' ;
2116
2217 public function __construct (ConfigurationInterface $ configuration = null , LoggerInterface $ logger = null , $ path = './ ' )
@@ -32,7 +27,7 @@ public function __construct(ConfigurationInterface $configuration = null, Logger
3227 *
3328 * @return Sprint
3429 */
35- public function getSprintFromJSON ($ json )
30+ public function getSprintFromJSON (object $ json ) : Sprint
3631 {
3732 $ sprint = $ this ->json_mapper ->map (
3833 $ json ,
@@ -42,38 +37,26 @@ public function getSprintFromJSON($json)
4237 return $ sprint ;
4338 }
4439
45- /**
46- * get all Sprint list.
47- *
48- * @param string $sprintId
49- *
50- * @throws JiraException
51- * @throws \JsonMapper_Exception
52- *
53- * @return Sprint
54- */
55- public function getSprint (string $ sprintId )
40+ public function getSprint (string |int $ sprintId ) :Sprint
5641 {
5742 $ ret = $ this ->exec ($ this ->uri .'/ ' .$ sprintId , null );
5843
5944 $ this ->log ->info ("Result= \n" .$ ret );
6045
61- return $ sprint = $ this ->json_mapper ->map (
46+ return $ this ->json_mapper ->map (
6247 json_decode ($ ret ),
6348 new Sprint ()
6449 );
6550 }
6651
6752 /**
68- * @param string|int $sprintId
69- * @param array $paramArray
7053 *
7154 * @throws JiraException
7255 * @throws \JsonMapper_Exception
7356 *
7457 * @return Issue[] array of Issue
7558 */
76- public function getSprintIssues ($ sprintId , $ paramArray = [])
59+ public function getSprintIssues (string | int $ sprintId , array $ paramArray = [])
7760 {
7861 $ json = $ this ->exec ($ this ->uri .'/ ' .$ sprintId .'/issue ' .$ this ->toHttpQueryParameter ($ paramArray ), null );
7962
@@ -85,4 +68,18 @@ public function getSprintIssues($sprintId, $paramArray = [])
8568
8669 return $ issues ;
8770 }
71+
72+ public function createSprint (Sprint $ sprint ) : Sprint
73+ {
74+ $ data = json_encode ($ sprint );
75+
76+ $ ret = $ this ->exec ($ this ->uri , $ data );
77+
78+ $ this ->log ->debug ('createSprint result= ' .var_export ($ ret , true ));
79+
80+ return $ this ->json_mapper ->map (
81+ json_decode ($ ret ),
82+ new Sprint ()
83+ );
84+ }
8885}
0 commit comments