push schedule apis

This commit is contained in:
ashrafzarkanisala
2024-09-24 00:51:13 +03:00
parent 6e3ad984e1
commit f3f6369237
11 changed files with 273 additions and 165 deletions

View File

@ -3,6 +3,7 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_rep
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_entry.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_model.dart';
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
import 'package:syncrow_web/services/api/http_service.dart';
@ -179,7 +180,7 @@ class DevicesManagementApi {
}
Future<bool> addScheduleRecord(
ScheduleModel sendSchedule, String uuid) async {
ScheduleEntry sendSchedule, String uuid) async {
try {
final response = await HTTPService().post(
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
@ -200,14 +201,14 @@ class DevicesManagementApi {
String uuid, String category) async {
try {
final response = await HTTPService().get(
path: ApiEndpoints.scheduleByDeviceId
path: ApiEndpoints.getScheduleByDeviceId
.replaceAll('{deviceUuid}', uuid)
.replaceAll('{category}', category),
showServerMessage: true,
expectedResponseModel: (json) {
List<ScheduleModel> schedules = [];
for (var schedule in json['schedules']) {
schedules.add(ScheduleModel.fromJson(schedule));
for (var schedule in json) {
schedules.add(ScheduleModel.fromMap(schedule));
}
return schedules;
},
@ -225,7 +226,7 @@ class DevicesManagementApi {
required String scheduleId}) async {
try {
final response = await HTTPService().put(
path: ApiEndpoints.scheduleByDeviceId
path: ApiEndpoints.updateScheduleByDeviceId
.replaceAll('{deviceUuid}', uuid)
.replaceAll('{scheduleUuid}', scheduleId),
body: {
@ -246,7 +247,7 @@ class DevicesManagementApi {
Future<bool> deleteScheduleRecord(String uuid, String scheduleId) async {
try {
final response = await HTTPService().delete(
path: ApiEndpoints.scheduleByDeviceId
path: ApiEndpoints.deleteScheduleByDeviceId
.replaceAll('{deviceUuid}', uuid)
.replaceAll('{scheduleUuid}', scheduleId),
showServerMessage: true,