mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-25 20:09:40 +00:00
36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
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);
|
|
// }
|
|
//
|
|
}
|
|
}
|
|
}
|