| @@ -67,79 +67,8 @@ | ||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $startUrl = 'shiftcontroller/v4'; |
| 70 | 70 | |
| 71 | - register_rest_route( $startUrl, '/calendars', | |
| 72 | - array( | |
| 73 | - array( | |
| 74 | - 'methods' => WP_REST_Server::READABLE, | |
| 75 | - 'callback' => array($this->self, 'calendarsGet'), | |
| 76 | - // 'permission_callback' => '__return_true', | |
| 77 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 78 | - ), | |
| 79 | - ) | |
| 80 | - ); | |
| 81 | - | |
| 82 | - register_rest_route( $startUrl, '/employees', | |
| 83 | - array( | |
| 84 | - array( | |
| 85 | - 'methods' => WP_REST_Server::READABLE, | |
| 86 | - 'callback' => array($this->self, 'employeesGet'), | |
| 87 | - // 'permission_callback' => '__return_true', | |
| 88 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 89 | - ), | |
| 90 | - array( | |
| 91 | - 'methods' => WP_REST_Server::CREATABLE, | |
| 92 | - 'callback' => array($this->self, 'employeesCreate'), | |
| 93 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 94 | - ), | |
| 95 | - ) | |
| 96 | - ); | |
| 97 | - | |
| 98 | - register_rest_route( $startUrl, '/employees/(?P<id>\d+)', | |
| 99 | - array( | |
| 100 | - array( | |
| 101 | - 'methods' => WP_REST_Server::READABLE, | |
| 102 | - 'callback' => array( $this->self, 'employeesGetById' ), | |
| 103 | - // 'permission_callback' => '__return_true', | |
| 104 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 105 | - ), | |
| 106 | - ) | |
| 107 | - ); | |
| 108 | - | |
| 109 | - register_rest_route( $startUrl, '/calendars/(?P<id>\d+)/employees', | |
| 110 | - array( | |
| 111 | - array( | |
| 112 | - 'methods' => WP_REST_Server::READABLE, | |
| 113 | - 'callback' => array( $this->self, 'employeesGetByCalendarId' ), | |
| 114 | - // 'permission_callback' => '__return_true', | |
| 115 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 116 | - ), | |
| 117 | - ) | |
| 118 | - ); | |
| 119 | - | |
| 120 | - register_rest_route( $startUrl, '/employees/(?P<id>\d+)/calendars', | |
| 121 | - array( | |
| 122 | - array( | |
| 123 | - 'methods' => WP_REST_Server::READABLE, | |
| 124 | - 'callback' => array( $this->self, 'calendarsGetByEmployeeId' ), | |
| 125 | - // 'permission_callback' => '__return_true', | |
| 126 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 127 | - ), | |
| 128 | - ) | |
| 129 | - ); | |
| 130 | - | |
| 131 | - register_rest_route( $startUrl, '/users/(?P<id>\d+)/employee', | |
| 132 | - array( | |
| 133 | - array( | |
| 134 | - 'methods' => WP_REST_Server::READABLE, | |
| 135 | - 'callback' => array( $this->self, 'employeesGetByUserId' ), | |
| 136 | - // 'permission_callback' => '__return_true', | |
| 137 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 138 | - ), | |
| 139 | - ) | |
| 140 | - ); | |
| 141 | - | |
| 142 | 71 | register_rest_route( $startUrl, '/available-employees', |
| 143 | 72 | array( |
| 144 | 73 | array( |
| 145 | 74 | 'methods' => WP_REST_Server::READABLE, |
| @@ -184,38 +113,8 @@ | ||
| 184 | 113 | 'permission_callback' => array( $this->self, 'checkAdmin' ), |
| 185 | 114 | ), |
| 186 | 115 | ) |
| 187 | 116 | ); |
| 188 | - | |
| 189 | - register_rest_route( $startUrl, '/employees/(?P<eid>\d+)/calendars/(?P<cid>\d+)', | |
| 190 | - array( | |
| 191 | - array( | |
| 192 | - 'methods' => WP_REST_Server::DELETABLE, | |
| 193 | - 'callback' => array( $this->self, 'employeesRemoveFromCalendar' ), | |
| 194 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 195 | - ), | |
| 196 | - array( | |
| 197 | - 'methods' => WP_REST_Server::CREATABLE, | |
| 198 | - 'callback' => array( $this->self, 'employeesAddToCalendar' ), | |
| 199 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 200 | - ), | |
| 201 | - ) | |
| 202 | - ); | |
| 203 | - | |
| 204 | - register_rest_route( $startUrl, '/calendars/(?P<eid>\d+)/employees/(?P<cid>\d+)', | |
| 205 | - array( | |
| 206 | - array( | |
| 207 | - 'methods' => WP_REST_Server::DELETABLE, | |
| 208 | - 'callback' => array( $this->self, 'employeesRemoveFromCalendar' ), | |
| 209 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 210 | - ), | |
| 211 | - array( | |
| 212 | - 'methods' => WP_REST_Server::CREATABLE, | |
| 213 | - 'callback' => array( $this->self, 'employeesAddToCalendar' ), | |
| 214 | - 'permission_callback' => array( $this->self, 'checkAdmin' ), | |
| 215 | - ), | |
| 216 | - ) | |
| 217 | - ); | |
| 218 | 117 | } |
| 219 | 118 | |
| 220 | 119 | public function availableEmployeesGet( $request ) |
| 221 | 120 | { |
| @@ -270,77 +169,6 @@ | ||
| 270 | 169 | parse_str( $body, $values ); |
| 271 | 170 | } |
| 272 | 171 | |
| 273 | 172 | return $this->api->shiftsUpdateById( $id, $values ); |
| 274 | - } | |
| 275 | - | |
| 276 | - public function calendarsGet( $request ) | |
| 277 | - { | |
| 278 | - $queryParams = $request->get_query_params(); | |
| 279 | - $ret = $this->api->calendarsGet( $queryParams ); | |
| 280 | - $ret = new WP_REST_Response( $ret ); | |
| 281 | - return $ret; | |
| 282 | - } | |
| 283 | - | |
| 284 | - public function employeesGet( $request ) | |
| 285 | - { | |
| 286 | - $queryParams = $request->get_query_params(); | |
| 287 | - $ret = $this->api->employeesGet( $queryParams ); | |
| 288 | - $ret = new WP_REST_Response( $ret ); | |
| 289 | - return $ret; | |
| 290 | - } | |
| 291 | - | |
| 292 | - public function employeesGetById( $request ) | |
| 293 | - { | |
| 294 | - $id = $request['id']; | |
| 295 | - return $this->api->employeesGetById( $id ); | |
| 296 | - } | |
| 297 | - | |
| 298 | - public function employeesCreate( $request ) | |
| 299 | - { | |
| 300 | - $isJson = wp_is_json_request(); | |
| 301 | - $values = $isJson ? $request->get_json_params() : $request->get_body_params(); | |
| 302 | - | |
| 303 | - if( ! $values ){ | |
| 304 | - $body = $request->get_body(); | |
| 305 | - parse_str( $body, $values ); | |
| 306 | - } | |
| 307 | - | |
| 308 | - return $this->api->employeesCreate( $request ); | |
| 309 | - } | |
| 310 | - | |
| 311 | - public function employeesGetByUserId( $request ) | |
| 312 | - { | |
| 313 | - $id = $request['id']; | |
| 314 | - return $this->api->employeesGetByUserId( $id ); | |
| 315 | - } | |
| 316 | - | |
| 317 | - public function employeesGetByCalendarId( $request ) | |
| 318 | - { | |
| 319 | - $id = $request['id']; | |
| 320 | - $ret = $this->api->employeesGetByCalendarId( $id ); | |
| 321 | - return $ret; | |
| 322 | - } | |
| 323 | - | |
| 324 | - public function calendarsGetByEmployeeId( $request ) | |
| 325 | - { | |
| 326 | - $id = $request['id']; | |
| 327 | - $ret = $this->api->calendarsGetByEmployeeId( $id ); | |
| 328 | - return $ret; | |
| 329 | - } | |
| 330 | - | |
| 331 | - public function employeesAddToCalendar( $request ) | |
| 332 | - { | |
| 333 | - $eid = $request['eid']; | |
| 334 | - $cid = $request['cid']; | |
| 335 | - $ret = $this->api->employeesAddToCalendar( $eid, $cid ); | |
| 336 | - return $ret; | |
| 337 | - } | |
| 338 | - | |
| 339 | - public function employeesRemoveFromCalendar( $request ) | |
| 340 | - { | |
| 341 | - $eid = $request['eid']; | |
| 342 | - $cid = $request['cid']; | |
| 343 | - $ret = $this->api->employeesRemoveFromCalendar( $eid, $cid ); | |
| 344 | - return $ret; | |
| 345 | 173 | } |
| 346 | 174 | } |