feat: 接入起卦后端流程并完善积分扣减链路
This commit is contained in:
@@ -44,6 +44,8 @@ class ApiClient {
|
||||
final Dio _dio;
|
||||
final Logger _logger = getLogger('data.network.api_client');
|
||||
|
||||
Dio get rawDio => _dio;
|
||||
|
||||
Future<void> postNoContent(String path, {Map<String, dynamic>? data}) async {
|
||||
try {
|
||||
await _dio.post<void>(path, data: data);
|
||||
@@ -90,6 +92,20 @@ class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getJson(String path) async {
|
||||
try {
|
||||
final response = await _dio.get<Map<String, dynamic>>(path);
|
||||
return response.data ?? <String, dynamic>{};
|
||||
} on DioException catch (error, stackTrace) {
|
||||
_logger.error(
|
||||
message: 'GET json failed',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
throw _mapProblem(error);
|
||||
}
|
||||
}
|
||||
|
||||
ApiProblem _mapProblem(DioException error) {
|
||||
final status = error.response?.statusCode ?? 500;
|
||||
final data = error.response?.data;
|
||||
|
||||
Reference in New Issue
Block a user