$value ){ $option_name = $app . '_' . $key; $value = sanitize_text_field( $value ); update_option( $option_name, $value ); } } if( ! isset($_POST[$app]['enabled']) ){ $k = $app . '_enabled'; $value = 0; update_option( $k, $value ); } } // $this->initOption(); $current = array(); $current['enabled'] = get_option( $app . '_enabled', 1 ); $current['auth_code'] = get_option( $app . '_auth_code', '' ); $startUrl = '/shiftcontroller/v4/'; // spaghetti starts here ?>
app ); ?>

Get Shifts

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Arguments__

calendar_id (__Calendar Id__)
employee_id (__Employee Id__)
from (__From Date__, YYYYMMDD / __From Date Time__, YYYYMMDDHHMM)
to (__To Date__, YYYYMMDD / __To Date Time__, YYYYMMDDHHMM)
status_id (publish, draft)

root(); $cfieldsQuery = $f->make('SH4_CFields_Query'); $cfields = $cfieldsQuery->read(); ?>

__Optional Arguments__

getName(); ?> (getLabel(); ?>)

__Examples__

GET 
GET ?calendar_id=11&from=
GET ?from=0900&to=1430&status_id=draft

__Get Shift__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET /123

__Delete Shift__

DELETE

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

DELETE /123

__Create Shift__

POST

__Headers__

X-WP-ShiftController-AuthCode:

__Arguments__

calendar_id (__Calendar Id__)
employee_id (__Employee Id__)
start (__Start Date Time__, YYYYMMDDHHMM)
end (__End Date Time__, YYYYMMDDHHMM)
status_id (publish, draft)
conflict (__Set to 1 to allow creation of shifts with conflicts__) __optional__

__Examples__

POST 

calendar_id: 11
employee_id: 22
start: 0800
end: 1430
status_id: publish

__If success, it returns the id of the new shift. Otherwise error messages will be given.__

__Update Shift__

PUT

__Headers__

X-WP-ShiftController-AuthCode:

__Arguments__

calendar_id (__Calendar Id__) __optional__
employee_id (__Employee Id__) __optional__
start (__Start Date Time__, YYYYMMDDHHMM) __optional__
end (__End Date Time__, YYYYMMDDHHMM) __optional__
status_id (publish, draft) __optional__
conflict (__Set to 1 to allow creation of shifts with conflicts__) __optional__

__Examples__

PUT /123
start: 0900
end: 1530
PUT /123
employee_id: 22
PUT /123
status_id: publish

__Get Available Employees__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Arguments__

calendar_id (__Calendar Id__) __optional__
__default value__: __all shift-type calendars__
from (__Start Date Time__, YYYYMMDDHHMM) __optional__
__default value__: __beginning of today__
to (__End Date Time__, YYYYMMDDHHMM) __optional__
__default value__: __one day from the start__

__Examples__

GET 
GET ?from=0900&to=1430
GET ?from=&calendar_id=123
GET ?calendar_id[]=123&calendar_id[]=456

__Example return__

{
  "from": "0900",
  "to": "1430",
  "employees": [
    {
      "id": "523",
      "title": "Alice",
      "email": "alice@host.local",
      "username": "alice"
    },
    {
      "id": "527",
      "title": "Eve",
      "email": "eve@host.local",
      "username": "eve"
    }
  ]
}

__Get All Calendars__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET 

__Example return__

[
    {
      "id": "12",
      "title": "Barista",
      "type": "shift",
      "active": "1"
    },
    {
      "id": "13",
      "title": "Server",
      "type": "shift",
      "active": "0"
    },
    {
      "id": "14",
      "title": "Holidays",
      "type": "timeoff",
      "active": "0"
    }
]

__Get All Employees__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET 

__Example return__

[
    {
      "id": "523",
      "title": "Alice",
      "email": "alice@host.local",
      "username": "alice"
    },
    {
      "id": "527",
      "title": "Eve",
      "email": "eve@host.local",
      "username": "eve"
    }
]

__Get Calendars For Employee__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET /123/calendars

__Get Employees Eligible For Calendar__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET /654/employees

__Add Employee To Calendar__

POST

POST

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

POST /654/employees/123
POST /123/calendars/654

__Remove Employee From Calendar__

DELETE

DELETE

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

DELETE /654/employees/123
DELETE /123/calendars/654

__Get Employee__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET /123

__Get Employee By User Id__

GET

__Headers__

X-WP-ShiftController-AuthCode:

__Examples__

GET /321/employee

__Create Employee__

POST

__Headers__

X-WP-ShiftController-AuthCode:

__Arguments__

title
user_id __optional__
description __optional__

__Either title or user_id required.__ __If user_id is given, it will link the new employee to this WordPress user.__ __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.__

__Examples__

POST 

title: James

__If success, it returns the id of the new employee. Otherwise error messages will be given.__