refactor: introduce base API service and core service for standardized API interaction and error handling.

This commit is contained in:
Achintha Isuru
2026-02-25 10:33:27 -05:00
parent 71c1610c0e
commit 77bb469186
6 changed files with 69 additions and 4 deletions

View File

@@ -8,4 +8,4 @@ export 'src/presentation/mixins/bloc_error_handler.dart';
export 'src/presentation/observers/core_bloc_observer.dart';
export 'src/config/app_config.dart';
export 'src/routing/routing.dart';
export 'src/services/api_service.dart';
export 'src/services/api_service/api_service.dart';

View File

@@ -5,7 +5,7 @@ import 'package:krow_domain/krow_domain.dart';
///
/// This class provides a wrapper around [Dio]'s methods to handle
/// response parsing and error handling in a consistent way.
class ApiService {
class ApiService implements BaseApiService {
/// Creates an [ApiService] with the given [Dio] instance.
ApiService(this._dio);
@@ -13,6 +13,7 @@ class ApiService {
final Dio _dio;
/// Performs a GET request to the specified [endpoint].
@override
Future<ApiResponse> get(
String endpoint, {
Map<String, dynamic>? params,
@@ -29,6 +30,7 @@ class ApiService {
}
/// Performs a POST request to the specified [endpoint].
@override
Future<ApiResponse> post(
String endpoint, {
dynamic data,
@@ -47,6 +49,7 @@ class ApiService {
}
/// Performs a PUT request to the specified [endpoint].
@override
Future<ApiResponse> put(
String endpoint, {
dynamic data,
@@ -65,6 +68,7 @@ class ApiService {
}
/// Performs a PATCH request to the specified [endpoint].
@override
Future<ApiResponse> patch(
String endpoint, {
dynamic data,