mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 11:04:55 +00:00
Semi-implemented getting spaces feature
This commit is contained in:
35
lib/services/api/spaces_api.dart
Normal file
35
lib/services/api/spaces_api.dart
Normal file
@ -0,0 +1,35 @@
|
||||
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
class SpacesAPI {
|
||||
// static Future<Token> loginWithEmail(
|
||||
// {required LoginWithEmailModel model}) async {
|
||||
// final response = await HTTPService().post(
|
||||
// path: ApiEndpoints.login,
|
||||
// body: model.toJson(),
|
||||
// showServerMessage: false,
|
||||
// expectedResponseModel: (json) {
|
||||
// Token token = Token.fromJson(json['data']);
|
||||
// return token;
|
||||
// });
|
||||
// debugPrint("response: $response");
|
||||
// return response;
|
||||
// }
|
||||
|
||||
static Future<List<SpaceModel>> getSpaces() async {
|
||||
final response = await HTTPService().get(
|
||||
path: "${ApiEndpoints.spaces}/${AuthCubit.user!.uuid}",
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<SpaceModel> spaces = [];
|
||||
for (var space in json) {
|
||||
spaces.add(SpaceModel.fromJson(space));
|
||||
}
|
||||
return spaces;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user