mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 20:34:54 +00:00
make the domain and data layers
This commit is contained in:
35
lib/features/booking_system/data/booking_remote_source.dart
Normal file
35
lib/features/booking_system/data/booking_remote_source.dart
Normal file
@ -0,0 +1,35 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:syncrow_app/features/booking_system/domain/booking_model.dart';
|
||||
import 'package:syncrow_app/features/booking_system/domain/booking_service.dart';
|
||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
class BookingRemoteSource implements BookingService {
|
||||
final HTTPService _httpService;
|
||||
BookingRemoteSource(this._httpService);
|
||||
|
||||
@override
|
||||
Future<List<BookingModel>> get() async {
|
||||
try {
|
||||
return _httpService.get(
|
||||
path: ApiEndpoints.upcomingBookings,
|
||||
expectedResponseModel: (json) {
|
||||
return BookingModel.fromJsonList(json['data']);
|
||||
},
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
return [];
|
||||
// final message = e.response?.data as Map<String, dynamic>?;
|
||||
// final error = message?['error'] as Map<String, dynamic>?;
|
||||
// final errorMessage = error?['error'] as String? ?? '';
|
||||
// final formattedErrorMessage =
|
||||
// [_defaultErrorMessage, errorMessage].join(': ');
|
||||
// throw APIException(formattedErrorMessage);
|
||||
// } catch (e) {
|
||||
// final formattedErrorMessage = [_defaultErrorMessage, '$e'].join(': ');
|
||||
// throw APIException(formattedErrorMessage);
|
||||
// }
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user