// api/admin-device-action.prg — Format device approve/revoke/delete response // ctx: device_id, action (approved|revoked|deleted), success (1|0) FUNCTION Main() LOCAL lOk := ctx_get("success", "0") == "1" IF lOk AP_JSONRESPONSE({ ; "ok" => .t., ; "deviceId" => ctx_get("device_id", ""), ; "action" => ctx_get("action", "") ; }) ELSE AP_JSONRESPONSE({ ; "error" => { ; "code" => "DEVICE_NOT_FOUND", ; "message" => "Device not found: " + ctx_get("device_id", ""), ; "status" => 404 ; } ; }, 404) ENDIF RETURN NIL