Rev 1295 | Rev 1326 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1295 | Rev 1299 | ||
---|---|---|---|
Line 90... | Line 90... | ||
90 | OIDplus::invoke_shutdown(); |
90 | OIDplus::invoke_shutdown(); |
91 | die(); // return array(); |
91 | die(); // return array(); |
92 | } |
92 | } |
93 | 93 | ||
94 | /** |
94 | /** |
- | 95 | * REST method for selecting |
|
95 | * @param string $endpoint |
96 | * @param string $endpoint |
96 | * @param array $json_in |
97 | * @param array $json_in |
97 | * @return array |
98 | * @return array |
98 | */ |
99 | */ |
99 | private function restApiCall_GET(string $endpoint, array $json_in): array { |
100 | private function restApiCall_GET(string $endpoint, array $json_in): array { |
Line 130... | Line 131... | ||
130 | http_response_code(200); |
131 | http_response_code(200); |
131 | return $output; |
132 | return $output; |
132 | } |
133 | } |
133 | 134 | ||
134 | /** |
135 | /** |
- | 136 | * REST method for replacing (re-create) |
|
135 | * @param string $endpoint |
137 | * @param string $endpoint |
136 | * @param array $json_in |
138 | * @param array $json_in |
137 | * @return array |
139 | * @return array |
138 | */ |
140 | */ |
139 | private function restApiCall_PUT(string $endpoint, array $json_in): array { |
141 | private function restApiCall_PUT(string $endpoint, array $json_in): array { |
140 | $id = substr($endpoint, strlen('objects/')); |
142 | $id = substr($endpoint, strlen('objects/')); |
141 | $obj = OIDplusObject::parse($id); |
143 | $obj = OIDplusObject::parse($id); |
142 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'PUT', $id), null, 400); |
144 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'PUT', $id), null, 400); |
143 | 145 | ||
- | 146 | // ATTENTION: Do *not* use $params=$json_in. We intentionally set $params to empty strings if the values do not exist in $json_in, |
|
- | 147 | // because PUT is for re-creating the whole object! |
|
144 | $params = array(); |
148 | $params = array(); |
145 | $params['id'] = $id; |
149 | $params['id'] = $id; |
146 | $params['ra_email'] = $json_in['ra_email'] ?? ''; |
150 | $params['ra_email'] = $json_in['ra_email'] ?? ''; |
147 | $params['comment'] = $json_in['comment'] ?? ''; |
151 | $params['comment'] = $json_in['comment'] ?? ''; |
148 | $params['confidential'] = $json_in['confidential'] ?? false; |
152 | $params['confidential'] = $json_in['confidential'] ?? false; |
Line 169... | Line 173... | ||
169 | http_response_code(200); |
173 | http_response_code(200); |
170 | return $output; |
174 | return $output; |
171 | } |
175 | } |
172 | 176 | ||
173 | /** |
177 | /** |
- | 178 | * REST method for inserting (create) |
|
174 | * @param string $endpoint |
179 | * @param string $endpoint |
175 | * @param array $json_in |
180 | * @param array $json_in |
176 | * @return array |
181 | * @return array |
177 | */ |
182 | */ |
178 | private function restApiCall_POST(string $endpoint, array $json_in): array { |
183 | private function restApiCall_POST(string $endpoint, array $json_in): array { |
Line 194... | Line 199... | ||
194 | http_response_code(200); |
199 | http_response_code(200); |
195 | return $output; |
200 | return $output; |
196 | } |
201 | } |
197 | 202 | ||
198 | /** |
203 | /** |
- | 204 | * REST method for modification |
|
199 | * @param string $endpoint |
205 | * @param string $endpoint |
200 | * @param array $json_in |
206 | * @param array $json_in |
201 | * @return array |
207 | * @return array |
202 | */ |
208 | */ |
203 | private function restApiCall_PATCH(string $endpoint, array $json_in): array { |
209 | private function restApiCall_PATCH(string $endpoint, array $json_in): array { |
Line 215... | Line 221... | ||
215 | http_response_code(200); |
221 | http_response_code(200); |
216 | return $output; |
222 | return $output; |
217 | } |
223 | } |
218 | 224 | ||
219 | /** |
225 | /** |
- | 226 | * REST method for deleting |
|
220 | * @param string $endpoint |
227 | * @param string $endpoint |
221 | * @param array $json_in |
228 | * @param array $json_in |
222 | * @return array |
229 | * @return array |
223 | */ |
230 | */ |
224 | private function restApiCall_DELETE(string $endpoint, array $json_in): array { |
231 | private function restApiCall_DELETE(string $endpoint, array $json_in): array { |