13
13
14
14
namespace Iris ;
15
15
16
+ require_once ("ReportsInstanceModel.php " );
17
+
16
18
final class Reports extends RestEntry {
17
19
18
20
public function __construct ($ parent ) {
19
21
$ this ->parent = $ parent ;
20
22
parent ::_init ($ this ->parent ->get_rest_client (), $ this ->parent ->get_relative_namespace ());
21
23
}
22
24
23
- public function getList ($ filters = Array ()) {
25
+ public function getList ($ filters = array ()) {
24
26
25
27
$ reports = [];
26
28
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 ) {
32
32
$ reports [] = new Report ($ this , $ report );
33
33
}
34
34
}
@@ -45,19 +45,68 @@ public function get_by_id($id) {
45
45
public function get_appendix () {
46
46
return '/reports ' ;
47
47
}
48
+ }
49
+
50
+ final class ReportValue {
51
+ use BaseModel;
48
52
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
+ }
49
60
}
50
61
51
- final class Report extends RestEntry {
62
+ final class ReportValues {
52
63
use BaseModel;
53
64
54
65
protected $ fields = array (
55
- "orderId " => array (
56
- "type " => "string "
57
- ),
58
- /* TODO: fill fields */
66
+ "Value " => array ("type " => "\Iris\ReportValue " )
59
67
);
68
+ public function __construct ($ data ) {
69
+ $ this ->set_data ($ data );
70
+ }
71
+ }
60
72
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
+ );
61
110
62
111
public function __construct ($ reports , $ data )
63
112
{
@@ -80,7 +129,7 @@ public function get() {
80
129
throw new \Exception ('Id should be provided ' );
81
130
82
131
$ data = parent ::_get ($ this ->id );
83
- $ this ->set_data ($ data ['Order ' ]);
132
+ $ this ->set_data ($ data ['Report ' ]);
84
133
}
85
134
86
135
public function areaCodes ()
@@ -90,55 +139,27 @@ public function areaCodes()
90
139
return $ data ;
91
140
}
92
141
93
- public function instances ()
142
+ public function instances ($ filters = array () )
94
143
{
95
144
$ rep_instances = [];
96
145
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 " ));
98
147
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 );
102
151
}
103
152
}
104
153
105
154
return $ rep_instances ;
106
155
}
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 );
130
156
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
135
160
}
136
161
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 ();
143
164
}
144
165
}
0 commit comments