{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "allOf": [ { "type": "object", "properties": { "eventId": { "type": "string", "format": "uuid" }, "deviceId": { "type": "string", "format": "uuid" }, "time": { "type": "string", "format": "date-time"}, "version": { "type": "string"}, "required": [ "eventId", "deviceId", "time", "version"] }, } { "oneOf": [ { "$ref": "#/$defs/deviceUpdate" }, { "$ref": "#/$defs/accessCodeUpdate" }, { "$ref": "#/$defs/commandUpdate" }, { "$ref": "#/$defs/userDevicesUpdate" } ] } ], "$defs": { "deviceUpdate": { "allOf": [ { "type": "object", "properties": { "eventType": { "const": "DeviceUpdate" } } }, { "oneOf": [ { "$ref": "#/$defs/deviceLockStateChanged" }, { "$ref": "#/$defs/deviceBatteryStateChanged" }, { "$ref": "#/$defs/deviceConnectivityStateChanged" }, { "$ref": "#/$defs/deviceAlarmStateChanged" }, { "$ref": "#/$defs/deviceKeypadLockoutStateChanged" } ] } ] }, "deviceLockStateChanged": { "type": "object", "properties": { "trigger": { "const": "DeviceLockStateChanged" }, "data": { "type": "object", "properties": { "lockState": { "type": "string", "enum": [ "Unlocked", "Locked", "Jammmed", "Unknown" ] } }, "accessor": { "type": [ "object", "null" ], "properties": { "id": { "type": [ "string", "null" ], "format": "uuid" }, "accessType": { "type": "string", "enum": [ "AccessCode", "VirtualKey", "AutoRelock", "Thumbturn", "1TouchLocking" ] } }, "required": [ "accessType" ] } }, "required": [ "lockState" ] } }, "required": [ "trigger", "data" ] }, "deviceBatteryStateChanged": { "type": "object", "properties": { "trigger": { "const": "DeviceBatteryStateChanged" }, "data": { "type": "object", "properties": { "batteryState": { "type": "string", "enum": [ "Normal", "Low", "CriticallyLow", "Unknown" ] }, "percentageBatteryLevel": { "type": "integer", "minimum": 0, "maximum": 100 } }, "required": [ "batteryState", "percentageBatteryLevel" ] } }, "required": [ "trigger", "data" ] }, "deviceConnectivityStateChanged": { "type": "object", "properties": { "trigger": { "const": "DeviceConnectivityStateChanged" }, "data": { "type": "object", "properties": { "connected": { "type": "boolean" } }, "required": [ "connected" ] } }, "required": [ "trigger", "data" ] }, "deviceAlarmStateChanged": { "type": "object", "properties": { "trigger": { "const": "DeviceAlarmStateChanged" }, "data": { "type": "object", "properties": { "inAlarm": { "type": "boolean" } }, "required": [ "inAlarm" ] } }, "required": [ "trigger", "data" ] }, "deviceKeypadLockoutStateChanged": { "type": "object", "properties": { "trigger": { "const": "DeviceKeypadLockoutStateChanged" }, "data": { "type": "object", "properties": { "lockedOut": { "type": "boolean" } }, "required": [ "lockedOut" ] } }, "required": [ "trigger", "data" ] }, "accessCodeUpdate": { "type": "object", "properties": { "eventType": { "const": "AccessCodeUpdate" }, "trigger": { "type": "string", "enum": [ "AccessCodeAdded", "AccessCodeUpdated", "AccessCodeDeleted" ] }, "data": { "type": "object", "properties": { "accessCodeId": { "type": "string", "format": "uuid" } }, "required": [ "accessCodeId" ] } }, "required": [ "eventType", "trigger", "data" ] }, "commandUpdate": { "allOf": [ { "type": "object", "properties": { "eventType": { "const": "CommandUpdate" } }, "required": [ "eventType" ] }, { "oneOf": [ { "$ref": "#/$defs/commandSucceeded" }, { "$ref": "#/$defs/commandFailed" }, { "$ref": "#/$defs/commandTimedOut"} ] } ] }, "commandSucceeded": { "type": "object", "properties": { "trigger": { "const": "CommandSucceeded" }, "data": { "$ref": "#/$defs/commandData" } } }, "commandFailed": { "type": "object", "properties": { "trigger": { "const": "CommandFailed" }, "data": { "allOf": [ { "type": "object", "properties": { "errorCode": { "type": "integer" }, "errorMessage": { "type": "string" } }, "required": [ "errorCode", "errorMessage" ] }, { "$ref": "#/$defs/commandData" } ] } } }, "commandTimedOut": { "type": "object", "properties": { "trigger": { "const": "CommandTimedOut" }, "data": { "$ref": "#/$defs/commandData" } } }, "commandData": { "type": "object", "properties": { "commandId": { "type": "string", "format": "uuid" }, "commandType": { "type": "string", "enum": [ "SetLockState", "AddAccessCode", "UpdateAccessCode", "DeleteAccessCode", "DeleteAllAccessCodes" ]}, "clientId": { "type": "string" } }, "required": [ "commandId", "clientId", "commandType" ] }, "userDevicesUpdate": { "type": "object", "properties": { "eventType": { "const": "UserDevicesUpdate" }, "trigger": { "type": "string", "enum": [ "DeviceAdded", "DeviceNameChanged", "DeviceRemoved" ] }, "data": { "type": "object", "properties": { "name": { "type": ["string", "null"] } }, "required": [ "name" ] } }, "required": [ "eventType", "trigger", "data" ] } }