Updated the API Endpoints, API Calls, Data Models and cubits to the lateset changes from the backend

This commit is contained in:
Mohammad Salameh
2024-04-29 10:00:58 +03:00
parent f24953a57c
commit f8358a0877
19 changed files with 255 additions and 199 deletions

View File

@ -8,29 +8,25 @@ import 'package:syncrow_app/services/api/http_service.dart';
class SpacesAPI {
static final HTTPService _httpService = HTTPService();
static Future<List<SpaceModel>> getSpaces() async {
static Future<List<SpaceModel>> getUnitsByUserId() async {
var uuid =
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
final response = await _httpService.get(
path: ApiEndpoints.spaces,
queryParameters: {
"userUuid": uuid,
},
path: "${ApiEndpoints.unitUser}$uuid",
showServerMessage: false,
expectedResponseModel: (json) => SpaceModel.fromJsonList(json),
);
return response;
}
//get rooms by space id
static Future<List<RoomModel>> getRoomsBySpaceId(int spaceId) async {
static Future<List<RoomModel>> getRoomsBySpaceId(String unitId) async {
final response = await _httpService.get(
path: ApiEndpoints.rooms,
queryParameters: {"homeId": spaceId},
path: "${ApiEndpoints.unitChild}$unitId",
queryParameters: {"page": 1, "pageSize": 10},
showServerMessage: false,
expectedResponseModel: (json) {
List<RoomModel> rooms = [];
for (var room in json) {
for (var room in json['children']) {
rooms.add(RoomModel.fromJson(room));
}
return rooms;