fix to prod

This commit is contained in:
2026-08-14 13:47:11 +03:00
parent f53fea576e
commit 80a95ece5b
27 changed files with 872 additions and 221 deletions

View File

@@ -36,8 +36,8 @@ import '../models/subscriptions_response.dart';
import '../models/user_check_response_dto.dart';
class ApiService {
static const String baseUrl = "https://sharing-api.sparkit.by/api/v1";
static const String fileBaseUrl = "https://sharing-api.sparkit.by";
static const String baseUrl = "https://api.behappybel.by/api/v1";
static const String fileBaseUrl = "https://api.behappybel.by/";
final SecurityService _securityService;
final Dio _dio;
@@ -935,11 +935,30 @@ class ApiService {
}
}
/// GET /scooterorder/fines/client
Future<List<Fine>> getClientFines() async {
try {
final response = await _dio.get(
"$baseUrl/scooterorder/fines/client",
options: await _getAuthOptions(),
);
if (response.statusCode == 200 && response.data is Map) {
final List<dynamic> dataList = response.data['data'] ?? [];
return dataList.map((json) => Fine.fromJson(json)).toList();
}
return [];
} on DioException catch (e) {
_handleDioError(e);
return [];
}
}
/// GET /scooterorder/{id}/fine
Future<Fine?> getFineDetails(int orderId) async {
try {
final response = await _dio.get(
"$baseUrl/scooterorder/$orderId/fine",
"$baseUrl/scooterorder/fines/client/$orderId",
options: await _getAuthOptions(),
);
@@ -953,7 +972,8 @@ class ApiService {
}
}
/// PUT /scooterorder/{id}/fine
/// PUT /scooterorder/fines/client/{id}
/// {id} — это id штрафа (Fine.id), а не id заказа (Fine.orderId)
Future<void> payFine({
required int orderId,
int? cardId,
@@ -961,10 +981,10 @@ class ApiService {
}) async {
try {
await _dio.put(
"$baseUrl/scooterorder/$orderId/fine",
"$baseUrl/scooterorder/fines/client/$orderId",
data: {
if (cardId != null) 'cardId': cardId,
'isBalance': isBalance,
"cardId": cardId ?? 0,
"isBalance": isBalance,
},
options: await _getAuthOptions(),
);

View File

@@ -449,6 +449,24 @@ class ScooterRepositoryImpl extends ScooterRepository {
return result;
}
@override
Future<Result<List<Fine>>> getClientFines() async {
late final Result<List<Fine>> result;
try {
final fines = await _apiService.getClientFines();
result = Success(fines);
} on AuthException catch (e) {
result = Failure(AuthFailure(e.attemptsLeft));
} on UnauthorizedException catch (e) {
result = Failure(AuthFailure(0, message: e.toString()));
} on AuthBlockException catch (e) {
result = Failure(AuthBlockFailure(e.toString()));
} catch (e) {
result = Failure(UnknownFailure("Неизвестная ошибка"));
}
return result;
}
@override
Future<Result<void>> payFine({
required int orderId,