| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
|
| 3 |
$app = 'sh4-rest'; |
| 4 |
|
| 5 |
if( isset($_POST[$app . '_submit']) ){ |
| 6 |
if( isset($_POST[$app]) ){ |
| 7 |
foreach( (array)$_POST[$app] as $key => $value ){ |
| 8 |
$option_name = $app . '_' . $key; |
| 9 |
$value = sanitize_text_field( $value ); |
| 10 |
update_option( $option_name, $value ); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
if( ! isset($_POST[$app]['enabled']) ){ |
| 15 |
$k = $app . '_enabled'; |
| 16 |
$value = 0; |
| 17 |
update_option( $k, $value ); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
// $this->initOption(); |
| 22 |
|
| 23 |
$current = array(); |
| 24 |
$current['enabled'] = get_option( $app . '_enabled', 1 ); |
| 25 |
$current['auth_code'] = get_option( $app . '_auth_code', '' ); |
| 26 |
|
| 27 |
$startUrl = '/shiftcontroller/v4/'; |
| 28 |
|
| 29 |
// spaghetti starts here |
| 30 |
?> |
| 31 |
|
| 32 |
<form method="post" action=""> |
| 33 |
<?php settings_fields( $app ); ?> |
| 34 |
<?php //do_settings_sections( $this->app ); ?> |
| 35 |
|
| 36 |
<label> |
| 37 |
<?php $checked = $current['enabled'] ? ' checked' : ''; ?> |
| 38 |
<input type="checkbox" name="<?php echo $app; ?>[enabled]" value="1" <?php echo $checked; ?>/> |
| 39 |
Enable |
| 40 |
</label> |
| 41 |
</br/> |
| 42 |
|
| 43 |
<label> |
| 44 |
AuthCode<br> |
| 45 |
<input type="text" name="<?php echo $app; ?>[auth_code]" value="<?php echo esc_attr( $current['auth_code'] ); ?>" /> |
| 46 |
</label> |
| 47 |
</br/> |
| 48 |
|
| 49 |
<p> |
| 50 |
<input name="<?php echo $app; ?>_submit" type="submit" class="button-primary" value="Save" /> |
| 51 |
</p> |
| 52 |
</form> |
| 53 |
|
| 54 |
<?php if( ! $current['enabled'] ) return; ?> |
| 55 |
|
| 56 |
|
| 57 |
<style> |
| 58 |
.sh4-code { |
| 59 |
display: block; padding: 1em; border: #999 1px solid; margin-bottom: 1em; |
| 60 |
} |
| 61 |
</style> |
| 62 |
|
| 63 |
<h3 class="hc-underline">Get Shifts</h3> |
| 64 |
<?php |
| 65 |
$url = $startUrl . 'shifts'; |
| 66 |
$fullUrl = get_rest_url( NULL, $url ); |
| 67 |
?> |
| 68 |
|
| 69 |
<p> |
| 70 |
<strong> |
| 71 |
GET <?php echo $url; ?> |
| 72 |
</strong> |
| 73 |
</p> |
| 74 |
|
| 75 |
<p> |
| 76 |
<strong>__Headers__</strong> |
| 77 |
</p> |
| 78 |
|
| 79 |
<p> |
| 80 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 81 |
</p> |
| 82 |
|
| 83 |
<p> |
| 84 |
<strong>__Arguments__</strong> |
| 85 |
</p> |
| 86 |
|
| 87 |
<p> |
| 88 |
<strong>calendar_id</strong> (__Calendar Id__)<br> |
| 89 |
<strong>employee_id</strong> (__Employee Id__)<br> |
| 90 |
<strong>from</strong> (__From Date__, YYYYMMDD / __From Date Time__, YYYYMMDDHHMM)<br> |
| 91 |
<strong>to</strong> (__To Date__, YYYYMMDD / __To Date Time__, YYYYMMDDHHMM)<br> |
| 92 |
<strong>status_id</strong> (publish, draft)<br> |
| 93 |
</p> |
| 94 |
|
| 95 |
<?php if( class_exists('SH4_CFields_Model') ) : ?> |
| 96 |
<?php |
| 97 |
$f = ShiftController4::$instance->root(); |
| 98 |
$cfieldsQuery = $f->make('SH4_CFields_Query'); |
| 99 |
$cfields = $cfieldsQuery->read(); |
| 100 |
?> |
| 101 |
<?php if( $cfields ) : ?> |
| 102 |
<p> |
| 103 |
<strong>__Optional Arguments__</strong> |
| 104 |
</p> |
| 105 |
|
| 106 |
<p> |
| 107 |
<?php foreach( $cfields as $cfield ) : ?> |
| 108 |
<em><?php echo $cfield->getName(); ?></em> (<?php echo $cfield->getLabel(); ?>)<br> |
| 109 |
<?php endforeach; ?> |
| 110 |
</p> |
| 111 |
<?php endif; ?> |
| 112 |
<?php endif; ?> |
| 113 |
|
| 114 |
<?php |
| 115 |
$today = date( 'Ymd' ); |
| 116 |
?> |
| 117 |
|
| 118 |
<p> |
| 119 |
<strong>__Examples__</strong> |
| 120 |
</p> |
| 121 |
|
| 122 |
<pre class="sh4-code"> |
| 123 |
GET <?php echo $fullUrl; ?> |
| 124 |
</pre> |
| 125 |
|
| 126 |
<pre class="sh4-code"> |
| 127 |
GET <?php echo $fullUrl; ?>?calendar_id=11&from=<?php echo $today; ?> |
| 128 |
</pre> |
| 129 |
|
| 130 |
<pre class="sh4-code"> |
| 131 |
GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430&status_id=draft |
| 132 |
</pre> |
| 133 |
|
| 134 |
<h3 class="hc-underline">__Get Shift__</h3> |
| 135 |
<?php |
| 136 |
$url = $startUrl . 'shifts/<id>'; |
| 137 |
$fullUrl = get_rest_url( NULL, $url ); |
| 138 |
|
| 139 |
$url2 = $startUrl . 'shifts'; |
| 140 |
$fullUrl2 = get_rest_url( NULL, $url2 ); |
| 141 |
?> |
| 142 |
|
| 143 |
<p> |
| 144 |
<strong> |
| 145 |
GET <?php echo $url; ?> |
| 146 |
</strong> |
| 147 |
</p> |
| 148 |
|
| 149 |
<p> |
| 150 |
<strong>__Headers__</strong> |
| 151 |
</p> |
| 152 |
|
| 153 |
<p> |
| 154 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 155 |
</p> |
| 156 |
|
| 157 |
<p> |
| 158 |
<strong>__Examples__</strong> |
| 159 |
</p> |
| 160 |
|
| 161 |
<pre class="sh4-code"> |
| 162 |
GET <?php echo $fullUrl2; ?>/123 |
| 163 |
</pre> |
| 164 |
|
| 165 |
<h3 class="hc-underline">__Delete Shift__</h3> |
| 166 |
<?php |
| 167 |
$url = $startUrl . 'shifts/<id>'; |
| 168 |
$fullUrl = get_rest_url( NULL, $url ); |
| 169 |
|
| 170 |
$url2 = $startUrl . 'shifts'; |
| 171 |
$fullUrl2 = get_rest_url( NULL, $url2 ); |
| 172 |
?> |
| 173 |
|
| 174 |
<p> |
| 175 |
<strong> |
| 176 |
DELETE <?php echo $url; ?> |
| 177 |
</strong> |
| 178 |
</p> |
| 179 |
|
| 180 |
<p> |
| 181 |
<strong>__Headers__</strong> |
| 182 |
</p> |
| 183 |
|
| 184 |
<p> |
| 185 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 186 |
</p> |
| 187 |
|
| 188 |
<p> |
| 189 |
<strong>__Examples__</strong> |
| 190 |
</p> |
| 191 |
|
| 192 |
<pre class="sh4-code"> |
| 193 |
DELETE <?php echo $fullUrl2; ?>/123 |
| 194 |
</pre> |
| 195 |
|
| 196 |
<h3 class="hc-underline">__Create Shift__</h3> |
| 197 |
<?php |
| 198 |
$url = $startUrl . 'shifts'; |
| 199 |
$fullUrl = get_rest_url( NULL, $url ); |
| 200 |
?> |
| 201 |
|
| 202 |
<p> |
| 203 |
<strong> |
| 204 |
POST <?php echo $url; ?> |
| 205 |
</strong> |
| 206 |
</p> |
| 207 |
|
| 208 |
<p> |
| 209 |
<strong>__Headers__</strong> |
| 210 |
</p> |
| 211 |
|
| 212 |
<p> |
| 213 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 214 |
</p> |
| 215 |
|
| 216 |
<p> |
| 217 |
<strong>__Arguments__</strong> |
| 218 |
</p> |
| 219 |
|
| 220 |
<p> |
| 221 |
<strong>calendar_id</strong> (__Calendar Id__)<br> |
| 222 |
<strong>employee_id</strong> (__Employee Id__)<br> |
| 223 |
<strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM)<br> |
| 224 |
<strong>end</strong> (__End Date Time__, YYYYMMDDHHMM)<br> |
| 225 |
<strong>status_id</strong> (publish, draft)<br> |
| 226 |
<strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>__optional__</em><br> |
| 227 |
</p> |
| 228 |
|
| 229 |
<p> |
| 230 |
<strong>__Examples__</strong> |
| 231 |
</p> |
| 232 |
|
| 233 |
<pre class="sh4-code"> |
| 234 |
POST <?php echo $fullUrl; ?> |
| 235 |
|
| 236 |
calendar_id: 11 |
| 237 |
employee_id: 22 |
| 238 |
start: <?php echo $today; ?>0800 |
| 239 |
end: <?php echo $today; ?>1430 |
| 240 |
status_id: publish |
| 241 |
</pre> |
| 242 |
|
| 243 |
<p> |
| 244 |
__If success, it returns the id of the new shift. Otherwise error messages will be given.__ |
| 245 |
</p> |
| 246 |
|
| 247 |
<h3 class="hc-underline">__Update Shift__</h3> |
| 248 |
<?php |
| 249 |
$url = $startUrl . 'shifts/<id>'; |
| 250 |
$fullUrl = get_rest_url( NULL, $url ); |
| 251 |
|
| 252 |
$url2 = $startUrl . 'shifts/'; |
| 253 |
$fullUrl2 = get_rest_url( NULL, $url2 ); |
| 254 |
if( '/' == substr($fullUrl2, -1) ){ |
| 255 |
$fullUrl2 = substr( $fullUrl2, 0, -1 ); |
| 256 |
} |
| 257 |
?> |
| 258 |
|
| 259 |
<p> |
| 260 |
<strong> |
| 261 |
PUT <?php echo $url; ?> |
| 262 |
</strong> |
| 263 |
</p> |
| 264 |
|
| 265 |
<p> |
| 266 |
<strong>__Headers__</strong> |
| 267 |
</p> |
| 268 |
|
| 269 |
<p> |
| 270 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 271 |
</p> |
| 272 |
|
| 273 |
<p> |
| 274 |
<strong>__Arguments__</strong> |
| 275 |
</p> |
| 276 |
|
| 277 |
<p> |
| 278 |
<strong>calendar_id</strong> (__Calendar Id__) <em>__optional__</em><br> |
| 279 |
<strong>employee_id</strong> (__Employee Id__) <em>__optional__</em><br> |
| 280 |
<strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br> |
| 281 |
<strong>end</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br> |
| 282 |
<strong>status_id</strong> (publish, draft) <em>__optional__</em><br> |
| 283 |
<strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>__optional__</em><br> |
| 284 |
</p> |
| 285 |
|
| 286 |
<p> |
| 287 |
<strong>__Examples__</strong> |
| 288 |
</p> |
| 289 |
|
| 290 |
<pre class="sh4-code"> |
| 291 |
PUT <?php echo $fullUrl2; ?>/123 |
| 292 |
start: <?php echo $today; ?>0900 |
| 293 |
end: <?php echo $today; ?>1530 |
| 294 |
</pre> |
| 295 |
|
| 296 |
<pre class="sh4-code"> |
| 297 |
PUT <?php echo $fullUrl2; ?>/123 |
| 298 |
employee_id: 22 |
| 299 |
</pre> |
| 300 |
|
| 301 |
<pre class="sh4-code"> |
| 302 |
PUT <?php echo $fullUrl2; ?>/123 |
| 303 |
status_id: publish |
| 304 |
</pre> |
| 305 |
|
| 306 |
<h3 class="hc-underline">__Get Available Employees__</h3> |
| 307 |
<?php |
| 308 |
$url = $startUrl . 'available-employees'; |
| 309 |
$fullUrl = get_rest_url( NULL, $url ); |
| 310 |
?> |
| 311 |
|
| 312 |
<p> |
| 313 |
<strong> |
| 314 |
GET <?php echo $url; ?> |
| 315 |
</strong> |
| 316 |
</p> |
| 317 |
|
| 318 |
<p> |
| 319 |
<strong>__Headers__</strong> |
| 320 |
</p> |
| 321 |
|
| 322 |
<p> |
| 323 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 324 |
</p> |
| 325 |
|
| 326 |
<p> |
| 327 |
<strong>__Arguments__</strong> |
| 328 |
</p> |
| 329 |
|
| 330 |
<p> |
| 331 |
<strong>calendar_id</strong> (__Calendar Id__) <em>__optional__</em><br> |
| 332 |
<em>__default value__</em>: __all shift-type calendars__<br> |
| 333 |
|
| 334 |
<strong>from</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br> |
| 335 |
<em>__default value__</em>: __beginning of today__<br> |
| 336 |
|
| 337 |
<strong>to</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br> |
| 338 |
<em>__default value__</em>: __one day from the start__<br> |
| 339 |
|
| 340 |
</p> |
| 341 |
|
| 342 |
<p> |
| 343 |
<strong>__Examples__</strong> |
| 344 |
</p> |
| 345 |
|
| 346 |
<pre class="sh4-code"> |
| 347 |
GET <?php echo $fullUrl; ?> |
| 348 |
</pre> |
| 349 |
|
| 350 |
<pre class="sh4-code"> |
| 351 |
GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430 |
| 352 |
</pre> |
| 353 |
|
| 354 |
<pre class="sh4-code"> |
| 355 |
GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>&calendar_id=123 |
| 356 |
</pre> |
| 357 |
|
| 358 |
<pre class="sh4-code"> |
| 359 |
GET <?php echo $fullUrl; ?>?calendar_id[]=123&calendar_id[]=456 |
| 360 |
</pre> |
| 361 |
|
| 362 |
<p> |
| 363 |
<strong>__Example return__</strong> |
| 364 |
</p> |
| 365 |
|
| 366 |
<pre class="sh4-code"> |
| 367 |
{ |
| 368 |
"from": "<?php echo $today; ?>0900", |
| 369 |
"to": "<?php echo $today; ?>1430", |
| 370 |
"employees": [ |
| 371 |
{ |
| 372 |
"id": "523", |
| 373 |
"title": "Alice", |
| 374 |
"email": "alice@host.local", |
| 375 |
"username": "alice" |
| 376 |
}, |
| 377 |
{ |
| 378 |
"id": "527", |
| 379 |
"title": "Eve", |
| 380 |
"email": "eve@host.local", |
| 381 |
"username": "eve" |
| 382 |
} |
| 383 |
] |
| 384 |
} |
| 385 |
</pre> |
| 386 |
|
| 387 |
<h3 class="hc-underline">__Get All Calendars__</h3> |
| 388 |
<?php |
| 389 |
$url = $startUrl . 'calendars'; |
| 390 |
$fullUrl = get_rest_url( NULL, $url ); |
| 391 |
?> |
| 392 |
|
| 393 |
<p> |
| 394 |
<strong> |
| 395 |
GET <?php echo $url; ?> |
| 396 |
</strong> |
| 397 |
</p> |
| 398 |
|
| 399 |
<p> |
| 400 |
<strong>__Headers__</strong> |
| 401 |
</p> |
| 402 |
|
| 403 |
<p> |
| 404 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 405 |
</p> |
| 406 |
|
| 407 |
<p> |
| 408 |
<strong>__Examples__</strong> |
| 409 |
</p> |
| 410 |
|
| 411 |
<pre class="sh4-code"> |
| 412 |
GET <?php echo $fullUrl; ?> |
| 413 |
</pre> |
| 414 |
|
| 415 |
<p> |
| 416 |
<strong>__Example return__</strong> |
| 417 |
</p> |
| 418 |
|
| 419 |
<pre class="sh4-code"> |
| 420 |
[ |
| 421 |
{ |
| 422 |
"id": "12", |
| 423 |
"title": "Barista", |
| 424 |
"type": "shift", |
| 425 |
"active": "1" |
| 426 |
}, |
| 427 |
{ |
| 428 |
"id": "13", |
| 429 |
"title": "Server", |
| 430 |
"type": "shift", |
| 431 |
"active": "0" |
| 432 |
}, |
| 433 |
{ |
| 434 |
"id": "14", |
| 435 |
"title": "Holidays", |
| 436 |
"type": "timeoff", |
| 437 |
"active": "0" |
| 438 |
} |
| 439 |
] |
| 440 |
</pre> |
| 441 |
|
| 442 |
<h3 class="hc-underline">__Get All Employees__</h3> |
| 443 |
<?php |
| 444 |
$url = $startUrl . 'employees'; |
| 445 |
$fullUrl = get_rest_url( NULL, $url ); |
| 446 |
?> |
| 447 |
|
| 448 |
<p> |
| 449 |
<strong> |
| 450 |
GET <?php echo $url; ?> |
| 451 |
</strong> |
| 452 |
</p> |
| 453 |
|
| 454 |
<p> |
| 455 |
<strong>__Headers__</strong> |
| 456 |
</p> |
| 457 |
|
| 458 |
<p> |
| 459 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 460 |
</p> |
| 461 |
|
| 462 |
<p> |
| 463 |
<strong>__Examples__</strong> |
| 464 |
</p> |
| 465 |
|
| 466 |
<pre class="sh4-code"> |
| 467 |
GET <?php echo $fullUrl; ?> |
| 468 |
</pre> |
| 469 |
|
| 470 |
<p> |
| 471 |
<strong>__Example return__</strong> |
| 472 |
</p> |
| 473 |
|
| 474 |
<pre class="sh4-code"> |
| 475 |
[ |
| 476 |
{ |
| 477 |
"id": "523", |
| 478 |
"title": "Alice", |
| 479 |
"email": "alice@host.local", |
| 480 |
"username": "alice" |
| 481 |
}, |
| 482 |
{ |
| 483 |
"id": "527", |
| 484 |
"title": "Eve", |
| 485 |
"email": "eve@host.local", |
| 486 |
"username": "eve" |
| 487 |
} |
| 488 |
] |
| 489 |
</pre> |
| 490 |
|
| 491 |
<h3 class="hc-underline">__Get Calendars For Employee__</h3> |
| 492 |
<?php |
| 493 |
$url = $startUrl . 'employees/<id>/calendars'; |
| 494 |
$fullUrl = get_rest_url( null, $url ); |
| 495 |
|
| 496 |
$url2 = $startUrl . 'employees'; |
| 497 |
$fullUrl2 = get_rest_url( null, $url2 ); |
| 498 |
?> |
| 499 |
|
| 500 |
<p> |
| 501 |
<strong> |
| 502 |
GET <?php echo $url; ?> |
| 503 |
</strong> |
| 504 |
</p> |
| 505 |
|
| 506 |
<p> |
| 507 |
<strong>__Headers__</strong> |
| 508 |
</p> |
| 509 |
|
| 510 |
<p> |
| 511 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 512 |
</p> |
| 513 |
|
| 514 |
<p> |
| 515 |
<strong>__Examples__</strong> |
| 516 |
</p> |
| 517 |
|
| 518 |
<pre class="sh4-code"> |
| 519 |
GET <?php echo $fullUrl2; ?>/123/calendars |
| 520 |
</pre> |
| 521 |
|
| 522 |
<h3 class="hc-underline">__Get Employees Eligible For Calendar__</h3> |
| 523 |
<?php |
| 524 |
$url = $startUrl . 'calendars/<id>/employees'; |
| 525 |
$fullUrl = get_rest_url( null, $url ); |
| 526 |
|
| 527 |
$url2 = $startUrl . 'calendars'; |
| 528 |
$fullUrl2 = get_rest_url( null, $url2 ); |
| 529 |
?> |
| 530 |
|
| 531 |
<p> |
| 532 |
<strong> |
| 533 |
GET <?php echo $url; ?> |
| 534 |
</strong> |
| 535 |
</p> |
| 536 |
|
| 537 |
<p> |
| 538 |
<strong>__Headers__</strong> |
| 539 |
</p> |
| 540 |
|
| 541 |
<p> |
| 542 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 543 |
</p> |
| 544 |
|
| 545 |
<p> |
| 546 |
<strong>__Examples__</strong> |
| 547 |
</p> |
| 548 |
|
| 549 |
<pre class="sh4-code"> |
| 550 |
GET <?php echo $fullUrl2; ?>/654/employees |
| 551 |
</pre> |
| 552 |
|
| 553 |
<h3 class="hc-underline">__Add Employee To Calendar__</h3> |
| 554 |
<?php |
| 555 |
$url = $startUrl . 'calendars/<cid>/employees/<eid>'; |
| 556 |
$fullUrl = get_rest_url( null, $url ); |
| 557 |
|
| 558 |
$url2 = $startUrl . 'calendars'; |
| 559 |
$fullUrl2 = get_rest_url( null, $url2 ); |
| 560 |
?> |
| 561 |
|
| 562 |
<p> |
| 563 |
<strong> |
| 564 |
POST <?php echo $url; ?> |
| 565 |
</strong> |
| 566 |
</p> |
| 567 |
|
| 568 |
<?php |
| 569 |
$url = $startUrl . 'employees/<eid>/calendars/<cid>'; |
| 570 |
$fullUrl = get_rest_url( null, $url ); |
| 571 |
|
| 572 |
$url3 = $startUrl . 'employees'; |
| 573 |
$fullUrl3 = get_rest_url( null, $url3 ); |
| 574 |
?> |
| 575 |
|
| 576 |
<p> |
| 577 |
<strong> |
| 578 |
POST <?php echo $url; ?> |
| 579 |
</strong> |
| 580 |
</p> |
| 581 |
|
| 582 |
<p> |
| 583 |
<strong>__Headers__</strong> |
| 584 |
</p> |
| 585 |
|
| 586 |
<p> |
| 587 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 588 |
</p> |
| 589 |
|
| 590 |
<p> |
| 591 |
<strong>__Examples__</strong> |
| 592 |
</p> |
| 593 |
|
| 594 |
<pre class="sh4-code"> |
| 595 |
POST <?php echo $fullUrl2; ?>/654/employees/123 |
| 596 |
</pre> |
| 597 |
|
| 598 |
<pre class="sh4-code"> |
| 599 |
POST <?php echo $fullUrl3; ?>/123/calendars/654 |
| 600 |
</pre> |
| 601 |
|
| 602 |
<h3 class="hc-underline">__Remove Employee From Calendar__</h3> |
| 603 |
<?php |
| 604 |
$url = $startUrl . 'calendars/<cid>/employees/<eid>'; |
| 605 |
$fullUrl = get_rest_url( null, $url ); |
| 606 |
|
| 607 |
$url2 = $startUrl . 'calendars'; |
| 608 |
$fullUrl2 = get_rest_url( null, $url2 ); |
| 609 |
?> |
| 610 |
|
| 611 |
<p> |
| 612 |
<strong> |
| 613 |
DELETE <?php echo $url; ?> |
| 614 |
</strong> |
| 615 |
</p> |
| 616 |
|
| 617 |
<?php |
| 618 |
$url = $startUrl . 'employees/<eid>/calendars/<cid>'; |
| 619 |
$fullUrl = get_rest_url( null, $url ); |
| 620 |
|
| 621 |
$url3 = $startUrl . 'employees'; |
| 622 |
$fullUrl3 = get_rest_url( null, $url3 ); |
| 623 |
?> |
| 624 |
|
| 625 |
<p> |
| 626 |
<strong> |
| 627 |
DELETE <?php echo $url; ?> |
| 628 |
</strong> |
| 629 |
</p> |
| 630 |
|
| 631 |
<p> |
| 632 |
<strong>__Headers__</strong> |
| 633 |
</p> |
| 634 |
|
| 635 |
<p> |
| 636 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 637 |
</p> |
| 638 |
|
| 639 |
<p> |
| 640 |
<strong>__Examples__</strong> |
| 641 |
</p> |
| 642 |
|
| 643 |
<pre class="sh4-code"> |
| 644 |
DELETE <?php echo $fullUrl2; ?>/654/employees/123 |
| 645 |
</pre> |
| 646 |
|
| 647 |
<pre class="sh4-code"> |
| 648 |
DELETE <?php echo $fullUrl3; ?>/123/calendars/654 |
| 649 |
</pre> |
| 650 |
|
| 651 |
<h3 class="hc-underline">__Get Employee__</h3> |
| 652 |
<?php |
| 653 |
$url = $startUrl . 'employees/<id>'; |
| 654 |
$fullUrl = get_rest_url( null, $url ); |
| 655 |
|
| 656 |
$url2 = $startUrl . 'employees'; |
| 657 |
$fullUrl2 = get_rest_url( null, $url2 ); |
| 658 |
?> |
| 659 |
|
| 660 |
<p> |
| 661 |
<strong> |
| 662 |
GET <?php echo $url; ?> |
| 663 |
</strong> |
| 664 |
</p> |
| 665 |
|
| 666 |
<p> |
| 667 |
<strong>__Headers__</strong> |
| 668 |
</p> |
| 669 |
|
| 670 |
<p> |
| 671 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 672 |
</p> |
| 673 |
|
| 674 |
<p> |
| 675 |
<strong>__Examples__</strong> |
| 676 |
</p> |
| 677 |
|
| 678 |
<pre class="sh4-code"> |
| 679 |
GET <?php echo $fullUrl2; ?>/123 |
| 680 |
</pre> |
| 681 |
|
| 682 |
<h3 class="hc-underline">__Get Employee By User Id__</h3> |
| 683 |
<?php |
| 684 |
$url = $startUrl . 'users/<id>/employee'; |
| 685 |
$fullUrl = get_rest_url( null, $url ); |
| 686 |
|
| 687 |
$url2 = $startUrl . 'users'; |
| 688 |
$fullUrl2 = get_rest_url( null, $url2 ); |
| 689 |
?> |
| 690 |
|
| 691 |
<p> |
| 692 |
<strong> |
| 693 |
GET <?php echo $url; ?> |
| 694 |
</strong> |
| 695 |
</p> |
| 696 |
|
| 697 |
<p> |
| 698 |
<strong>__Headers__</strong> |
| 699 |
</p> |
| 700 |
|
| 701 |
<p> |
| 702 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 703 |
</p> |
| 704 |
|
| 705 |
<p> |
| 706 |
<strong>__Examples__</strong> |
| 707 |
</p> |
| 708 |
|
| 709 |
<pre class="sh4-code"> |
| 710 |
GET <?php echo $fullUrl2; ?>/321/employee |
| 711 |
</pre> |
| 712 |
|
| 713 |
<h3 class="hc-underline">__Create Employee__</h3> |
| 714 |
<?php |
| 715 |
$url = $startUrl . 'employees'; |
| 716 |
$fullUrl = get_rest_url( NULL, $url ); |
| 717 |
?> |
| 718 |
|
| 719 |
<p> |
| 720 |
<strong> |
| 721 |
POST <?php echo $url; ?> |
| 722 |
</strong> |
| 723 |
</p> |
| 724 |
|
| 725 |
<p> |
| 726 |
<strong>__Headers__</strong> |
| 727 |
</p> |
| 728 |
|
| 729 |
<p> |
| 730 |
X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?> |
| 731 |
</p> |
| 732 |
|
| 733 |
<p> |
| 734 |
<strong>__Arguments__</strong> |
| 735 |
</p> |
| 736 |
|
| 737 |
<p> |
| 738 |
<strong>title</strong><br> |
| 739 |
<strong>user_id</strong> <em>__optional__</em><br> |
| 740 |
<strong>description</strong> <em>__optional__</em><br> |
| 741 |
</p> |
| 742 |
|
| 743 |
<p> |
| 744 |
__Either title or user_id required.__ __If user_id is given, it will link the new employee to this WordPress user.__ |
| 745 |
__If user_id is given without the title, it will create a new employee with this WordPress user's full name as employee's title and link this employee to this user.__ |
| 746 |
</p> |
| 747 |
|
| 748 |
<p> |
| 749 |
<strong>__Examples__</strong> |
| 750 |
</p> |
| 751 |
|
| 752 |
<pre class="sh4-code"> |
| 753 |
POST <?php echo $fullUrl; ?> |
| 754 |
|
| 755 |
title: James |
| 756 |
</pre> |
| 757 |
|
| 758 |
<p> |
| 759 |
__If success, it returns the id of the new employee. Otherwise error messages will be given.__ |
| 760 |
</p> |
| 761 |
|