API Version: Development

Nightmode

Permissions

Requires System-Admin, Company-Admin or Nightmode permissions.

command 'read'

Path: /rest/dialplan/read/
Read current nightmode settings for one or more companies.
{
    "type": "nm",
    "scope": {
        "company": ["company-id", ...]
    }
}
For example:
{
    "type": "nm",
    "scope": {
        "company": ["default"]
    }
}
Format of result:
{
    "result": "success",
    "values": {
        "default": {
            1: "sched",
            2: "sched",
            3: "sched",
            4: "sched",
            5: "sched",
            6: "sched",
            7: "on",
            8: "off",
            9: "sched",
            10: "sched"
        }
    }
}

command 'update'

Path: /rest/dialplan/update/
Update nightmode settings for one or more companies and one or more nightmodes.
{
    "type": "nm",
    "scope": {
        "company": ["company-id", ...]
    },
    "values": {
        "1": "on" or "off" or "sched",
        ... missing values unchanged ...
        "10": "on" or "off" or "sched"
    }
}
For example:
{
    "type": "nm",
    "scope": {
        "company": ["default"]
    },
    "values": {
        "2": "off",
        "3": "on",
        "4": "sched"
    }
}

command 'readnames'

Path: /rest/dialplan/readnames/
Read the names of the numbered night modes 6.3+.
{
    "type": "nm",
    "scope": {
        "company": ["company-id", ...]
    }
}
Return value:
{
    "result": "success",
    "values": {
        "company id": [
            "Nightmode zero name",
            ...
        ],
        ...
    }
}
For example:
{
    "type": "nm",
    "scope": {
        "company": [
            "default",
            "office"
        ]
    }
}
{
    "result": "success",
    "values": {
        "default": [
            "Secretarial",
            null,
            "Medical"
        ],
        "office": [
            "open hours",
            "lunchtime"
        ]
    }
}

command 'readcal'

Path: /rest/dialplan/readcal/
Read the list of nightmode calendar events 6.3+.
{
    "type": "nm",
    "scope": {
        "company": ["company-id", ...]
    }
}
Return value (columns are not selectable):
{
    "result": "success",
    "values": {
        "company id": [
            {
                "owner_id": company-owner-id,
                "event_type": "NMCAL",
                "event_id": unique-event-id,
                "event_instance": "nightmode-num-affected",
                "event_repeat": "NEVER|DAY|WEEK|MONTH|YEAR",
                "event_start": epoch-milliseconds-next-event-starts,
                "event_end": epoch-milliseconds-next-event-ends,
                "event_action": "ON|OFF",
                "event_last": epoch-milliseconds-event-expires
            },
            ...
        ],
        ...
    }
}
For example:
{
    "type": "nm",
    "scope": {
        "company": [
            "default"
        ]
    }
}
{
    "result": "success",
    "values": {
        "default": [
            {
                "owner_id": 7,
                "event_type": "NMCAL",
                "event_id": 844,
                "event_instance": "1",
                "event_repeat": "YEAR",
                "event_start": 1545696000000,
                "event_end": 1577350800000,
                "event_action": "ON",
                "event_last": null
            },
            {
                "owner_id": 7,
                "event_type": "NMCAL",
                "event_id": 848,
                "event_instance": "3",
                "event_repeat": "YEAR",
                "event_start": 1545696000000,
                "event_end": 1577350800000,
                "event_action": "ON",
                "event_last": null
            },
            {
                "owner_id": 7,
                "event_type": "NMCAL",
                "event_id": 849,
                "event_instance": "0",
                "event_repeat": "NEVER",
                "event_start": 1514160000000,
                "event_end": 1514278800000,
                "event_action": "OFF",
                "event_last": null
            }
        ]
    }
}

command 'createcal'

Path: /rest/dialplan/createcal/
Create a new nightmode calendar event 6.3+.
{       
    "type": "nm",
    "values": {
        "company": "company-id",
        "instance": nightmode-number,
        "start": start-date-of-event,
        "end": end-date-of-event,
        "last": event-expiry (optional),
        "repeat": "NEVER|DAY|WEEK|MONTH|YEAR",
        "action": "ON|OFF"
    }
}
Return value (columns are not selectable):
{       
    "result": "success",
    "event_id": event_id,
    "owner_id": owner_id
}
For example:
{
    "type": "nm",
    "values": {
        "company": "test",
        "instance": 3,
        "start": 1536487200000,
        "end": 1559419200000,
        "last": null,
        "repeat": "YEAR",
        "action": "ON"
    }
}
{
    "result": "success",
    "event_id": 1234,
    "owner_id": 567
}

command 'deletecal'

Path: /rest/dialplan/deletecal/
Delete a nightmode calendar event 6.3+.
{
    "type": "nm",
    "scope": {
        "event_id": [event-id, ...]
    }
}
Return value:
{
    "result": "success",
    "numrows": number-of-entries-deleted
}