mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 02:51:44 +00:00
Compare commits
11 Commits
SP-1285-FE
...
SP-1416
| Author | SHA1 | Date | |
|---|---|---|---|
| 99adb1c286 | |||
| dd66e7c747 | |||
| 7af61d2f65 | |||
| f37eacb0ee | |||
| c7dcc297aa | |||
| aefe5ad081 | |||
| 8d9af8519d | |||
| b1d52937c9 | |||
| 5fedf37421 | |||
| 4c8f2c72df | |||
| fb867e5df3 |
2
.env.dev
2
.env.dev
@ -1,3 +1,5 @@
|
|||||||
ENV_NAME=development
|
ENV_NAME=development
|
||||||
BASE_URL=https://syncrow-dev.azurewebsites.net
|
BASE_URL=https://syncrow-dev.azurewebsites.net
|
||||||
PROJECT_ID=0e62577c-06fa-41b9-8a92-99a21fbaf51c
|
PROJECT_ID=0e62577c-06fa-41b9-8a92-99a21fbaf51c
|
||||||
|
CLIENT_ID=c024573d191a327ce74db7d4502fdc29
|
||||||
|
CLIENT_SECRET=fec6ccbc33664f94a3b84a45c7cceef3f3ebd1613ef4307db8946ede530cd1ed
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/signup_model.dart';
|
import 'package:syncrow_app/features/auth/model/signup_model.dart';
|
||||||
@ -217,9 +218,22 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
signUp() async {
|
signUp() async {
|
||||||
emit(AuthLoginLoading());
|
emit(AuthLoginLoading());
|
||||||
final response;
|
final response;
|
||||||
|
|
||||||
|
final clientId = dotenv.env['CLIENT_ID'] ?? '';
|
||||||
|
final clientSecret = dotenv.env['CLIENT_SECRET'] ?? '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> userFullName = fullName.split(' ');
|
List<String> userFullName = fullName.split(' ');
|
||||||
|
|
||||||
|
final clientToken = await AuthenticationAPI.fetchClientToken(
|
||||||
|
clientId: clientId,
|
||||||
|
clientSecret: clientSecret,
|
||||||
|
);
|
||||||
|
|
||||||
|
final accessToken = clientToken['accessToken'];
|
||||||
|
|
||||||
response = await AuthenticationAPI.signUp(
|
response = await AuthenticationAPI.signUp(
|
||||||
|
accessToken: accessToken,
|
||||||
model: SignUpModel(
|
model: SignUpModel(
|
||||||
hasAcceptedAppAgreement: true,
|
hasAcceptedAppAgreement: true,
|
||||||
email: email.toLowerCase(),
|
email: email.toLowerCase(),
|
||||||
|
|||||||
@ -169,19 +169,18 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DeviceModel> _getOnlyImplementedDevices(List<DeviceModel> devices) {
|
_getOnlyImplementedDevices(List<DeviceModel> devices) {
|
||||||
const allowedDeviceTypes = {
|
List<DeviceModel> implementedDevices = [];
|
||||||
DeviceType.AC,
|
for (int i = 0; i < devices.length; i++) {
|
||||||
DeviceType.DoorLock,
|
if (devices[i].productType == DeviceType.AC ||
|
||||||
DeviceType.Gateway,
|
devices[i].productType == DeviceType.DoorLock ||
|
||||||
DeviceType.WallSensor,
|
devices[i].productType == DeviceType.Gateway ||
|
||||||
DeviceType.CeilingSensor,
|
devices[i].productType == DeviceType.WallSensor ||
|
||||||
DeviceType.ThreeGang,
|
devices[i].productType == DeviceType.CeilingSensor ||
|
||||||
DeviceType.OneGang,
|
devices[i].productType == DeviceType.ThreeGang) {
|
||||||
};
|
implementedDevices.add(devices[i]);
|
||||||
|
}
|
||||||
return devices
|
}
|
||||||
.where((device) => allowedDeviceTypes.contains(device.productType))
|
return implementedDevices;
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,78 +0,0 @@
|
|||||||
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
|
||||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
|
||||||
|
|
||||||
class OneGangHelperFunctions {
|
|
||||||
static List<SceneStaticFunction> oneGangHelperFunctions(
|
|
||||||
String deviceId, String deviceName, functionValue) {
|
|
||||||
return [
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsAcPower,
|
|
||||||
operationName: 'Light Switch',
|
|
||||||
code: 'switch_1',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.onOff,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsLightCountdown,
|
|
||||||
operationName: 'Light CountDown',
|
|
||||||
code: 'countdown_1',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.countdown,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<SceneStaticFunction> oneGangAutomationFunctions(
|
|
||||||
String deviceId, String deviceName, functionValue) {
|
|
||||||
return [
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsAcPower,
|
|
||||||
operationName: 'Light Switch',
|
|
||||||
code: 'switch_1',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.onOff,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsLightCountdown,
|
|
||||||
operationName: 'Light CountDown',
|
|
||||||
code: 'countdown_1',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.integerSteps,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: '',
|
|
||||||
description: "sec",
|
|
||||||
value: 0.0,
|
|
||||||
minValue: 0,
|
|
||||||
maxValue: 43200,
|
|
||||||
stepValue: 1,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -6,7 +6,6 @@ import 'package:syncrow_app/features/scene/helper/functions_per_device/ac_functi
|
|||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/door_lock_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/door_lock_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/gateway_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/gateway_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/human_presence_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/human_presence_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/one_gang_functions.dart';
|
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/presence_sensor.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/presence_sensor.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/three_gang_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/three_gang_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||||
@ -15,9 +14,8 @@ import 'package:syncrow_app/generated/assets.dart';
|
|||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
mixin SceneOperationsDataHelper {
|
mixin SceneOperationsDataHelper {
|
||||||
final Map<DeviceType,
|
final Map<DeviceType, Function(List<FunctionModel>, String, String, dynamic, bool)> _functionMap =
|
||||||
Function(List<FunctionModel>, String, String, dynamic, bool)>
|
{
|
||||||
_functionMap = {
|
|
||||||
DeviceType.LightBulb: lightBulbFunctions,
|
DeviceType.LightBulb: lightBulbFunctions,
|
||||||
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
||||||
DeviceType.WallSensor: wallSensorFunctions,
|
DeviceType.WallSensor: wallSensorFunctions,
|
||||||
@ -26,7 +24,6 @@ mixin SceneOperationsDataHelper {
|
|||||||
DeviceType.Curtain: curtainFunctions,
|
DeviceType.Curtain: curtainFunctions,
|
||||||
DeviceType.ThreeGang: threeGangFunctions,
|
DeviceType.ThreeGang: threeGangFunctions,
|
||||||
DeviceType.Gateway: gatewayFunctions,
|
DeviceType.Gateway: gatewayFunctions,
|
||||||
DeviceType.OneGang: oneGangFunctions,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
final Map<DeviceType, String> _titleMap = {
|
final Map<DeviceType, String> _titleMap = {
|
||||||
@ -38,24 +35,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
DeviceType.Curtain: 'Curtain Functions',
|
DeviceType.Curtain: 'Curtain Functions',
|
||||||
DeviceType.ThreeGang: '3G Light Switch Functions',
|
DeviceType.ThreeGang: '3G Light Switch Functions',
|
||||||
DeviceType.Gateway: 'Gateway Functions',
|
DeviceType.Gateway: 'Gateway Functions',
|
||||||
DeviceType.OneGang: '1G Light Switch Conditions',
|
|
||||||
};
|
};
|
||||||
static String _productTypeCache = '';
|
|
||||||
|
|
||||||
//one gang functions
|
|
||||||
static List<SceneStaticFunction> oneGangFunctions(
|
|
||||||
List<FunctionModel> functions,
|
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
|
||||||
return OneGangHelperFunctions.oneGangAutomationFunctions(
|
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
|
||||||
return OneGangHelperFunctions.oneGangHelperFunctions(
|
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SceneStaticFunction> getFunctionsWithIcons({
|
List<SceneStaticFunction> getFunctionsWithIcons({
|
||||||
DeviceType? type,
|
DeviceType? type,
|
||||||
@ -65,22 +45,16 @@ mixin SceneOperationsDataHelper {
|
|||||||
required bool isAutomation,
|
required bool isAutomation,
|
||||||
}) {
|
}) {
|
||||||
final functionValue = null;
|
final functionValue = null;
|
||||||
return _functionMap[type]?.call(
|
return _functionMap[type]?.call(functions, deviceId, deviceName, functionValue, isAutomation) ??
|
||||||
functions, deviceId, deviceName, functionValue, isAutomation) ??
|
lightBulbFunctions(functions, deviceId, deviceName, functionValue, isAutomation);
|
||||||
lightBulbFunctions(
|
|
||||||
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getTitle({DeviceType? type}) {
|
String getTitle({DeviceType? type}) {
|
||||||
return _titleMap[type] ?? '';
|
return _titleMap[type] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> ceilingSensorFunctions(
|
static List<SceneStaticFunction> ceilingSensorFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
@ -89,35 +63,22 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> curtainFunctions(
|
static List<SceneStaticFunction> curtainFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> doorLockFunctions(
|
static List<SceneStaticFunction> doorLockFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return DoorLockHelperFunctions.doorLockTapToRunFunctions(
|
return DoorLockHelperFunctions.doorLockTapToRunFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> wallSensorFunctions(
|
static List<SceneStaticFunction> wallSensorFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
@ -126,51 +87,31 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> lightBulbFunctions(
|
static List<SceneStaticFunction> lightBulbFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> gatewayFunctions(
|
static List<SceneStaticFunction> gatewayFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
return GatewayHelperFunctions.tabToRunGatewayFunctions(deviceId, deviceName, functionValue);
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
return GatewayHelperFunctions.tabToRunGatewayFunctions(
|
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> threeGangFunctions(
|
static List<SceneStaticFunction> threeGangFunctions(List<FunctionModel> functions,
|
||||||
List<FunctionModel> functions,
|
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return ThreeGangHelperFunctions.threeGangHelperFunctions(
|
return ThreeGangHelperFunctions.threeGangHelperFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> acFunctions(
|
static List<SceneStaticFunction> acFunctions(List<FunctionModel> functions, String deviceId,
|
||||||
List<FunctionModel> functions,
|
String deviceName, dynamic functionValue, bool isAutomation) {
|
||||||
String deviceId,
|
|
||||||
String deviceName,
|
|
||||||
dynamic functionValue,
|
|
||||||
bool isAutomation) {
|
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return ACFunctionsHelper.automationAcFunctions(
|
return ACFunctionsHelper.automationAcFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
return ACFunctionsHelper.tabToRunAcFunctions(
|
return ACFunctionsHelper.tabToRunAcFunctions(deviceId, deviceName, functionValue);
|
||||||
deviceId, deviceName, functionValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
||||||
@ -208,12 +149,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: action.entityId,
|
deviceId: action.entityId,
|
||||||
deviceName: action.name.toString(),
|
deviceName: action.name.toString(),
|
||||||
deviceIcon: action.type == 'automation'
|
deviceIcon: action.type == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
? Assets.player
|
icon: action.type == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
: Assets.handClickIcon,
|
|
||||||
icon: action.type == 'automation'
|
|
||||||
? Assets.player
|
|
||||||
: Assets.handClickIcon,
|
|
||||||
operationName: action.type.toString(),
|
operationName: action.type.toString(),
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
functionValue: action.actionExecutor,
|
functionValue: action.actionExecutor,
|
||||||
@ -233,8 +170,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
functions
|
functions.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
||||||
.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,9 +206,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
}) {
|
}) {
|
||||||
final executorProperty = action.executorProperty;
|
final executorProperty = action.executorProperty;
|
||||||
|
|
||||||
final Map<String,
|
final Map<String, SceneStaticFunction Function(Action, bool, String?, String?)> functionMap = {
|
||||||
SceneStaticFunction Function(Action, bool, String?, String?)>
|
|
||||||
functionMap = {
|
|
||||||
'sensitivity': _createSensitivityFunction,
|
'sensitivity': _createSensitivityFunction,
|
||||||
'normal_open_switch': _createNormalOpenSwitchFunction,
|
'normal_open_switch': _createNormalOpenSwitchFunction,
|
||||||
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
||||||
@ -348,16 +282,14 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSensitivityFunction(Action action,
|
SceneStaticFunction _createSensitivityFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Presence Sensor',
|
'Presence Sensor',
|
||||||
Assets.assetsIconsSensors,
|
Assets.assetsIconsSensors,
|
||||||
'Sensitivity',
|
'Sensitivity',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.listOfOptions,
|
||||||
? OperationDialogType.integerSteps
|
|
||||||
: OperationDialogType.listOfOptions,
|
|
||||||
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
@ -365,8 +297,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createNormalOpenSwitchFunction(Action action,
|
SceneStaticFunction _createNormalOpenSwitchFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -419,8 +351,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockFingerprintFunction(Action action,
|
SceneStaticFunction _createUnlockFingerprintFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -434,8 +366,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockPasswordFunction(Action action,
|
SceneStaticFunction _createUnlockPasswordFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -449,8 +381,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockCardFunction(Action action,
|
SceneStaticFunction _createUnlockCardFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -464,8 +396,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createAlarmLockFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createAlarmLockFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -479,8 +411,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockRequestFunction(Action action,
|
SceneStaticFunction _createUnlockRequestFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -494,8 +426,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createResidualElectricityFunction(Action action,
|
SceneStaticFunction _createResidualElectricityFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -509,8 +441,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createReverseLockFunction(Action action,
|
SceneStaticFunction _createReverseLockFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -524,8 +456,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockAppFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createUnlockAppFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -539,8 +471,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createHijackFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createHijackFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -554,8 +486,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createDoorbellFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createDoorbellFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -569,8 +501,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockTemporaryFunction(Action action,
|
SceneStaticFunction _createUnlockTemporaryFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -584,8 +516,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createFarDetectionFunction(Action action,
|
SceneStaticFunction _createFarDetectionFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -599,8 +531,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMotionSensitivityFunction(Action action,
|
SceneStaticFunction _createMotionSensitivityFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -614,8 +546,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMotionlessSensitivityFunction(Action action,
|
SceneStaticFunction _createMotionlessSensitivityFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -629,8 +561,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createIndicatorFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createIndicatorFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -644,8 +576,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createPresenceTimeFunction(Action action,
|
SceneStaticFunction _createPresenceTimeFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -659,8 +591,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createPresenceStateFunction(Action action,
|
SceneStaticFunction _createPresenceStateFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -674,16 +606,14 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createDisCurrentFunction(Action action,
|
SceneStaticFunction _createDisCurrentFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
Assets.assetsIconsSensors,
|
Assets.assetsIconsSensors,
|
||||||
'Current Distance',
|
'Current Distance',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
|
||||||
: OperationDialogType.countdown,
|
|
||||||
_createCurrentDistanceOptions(),
|
_createCurrentDistanceOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
@ -691,8 +621,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createIlluminanceValueFunction(Action action,
|
SceneStaticFunction _createIlluminanceValueFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -706,8 +636,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCheckingResultFunction(Action action,
|
SceneStaticFunction _createCheckingResultFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -721,8 +651,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitchFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createSwitchFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -736,27 +666,23 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createTempSetFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createTempSetFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
Assets.assetsIconsAC,
|
Assets.assetsIconsAC,
|
||||||
'Set Temperature',
|
'Set Temperature',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.temperature,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationTemperatureOptions() : _createTemperatureOptions(),
|
||||||
: OperationDialogType.temperature,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationTemperatureOptions()
|
|
||||||
: _createTemperatureOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createTempCurrentFunction(Action action,
|
SceneStaticFunction _createTempCurrentFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -770,8 +696,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createModeFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createModeFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -785,8 +711,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createLevelFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createLevelFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -800,8 +726,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createChildLockFunction(Action action, bool isAutomation,
|
SceneStaticFunction _createChildLockFunction(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -815,38 +741,23 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch1Function(Action action, bool isAutomation,
|
SceneStaticFunction _createSwitch1Function(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
switch (action.productType) {
|
return _createSceneFunction(
|
||||||
case "3G":
|
action,
|
||||||
return _createSceneFunction(
|
'3 Gang Button Switch L-L',
|
||||||
action,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'3 Gang Button Switch L-L',
|
'Light 1 Switch',
|
||||||
Assets.assetsIcons3GangSwitch,
|
OperationDialogType.onOff,
|
||||||
'Light 1 Switch',
|
_createOnOffOptions(),
|
||||||
OperationDialogType.onOff,
|
isAutomation,
|
||||||
_createOnOffOptions(),
|
comparator,
|
||||||
isAutomation,
|
uniqueCustomId,
|
||||||
comparator,
|
);
|
||||||
uniqueCustomId,
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return _createSceneFunction(
|
|
||||||
action,
|
|
||||||
'1 Gang Button Switch L-L',
|
|
||||||
Assets.oneGang,
|
|
||||||
'Light Switch',
|
|
||||||
OperationDialogType.onOff,
|
|
||||||
_createOnOffOptions(),
|
|
||||||
isAutomation,
|
|
||||||
comparator,
|
|
||||||
uniqueCustomId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch2Function(Action action, bool isAutomation,
|
SceneStaticFunction _createSwitch2Function(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -860,8 +771,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch3Function(Action action, bool isAutomation,
|
SceneStaticFunction _createSwitch3Function(
|
||||||
String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -875,84 +786,53 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown1Function(Action action,
|
SceneStaticFunction _createCountdown1Function(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
switch (action.productType) {
|
return _createSceneFunction(
|
||||||
case "3G":
|
action,
|
||||||
return _createSceneFunction(
|
'3 Gang Button Switch L-L',
|
||||||
action,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'3 Gang Button Switch L-L',
|
'Light 1 CountDown',
|
||||||
Assets.assetsIcons3GangSwitch,
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
'Light 1 CountDown',
|
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
||||||
isAutomation
|
isAutomation,
|
||||||
? OperationDialogType.integerSteps
|
comparator,
|
||||||
: OperationDialogType.countdown,
|
uniqueCustomId,
|
||||||
isAutomation
|
);
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
|
||||||
comparator,
|
|
||||||
uniqueCustomId,
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return _createSceneFunction(
|
|
||||||
action,
|
|
||||||
'1 Gang Button Switch L-L',
|
|
||||||
Assets.oneGang,
|
|
||||||
'Light CountDown',
|
|
||||||
isAutomation
|
|
||||||
? OperationDialogType.integerSteps
|
|
||||||
: OperationDialogType.countdown,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
|
||||||
comparator,
|
|
||||||
uniqueCustomId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown2Function(Action action,
|
SceneStaticFunction _createCountdown2Function(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
Assets.assetsIcons3GangSwitch,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'Light 2 CountDown',
|
'Light 2 CountDown',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
||||||
: OperationDialogType.countdown,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown3Function(Action action,
|
SceneStaticFunction _createCountdown3Function(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
Assets.assetsIcons3GangSwitch,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'Light 3 CountDown',
|
'Light 3 CountDown',
|
||||||
isAutomation
|
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
||||||
? OperationDialogType.integerSteps
|
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
||||||
: OperationDialogType.countdown,
|
|
||||||
isAutomation
|
|
||||||
? _createAutomationCountDownOptions()
|
|
||||||
: _createCountdownOptions(),
|
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitchAlarmSoundFunction(Action action,
|
SceneStaticFunction _createSwitchAlarmSoundFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -966,8 +846,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMasterStateFunction(Action action,
|
SceneStaticFunction _createMasterStateFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -981,8 +861,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createFactoryResetFunction(Action action,
|
SceneStaticFunction _createFactoryResetFunction(
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -1300,12 +1180,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
uniqueCustomId: taskItem.uniqueCustomId,
|
uniqueCustomId: taskItem.uniqueCustomId,
|
||||||
deviceId: taskItem.deviceId,
|
deviceId: taskItem.deviceId,
|
||||||
deviceName: taskItem.deviceName.toString(),
|
deviceName: taskItem.deviceName.toString(),
|
||||||
deviceIcon: taskItem.operationName == 'automation'
|
deviceIcon: taskItem.operationName == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
? Assets.player
|
icon: taskItem.operationName == 'automation' ? Assets.player : Assets.handClickIcon,
|
||||||
: Assets.handClickIcon,
|
|
||||||
icon: taskItem.operationName == 'automation'
|
|
||||||
? Assets.player
|
|
||||||
: Assets.handClickIcon,
|
|
||||||
operationName: taskItem.operationName,
|
operationName: taskItem.operationName,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
||||||
|
|||||||
@ -74,7 +74,6 @@ class Action {
|
|||||||
ExecutorProperty? executorProperty;
|
ExecutorProperty? executorProperty;
|
||||||
String? name;
|
String? name;
|
||||||
String? type;
|
String? type;
|
||||||
String? productType;
|
|
||||||
|
|
||||||
Action({
|
Action({
|
||||||
required this.actionExecutor,
|
required this.actionExecutor,
|
||||||
@ -82,7 +81,6 @@ class Action {
|
|||||||
this.executorProperty,
|
this.executorProperty,
|
||||||
this.name,
|
this.name,
|
||||||
this.type,
|
this.type,
|
||||||
this.productType,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
String toRawJson() => json.encode(toJson());
|
String toRawJson() => json.encode(toJson());
|
||||||
@ -90,11 +88,10 @@ class Action {
|
|||||||
static Action? fromJson(Map<String, dynamic> json) {
|
static Action? fromJson(Map<String, dynamic> json) {
|
||||||
if (json['name'] != null && json['type'] != null) {
|
if (json['name'] != null && json['type'] != null) {
|
||||||
return Action(
|
return Action(
|
||||||
actionExecutor: json["actionExecutor"] as String,
|
actionExecutor: json["actionExecutor"],
|
||||||
entityId: json["entityId"] as String,
|
entityId: json["entityId"],
|
||||||
name: json['name'] as String?,
|
name: json['name'],
|
||||||
type: json['type'] as String?,
|
type: json['type'],
|
||||||
productType: json['productType'] as String?,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (json["executorProperty"] == null) {
|
if (json["executorProperty"] == null) {
|
||||||
@ -102,10 +99,9 @@ class Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Action(
|
return Action(
|
||||||
actionExecutor: json["actionExecutor"] as String,
|
actionExecutor: json["actionExecutor"],
|
||||||
entityId: json["entityId"] as String,
|
entityId: json["entityId"],
|
||||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||||
productType: json['productType'] as String?,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String sendOtp = '/authentication/user/send-otp';
|
static const String sendOtp = '/authentication/user/send-otp';
|
||||||
static const String verifyOtp = '/authentication/user/verify-otp';
|
static const String verifyOtp = '/authentication/user/verify-otp';
|
||||||
static const String forgetPassword = '/authentication/user/forget-password';
|
static const String forgetPassword = '/authentication/user/forget-password';
|
||||||
|
static const String clientLogin = '/client/token';
|
||||||
////////////////////////////////////// Spaces ///////////////////////////////////////
|
////////////////////////////////////// Spaces ///////////////////////////////////////
|
||||||
|
|
||||||
///Community Module
|
///Community Module
|
||||||
@ -111,9 +111,9 @@ abstract class ApiEndpoints {
|
|||||||
//POST
|
//POST
|
||||||
static const String addDeviceToRoom = '/device/room';
|
static const String addDeviceToRoom = '/device/room';
|
||||||
static const String addDeviceToGroup = '/device/group';
|
static const String addDeviceToGroup = '/device/group';
|
||||||
static const String controlDevice = '/device/{deviceUuid}/control';
|
static const String controlDevice = '/devices/{deviceUuid}/command';
|
||||||
static const String firmwareDevice =
|
static const String firmwareDevice =
|
||||||
'/device/{deviceUuid}/firmware/{firmwareVersion}';
|
'/devices/{deviceUuid}/firmware/{firmwareVersion}';
|
||||||
static const String getDevicesByUserId = '/device/user/{userId}';
|
static const String getDevicesByUserId = '/device/user/{userId}';
|
||||||
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
||||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||||
@ -121,13 +121,13 @@ abstract class ApiEndpoints {
|
|||||||
//GET
|
//GET
|
||||||
static const String deviceByRoom =
|
static const String deviceByRoom =
|
||||||
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
|
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
|
||||||
static const String deviceByUuid = '/device/{deviceUuid}';
|
static const String deviceByUuid = '/devices/{deviceUuid}';
|
||||||
static const String deviceFunctions = '/device/{deviceUuid}/functions';
|
static const String deviceFunctions = '/devices/{deviceUuid}/functions';
|
||||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
||||||
static const String deviceFunctionsStatus =
|
static const String deviceFunctionsStatus =
|
||||||
'/device/{deviceUuid}/functions/status';
|
'/devices/{deviceUuid}/functions/status';
|
||||||
static const String powerClamp =
|
static const String powerClamp =
|
||||||
'/device/{powerClampUuid}/power-clamp/status';
|
'/devices/{deviceUuid}/functions/status';
|
||||||
|
|
||||||
///Device Permission Module
|
///Device Permission Module
|
||||||
//POST
|
//POST
|
||||||
@ -153,7 +153,8 @@ abstract class ApiEndpoints {
|
|||||||
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
||||||
static const String getIconScene = '/scene/icon';
|
static const String getIconScene = '/scene/icon';
|
||||||
|
|
||||||
static const String getUnitAutomation = '/projects/{projectId}/communities/{communityId}/spaces/{unitUuid}/automations';
|
static const String getUnitAutomation =
|
||||||
|
'/projects/{projectId}/communities/{communityId}/spaces/{unitUuid}/automations';
|
||||||
|
|
||||||
static const String getAutomationDetails =
|
static const String getAutomationDetails =
|
||||||
'/projects/{projectId}/automations/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
@ -161,7 +162,8 @@ abstract class ApiEndpoints {
|
|||||||
/// PUT
|
/// PUT
|
||||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
|
static const String updateAutomation =
|
||||||
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
static const String updateAutomationStatus =
|
static const String updateAutomationStatus =
|
||||||
'/projects/{projectId}/automations/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
@ -169,7 +171,8 @@ abstract class ApiEndpoints {
|
|||||||
/// DELETE
|
/// DELETE
|
||||||
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
|
static const String deleteAutomation =
|
||||||
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
//////////////////////Door Lock //////////////////////
|
//////////////////////Door Lock //////////////////////
|
||||||
//online
|
//online
|
||||||
@ -213,18 +216,18 @@ abstract class ApiEndpoints {
|
|||||||
static const String changeSchedule = '/schedule/enable/{deviceUuid}';
|
static const String changeSchedule = '/schedule/enable/{deviceUuid}';
|
||||||
static const String deleteSchedule = '/schedule/{deviceUuid}/{scheduleId}';
|
static const String deleteSchedule = '/schedule/{deviceUuid}/{scheduleId}';
|
||||||
static const String reportLogs =
|
static const String reportLogs =
|
||||||
'/device/report-logs/{deviceUuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
'/devices/report-logs/{deviceUuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||||
static const String controlBatch = '/device/control/batch';
|
static const String controlBatch = '/devices/batch';
|
||||||
static const String statusBatch = '/device/status/batch';
|
static const String statusBatch = '/devices/batch';
|
||||||
static const String deviceScene = '/device/{deviceUuid}/scenes';
|
static const String deviceScene = '/devices/{deviceUuid}/scenes';
|
||||||
|
|
||||||
static const String fourSceneByName =
|
static const String fourSceneByName =
|
||||||
'/device/{deviceUuid}/scenes?switchName={switchName}';
|
'/devices/{deviceUuid}/scenes?switchName={switchName}';
|
||||||
|
|
||||||
static const String resetDevice = '/factory/reset/{deviceUuid}';
|
static const String resetDevice = '/factory/reset/{deviceUuid}';
|
||||||
static const String unAssignScenesDevice =
|
static const String unAssignScenesDevice =
|
||||||
'/device/{deviceUuid}/scenes?switchName={switchName}';
|
'/devices/{deviceUuid}/scenes?switchName={switchName}';
|
||||||
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
static const String getDeviceLogs = '/devices/report-logs/{uuid}?code={code}';
|
||||||
static const String terms = '/terms';
|
static const String terms = '/terms';
|
||||||
static const String policy = '/policy';
|
static const String policy = '/policy';
|
||||||
static const String getPermission = '/permission/{roleUuid}';
|
static const String getPermission = '/permission/{roleUuid}';
|
||||||
|
|||||||
@ -25,11 +25,15 @@ class AuthenticationAPI {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> signUp({required SignUpModel model}) async {
|
static Future<bool> signUp({
|
||||||
|
required SignUpModel model,
|
||||||
|
required String accessToken,
|
||||||
|
}) async {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.signUp,
|
path: ApiEndpoints.signUp,
|
||||||
body: model.toJson(),
|
body: model.toJson(),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
|
accessToken: accessToken,
|
||||||
expectedResponseModel: (json) => json['statusCode'] == 201);
|
expectedResponseModel: (json) => json['statusCode'] == 201);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -63,4 +67,20 @@ class AuthenticationAPI {
|
|||||||
expectedResponseModel: (json) => json['data']);
|
expectedResponseModel: (json) => json['data']);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>> fetchClientToken({
|
||||||
|
required String clientId,
|
||||||
|
required String clientSecret,
|
||||||
|
}) async {
|
||||||
|
final response = await HTTPService().post(
|
||||||
|
path: ApiEndpoints.clientLogin,
|
||||||
|
body: {
|
||||||
|
'clientId': clientId,
|
||||||
|
'clientSecret': clientSecret,
|
||||||
|
},
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) => json['data'],
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
@ -8,7 +7,6 @@ import 'package:syncrow_app/features/devices/model/device_report_model.dart';
|
|||||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||||
import 'package:syncrow_app/services/api/http_service.dart';
|
import 'package:syncrow_app/services/api/http_service.dart';
|
||||||
import 'package:syncrow_app/utils/constants/temp_const.dart';
|
|
||||||
import '../../features/devices/model/create_temporary_password_model.dart';
|
import '../../features/devices/model/create_temporary_password_model.dart';
|
||||||
|
|
||||||
class DevicesAPI {
|
class DevicesAPI {
|
||||||
@ -39,7 +37,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||||
body: {"deviceName": deviceName},
|
body: {"deviceName": deviceName},
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
@ -92,7 +90,7 @@ class DevicesAPI {
|
|||||||
.replaceAll('{deviceUuid}', deviceId),
|
.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
@ -101,7 +99,7 @@ class DevicesAPI {
|
|||||||
static Future<Map<String, dynamic>> getPowerClampStatus(
|
static Future<Map<String, dynamic>> getPowerClampStatus(
|
||||||
String deviceId) async {
|
String deviceId) async {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{powerClampUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
@ -132,7 +130,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
final functions = FunctionModel.fromJson(json);
|
final functions = FunctionModel.fromJson(json['data']);
|
||||||
return functions;
|
return functions;
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
@ -188,7 +186,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -264,7 +262,7 @@ class DevicesAPI {
|
|||||||
if (json == null || json.isEmpty || json == []) {
|
if (json == null || json.isEmpty || json == []) {
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
for (var device in json['devices']) {
|
for (var device in json['data']['devices']) {
|
||||||
devices.add(DeviceModel.fromJson(device));
|
devices.add(DeviceModel.fromJson(device));
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
@ -491,7 +489,12 @@ class DevicesAPI {
|
|||||||
}) async {
|
}) async {
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.controlBatch,
|
path: ApiEndpoints.controlBatch,
|
||||||
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
body: {
|
||||||
|
"devicesUuid": devicesUuid,
|
||||||
|
"code": code,
|
||||||
|
"value": value,
|
||||||
|
"operationType": 'COMMAND',
|
||||||
|
},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class HomeManagementAPI {
|
|||||||
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
json.forEach((value) {
|
json['data'].forEach((value) {
|
||||||
list.add(DeviceModel.fromJson(value));
|
list.add(DeviceModel.fromJson(value));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -48,13 +48,26 @@ class HTTPService {
|
|||||||
Options? options,
|
Options? options,
|
||||||
dynamic body,
|
dynamic body,
|
||||||
bool showServerMessage = true,
|
bool showServerMessage = true,
|
||||||
|
String? accessToken,
|
||||||
required T Function(dynamic) expectedResponseModel}) async {
|
required T Function(dynamic) expectedResponseModel}) async {
|
||||||
try {
|
try {
|
||||||
|
final authOptions = options ??
|
||||||
|
Options(
|
||||||
|
headers: accessToken != null
|
||||||
|
? {
|
||||||
|
'Authorization': 'Bearer $accessToken',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
final response = await client.post(
|
final response = await client.post(
|
||||||
path,
|
path,
|
||||||
data: body,
|
data: body,
|
||||||
queryParameters: queryParameters,
|
queryParameters: queryParameters,
|
||||||
options: options,
|
options: authOptions,
|
||||||
);
|
);
|
||||||
return expectedResponseModel(response.data);
|
return expectedResponseModel(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user