updated endpoint of get automation by space

This commit is contained in:
hannathkadher
2025-03-14 11:50:18 +04:00
parent 70d31f5351
commit 2a0f6a4596
3 changed files with 85 additions and 152 deletions

View File

@ -11,8 +11,7 @@ class SceneApi {
static final HTTPService _httpService = HTTPService();
// //create scene
static Future<Map<String, dynamic>> createScene(
CreateSceneModel createSceneModel) async {
static Future<Map<String, dynamic>> createScene(CreateSceneModel createSceneModel) async {
try {
debugPrint('create scene model: ${createSceneModel.toMap()}');
final response = await _httpService.post(
@ -69,8 +68,7 @@ class SceneApi {
//get scenes by community id and space id
static Future<List<ScenesModel>> getScenes(
String spaceId, String communityId, String projectId,
static Future<List<ScenesModel>> getScenes(String spaceId, String communityId, String projectId,
{showInDevice = false}) async {
try {
final response = await _httpService.get(
@ -98,11 +96,14 @@ class SceneApi {
//getAutomation
static Future<List<ScenesModel>> getAutomation(String spaceId) async {
static Future<List<ScenesModel>> getAutomation(
String spaceId, String communityId, String projectId) async {
try {
final response = await _httpService.get(
path:
ApiEndpoints.getSpaceAutomation.replaceAll('{spaceUuid}', spaceId),
path: ApiEndpoints.getSpaceAutomation
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', projectId),
showServerMessage: false,
expectedResponseModel: (json) {
List<ScenesModel> scenes = [];
@ -132,12 +133,10 @@ class SceneApi {
// }
//automation details
static Future<RoutineDetailsModel> getAutomationDetails(
String automationId) async {
static Future<RoutineDetailsModel> getAutomationDetails(String automationId) async {
try {
final response = await _httpService.get(
path: ApiEndpoints.getAutomationDetails
.replaceAll('{automationId}', automationId),
path: ApiEndpoints.getAutomationDetails.replaceAll('{automationId}', automationId),
showServerMessage: false,
expectedResponseModel: (json) => RoutineDetailsModel.fromMap(json),
);
@ -152,8 +151,7 @@ class SceneApi {
try {
final response = await _httpService.put(
path: ApiEndpoints.updateScene.replaceAll('{sceneId}', sceneId),
body: createSceneModel
.toJson(sceneId.isNotEmpty == true ? sceneId : null),
body: createSceneModel.toJson(sceneId.isNotEmpty == true ? sceneId : null),
expectedResponseModel: (json) {
return json;
},
@ -165,14 +163,11 @@ class SceneApi {
}
//update automation
static updateAutomation(
CreateAutomationModel createAutomationModel, String automationId) async {
static updateAutomation(CreateAutomationModel createAutomationModel, String automationId) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.updateAutomation
.replaceAll('{automationId}', automationId),
body: createAutomationModel
.toJson(automationId.isNotEmpty == true ? automationId : null),
path: ApiEndpoints.updateAutomation.replaceAll('{automationId}', automationId),
body: createAutomationModel.toJson(automationId.isNotEmpty == true ? automationId : null),
expectedResponseModel: (json) {
return json;
},
@ -189,8 +184,7 @@ class SceneApi {
final response = await _httpService.get(
path: ApiEndpoints.getScene.replaceAll('{sceneId}', sceneId),
showServerMessage: false,
expectedResponseModel: (json) =>
RoutineDetailsModel.fromMap(json['data']),
expectedResponseModel: (json) => RoutineDetailsModel.fromMap(json['data']),
);
return response;
} catch (e) {
@ -199,8 +193,7 @@ class SceneApi {
}
//delete Scene
static Future<bool> deleteScene(
{required String unitUuid, required String sceneId}) async {
static Future<bool> deleteScene({required String unitUuid, required String sceneId}) async {
try {
final response = await _httpService.delete(
path: ApiEndpoints.deleteScene