1313
1414namespace Iris ;
1515
16+ require_once ("ReportsInstanceModel.php " );
17+
1618final class Reports extends RestEntry {
1719
1820 public function __construct ($ parent ) {
1921 $ this ->parent = $ parent ;
2022 parent ::_init ($ this ->parent ->get_rest_client (), $ this ->parent ->get_relative_namespace ());
2123 }
2224
23- public function getList ($ filters = Array ()) {
25+ public function getList ($ filters = array ()) {
2426
2527 $ reports = [];
2628
27- $ data = parent ::_get ('reports ' , $ filters , Array ("page " => 1 , "size " => 30 ), Array ("page " , "size " ));
28- print_r ($ data ); exit ;
29- /* TODO: correct struct */
30- if ($ data ['ListOrderIdUserIdDate ' ] && $ data ['ListOrderIdUserIdDate ' ]['TotalCount ' ]) {
31- foreach ($ data ['ListOrderIdUserIdDate ' ]['OrderIdUserIdDate ' ] as $ report ) {
29+ $ data = parent ::_get ('reports ' , $ filters , array ("page " => 1 , "size " => 30 ), array ("page " , "size " ));
30+ if ($ data ['Reports ' ]) {
31+ foreach ($ data ['Reports ' ]['Report ' ] as $ report ) {
3232 $ reports [] = new Report ($ this , $ report );
3333 }
3434 }
@@ -45,19 +45,68 @@ public function get_by_id($id) {
4545 public function get_appendix () {
4646 return '/reports ' ;
4747 }
48+ }
49+
50+ final class ReportValue {
51+ use BaseModel;
4852
53+ protected $ fields = array (
54+ "InternalName " => array ("type " => "string " ),
55+ "DisplayName " => array ("type " => "string " ),
56+ );
57+ public function __construct ($ data ) {
58+ $ this ->set_data ($ data );
59+ }
4960}
5061
51- final class Report extends RestEntry {
62+ final class ReportValues {
5263 use BaseModel;
5364
5465 protected $ fields = array (
55- "orderId " => array (
56- "type " => "string "
57- ),
58- /* TODO: fill fields */
66+ "Value " => array ("type " => "\Iris\ReportValue " )
5967 );
68+ public function __construct ($ data ) {
69+ $ this ->set_data ($ data );
70+ }
71+ }
6072
73+ final class ReportParameter {
74+ use BaseModel;
75+
76+ protected $ fields = array (
77+ "Name " => array ("type " => "string " ),
78+ "Type " => array ("type " => "string " ),
79+ "Required " => array ("type " => "string " ),
80+ "Description " => array ("type " => "string " ),
81+ "MultiSelectAllowed " => array ("type " => "string " ),
82+ "HelpInformation " => array ("type " => "string " ),
83+ "Values " => array ("type " => "\Iris\ReportValues " ),
84+ );
85+ public function __construct ($ data ) {
86+ $ this ->set_data ($ data );
87+ }
88+ }
89+
90+ final class ReportParameters {
91+ use BaseModel;
92+
93+ protected $ fields = array (
94+ "Parameter " => array ("type " => "\Iris\ReportParameter " )
95+ );
96+ public function __construct ($ data ) {
97+ $ this ->set_data ($ data );
98+ }
99+ }
100+
101+ final class Report extends RestEntry{
102+ use BaseModel;
103+
104+ protected $ fields = array (
105+ "Id " => array ("type " => "string " ),
106+ "Name " => array ("type " => "string " ),
107+ "Description " => array ("type " => "string " ),
108+ "Parameters " => array ("type " => "\Iris\ReportParameters " ),
109+ );
61110
62111 public function __construct ($ reports , $ data )
63112 {
@@ -80,7 +129,7 @@ public function get() {
80129 throw new \Exception ('Id should be provided ' );
81130
82131 $ data = parent ::_get ($ this ->id );
83- $ this ->set_data ($ data ['Order ' ]);
132+ $ this ->set_data ($ data ['Report ' ]);
84133 }
85134
86135 public function areaCodes ()
@@ -90,55 +139,27 @@ public function areaCodes()
90139 return $ data ;
91140 }
92141
93- public function instances ()
142+ public function instances ($ filters = array () )
94143 {
95144 $ rep_instances = [];
96145
97- $ data = parent ::_get (' reports/{ $this->id} /instances ' , $ filters , Array ("page " => 1 , "size " => 30 ), Array ("page " , "size " ));
146+ $ data = parent ::_get ($ this ->Id . ' /instances ' , $ filters , array ("page " => 1 , "size " => 30 ), array ("page " , "size " ));
98147
99- if ($ data ['ListOrderIdUserIdDate ' ] && $ data [ ' ListOrderIdUserIdDate ' ][ ' TotalCount ' ]) {
100- foreach ($ data ['ListOrderIdUserIdDate ' ]['OrderIdUserIdDate ' ] as $ instance ) {
101- $ rep_instances [] = new ReportInctace ($ this , $ instance );
148+ if ($ data ['Instances ' ]) {
149+ foreach ($ data ['Instances ' ]['Instance ' ] as $ instance ) {
150+ $ rep_instances [] = new ReportInstance ($ this , $ instance );
102151 }
103152 }
104153
105154 return $ rep_instances ;
106155 }
107- }
108-
109-
110- final class ReportInstance extends RestEntry{
111- use BaseModel;
112-
113- protected $ fields = array (
114- "orderId " => array (
115- "type " => "string "
116- ),
117- /* TODO: fill fields */
118- );
119-
120-
121- public function __construct ($ report , $ data )
122- {
123- if (isset ($ data )) {
124- if (is_object ($ data ) && $ data ->Id )
125- $ this ->id = $ data ->Id ;
126- if (is_array ($ data ) && isset ($ data ['Id ' ]))
127- $ this ->id = $ data ['Id ' ];
128- }
129- $ this ->set_data ($ data );
130156
131- if (!is_null ($ report )) {
132- $ this ->parent = $ report ;
133- parent ::_init ($ report ->get_rest_client (), $ report ->get_relative_namespace ());
134- }
157+ public function modifyInstance ($ instance ) {
158+ $ response = parent ::post ($ this ->Id ."/instances/ " .$ instance ->Id , "Instance " , $ this ->to_array ());
159+ return $ response ; //this api endpoint returns a response header
135160 }
136161
137- public function get () {
138- if (is_null ($ this ->id ))
139- throw new \Exception ('Id should be provided ' );
140-
141- $ data = parent ::_get ($ this ->id );
142- $ this ->set_data ($ data ['Order ' ]);
162+ public function get_appendix () {
163+ return $ this ->parent ->get_appendix ();
143164 }
144165}
0 commit comments