forked from eatvio/eatvio_app
fixed sentry crashes handling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
|
||||
import 'package:eatvio_app/features/chat/models/payment_model.dart';
|
||||
import 'package:eatvio_app/features/chat/services/chat_service.dart';
|
||||
import 'package:eatvio_app/features/payment/models/promo_applied_list_response.dart';
|
||||
@@ -10,8 +11,9 @@ import 'package:eatvio_app/features/payment/models/promo_validate_response.dart'
|
||||
/// Репозиторий оплаты консультаций (chosen_plan) через Alfa Bank / СБП.
|
||||
class PaymentRepository {
|
||||
final ChatService chatService;
|
||||
final ApiResponseErrorReporter? responseErrors;
|
||||
|
||||
PaymentRepository({required this.chatService});
|
||||
PaymentRepository({required this.chatService, this.responseErrors});
|
||||
|
||||
/// Запускает процесс оплаты: POST `/api/chosen_plans/{id}/start_payment_process`
|
||||
/// с `payment_provider: alfa-bank`.
|
||||
@@ -64,9 +66,15 @@ class PaymentRepository {
|
||||
body: {'promo_code': promoCode},
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
final data = e.response?.data;
|
||||
if (data is Map<String, dynamic>) {
|
||||
return PromoApplyResponse.fromJson(data);
|
||||
final response = e.response;
|
||||
final data = response?.data;
|
||||
if (response != null && data is Map<String, dynamic>) {
|
||||
return ApiResponseErrorReporter.decode(
|
||||
responseErrors,
|
||||
response,
|
||||
'/api/chosen_plans/{id}/apply_promo',
|
||||
() => PromoApplyResponse.fromJson(data),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
@@ -77,9 +85,15 @@ class PaymentRepository {
|
||||
try {
|
||||
return await chatService.removePromoCode(id: planId);
|
||||
} on DioException catch (e) {
|
||||
final data = e.response?.data;
|
||||
if (data is Map<String, dynamic>) {
|
||||
return PromoRemoveResponse.fromJson(data);
|
||||
final response = e.response;
|
||||
final data = response?.data;
|
||||
if (response != null && data is Map<String, dynamic>) {
|
||||
return ApiResponseErrorReporter.decode(
|
||||
responseErrors,
|
||||
response,
|
||||
'/api/chosen_plans/{id}/remove_promo_code',
|
||||
() => PromoRemoveResponse.fromJson(data),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user