Compare commits

...

11 Commits

53 changed files with 1701 additions and 471 deletions

View File

@@ -1,5 +1,5 @@
{
"env": "development",
"apiBaseUrl": "https://api-neki-b2b.neki.es/gateway/api/",
"apiOrigin": "bde6ea73-d09c-475f-aabf-1d11137e4d0d"
}
"apiOrigin": "https://neki-b2b.neki.es"
}

View File

@@ -1,7 +0,0 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
abstract class DevicesRemoteDatasource {
Future<void> deleteDevice({required String userId, required String deviceId});
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request});
}

View File

@@ -1,37 +0,0 @@
import 'package:account/src/core/data/models/update_device_request_model.dart';
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'devices_remote_datasource.dart';
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
DevicesRemoteDatasourceImpl(this._repository);
final QuestiaRepository _repository;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) async {
try {
await _repository.delete<void>(
'/devices/$deviceId',
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to delete device');
}
}
@override
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) async {
try {
final body = request.toModel().toJson();
await _repository.put<void>(
'/devices',
body: body,
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to update device');
}
}
}

View File

@@ -1,20 +0,0 @@
import 'package:account/src/core/data/datasource/devices_remote_datasource.dart';
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
import '../../domain/repositories/devices_repository.dart';
class DevicesRepositoryImpl implements DevicesRepository {
const DevicesRepositoryImpl(this._remote);
final DevicesRemoteDatasource _remote;
@override
Future<void> deleteDevice({required String userId, required String deviceId}) {
return _remote.deleteDevice(userId: userId, deviceId: deviceId);
}
@override
Future<void> updateDevice({required String userId, required UpdateDeviceRequestEntity request}) {
return _remote.updateDevice(userId: userId, request: request);
}
}

View File

@@ -1,10 +0,0 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
abstract class DevicesRepository {
Future<void> deleteDevice({required String userId, required String deviceId});
Future<void> updateDevice({
required String userId,
required UpdateDeviceRequestEntity request
});
}

View File

@@ -1,10 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import '../data/datasource/devices_remote_datasource.dart';
import '../data/datasource/devices_remote_datasource_impl.dart';
final devicesRemoteDatasourceProvider = Provider<DevicesRemoteDatasource>((ref) {
final questiaRepository = getIt<QuestiaRepository>();
return DevicesRemoteDatasourceImpl(questiaRepository);
});

View File

@@ -1,10 +0,0 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/repositories/devices_repository_impl.dart';
import '../domain/repositories/devices_repository.dart';
import 'devices_remote_datasource_provider.dart';
final devicesRepositoryProvider = Provider<DevicesRepository>((ref) {
final remote = ref.read(devicesRemoteDatasourceProvider);
return DevicesRepositoryImpl(remote);
});

View File

@@ -16,6 +16,9 @@ class ChangePasswordScreen extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
final password = ref.watch(
changePasswordViewModelProvider.select((s)=>s.newPassword)
);
return LegacyPageLayout(
theme: theme,
@@ -28,11 +31,11 @@ class ChangePasswordScreen extends ConsumerWidget {
child: SingleChildScrollView(child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const _PasswordSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
const _NewPasswordSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
const _RepeatPasswordSection(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
_PasswordCriteriaList(password: password),
const _ErrorMessageSection()
],
))
@@ -42,29 +45,6 @@ class ChangePasswordScreen extends ConsumerWidget {
}
}
class _PasswordSection extends ConsumerWidget {
const _PasswordSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
);
return CustomTextField(
controller: vm.currentPasswordController,
hint: '********',
label: context.translate(I18n.password),
showPassword: showPassword,
onVisibilityChanged: vm.toggleCurrentPasswordVisibility,
);
}
}
class _NewPasswordSection extends ConsumerWidget {
const _NewPasswordSection();
@@ -74,7 +54,7 @@ class _NewPasswordSection extends ConsumerWidget {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
changePasswordViewModelProvider.select((s)=>s.showNewPassword)
);
return CustomTextField(
@@ -97,7 +77,7 @@ class _RepeatPasswordSection extends ConsumerWidget {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s)=>s.showCurrentPassword)
changePasswordViewModelProvider.select((s)=>s.showRepeatedPassword)
);
return CustomTextField(
@@ -111,6 +91,89 @@ class _RepeatPasswordSection extends ConsumerWidget {
}
class _PasswordCriteriaList extends StatelessWidget {
final String password;
const _PasswordCriteriaList({required this.password});
static final _upperRegex = RegExp(r'[A-Z]');
static final _digitRegex = RegExp(r'[0-9]');
static final _specialRegex =
RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]');
@override
Widget build(BuildContext context) {
final hasInput = password.isNotEmpty;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 6,
children: [
_CriteriaRow(
label: context.translate(I18n.passwordLength),
met: password.length >= 8,
hasInput: hasInput,
),
_CriteriaRow(
label: context.translate(I18n.passwordCapital),
met: _upperRegex.hasMatch(password),
hasInput: hasInput,
),
_CriteriaRow(
label: context.translate(I18n.passwordNumber),
met: _digitRegex.hasMatch(password),
hasInput: hasInput,
),
_CriteriaRow(
label: context.translate(I18n.passwordSpecial),
met: _specialRegex.hasMatch(password),
hasInput: hasInput,
),
],
);
}
}
class _CriteriaRow extends StatelessWidget {
final String label;
final bool met;
final bool hasInput;
const _CriteriaRow({
required this.label,
required this.met,
required this.hasInput,
});
@override
Widget build(BuildContext context) {
final Color color;
final IconData icon;
if (!hasInput) {
color = Colors.grey;
icon = Icons.circle_outlined;
} else if (met) {
color = Colors.green;
icon = Icons.check_circle;
} else {
color = Colors.red.shade400;
icon = Icons.cancel;
}
return Row(
spacing: 8,
children: [
Icon(icon, size: 16, color: color),
Text(
label,
style: TextStyle(fontSize: 13, color: color),
),
],
);
}
}
class _ErrorMessageSection extends ConsumerWidget {
const _ErrorMessageSection();
@@ -136,7 +199,9 @@ class _ErrorMessageSection extends ConsumerWidget {
),
],
);
} else return SizedBox.shrink();
} else {
return SizedBox.shrink();
}
}
}

View File

@@ -14,7 +14,6 @@ NotifierProvider.autoDispose<ChangePasswordViewModel, ChangePasswordViewState>(
class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
late final ChangePasswordUseCase _changePasswordUseCase;
late final TextEditingController currentPasswordController;
late final TextEditingController newPasswordController;
late final TextEditingController repeatPasswordController;
late final TextEditingController passwordController;
@@ -29,10 +28,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
}
void _initControllers() {
currentPasswordController = TextEditingController();
currentPasswordController.addListener(_onCurrentPasswordChanged);
newPasswordController = TextEditingController();
newPasswordController.addListener(_onNewPasswordChanged);
@@ -42,12 +37,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
ref.onDispose(disposeControllers);
}
void toggleCurrentPasswordVisibility() {
state = state.copyWith(
showCurrentPassword: !state.showCurrentPassword
);
}
void toggleNewPasswordVisibility() {
state = state.copyWith(
showNewPassword: !state.showNewPassword
@@ -60,17 +49,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
);
}
void _onCurrentPasswordChanged() {
final value = currentPasswordController.text;
if (value == state.currentPassword) return;
state = state.copyWith(
currentPassword: value,
errorMessage: ''
);
}
void _onNewPasswordChanged() {
final value = newPasswordController.text;
@@ -94,11 +72,14 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
}
bool _validateForm() {
if (state.currentPassword.trim().isEmpty){
state = state.copyWith(errorMessage: 'errorMessageCurrentPasswordIsEmpty');
return false;
}
if (state.newPassword.trim().isEmpty){
final _upperRegex = RegExp(r'[A-Z]');
final _digitRegex = RegExp(r'[0-9]');
final _specialRegex =
RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]');
final password = state.newPassword.trim();
if (password.isEmpty){
state = state.copyWith(errorMessage: 'errorMessageNewPasswordIsEmpty');
return false;
}
@@ -106,10 +87,26 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
state = state.copyWith(errorMessage: 'errorMessageRepeatPasswordIsEmpty');
return false;
}
if (state.newPassword.trim() != state.repeatPassword.trim()){
if (password != state.repeatPassword.trim()){
state = state.copyWith(errorMessage: 'errorMessagePasswordsDontMatch');
return false;
}
if (password.length < 8){
state = state.copyWith(errorMessage: 'errorPasswordMinLength');
return false;
}
if (!_upperRegex.hasMatch(password)) {
state = state.copyWith(errorMessage: 'errorPasswordUppercase');
return false;
}
if (!_digitRegex.hasMatch(password)) {
state = state.copyWith(errorMessage: 'errorPasswordDigits');
return false;
}
if (!_specialRegex.hasMatch(password)) {
state = state.copyWith(errorMessage: 'errorPasswordSpecial');
return false;
}
return true;
}
@@ -155,9 +152,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
}
void disposeControllers() {
currentPasswordController.removeListener(_onCurrentPasswordChanged);
currentPasswordController.dispose();
newPasswordController.removeListener(_onNewPasswordChanged);
newPasswordController.dispose();

View File

@@ -7,10 +7,8 @@ abstract class ChangePasswordViewState with _$ChangePasswordViewState {
const factory ChangePasswordViewState({
@Default(false) bool isLoading,
@Default(false) bool isComplete,
@Default(false) bool showCurrentPassword,
@Default(false) bool showNewPassword,
@Default(false) bool showRepeatedPassword,
@Default('') String currentPassword,
@Default('') String newPassword,
@Default('') String repeatPassword,
@Default('') String errorMessage

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ChangePasswordViewState {
bool get isLoading; bool get isComplete; bool get showCurrentPassword; bool get showNewPassword; bool get showRepeatedPassword; String get currentPassword; String get newPassword; String get repeatPassword; String get errorMessage;
bool get isLoading; bool get isComplete; bool get showNewPassword; bool get showRepeatedPassword; String get newPassword; String get repeatPassword; String get errorMessage;
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $ChangePasswordViewStateCopyWith<ChangePasswordViewState> get copyWith => _$Chan
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
@override
String toString() {
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $ChangePasswordViewStateCopyWith<$Res> {
factory $ChangePasswordViewStateCopyWith(ChangePasswordViewState value, $Res Function(ChangePasswordViewState) _then) = _$ChangePasswordViewStateCopyWithImpl;
@useResult
$Res call({
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
});
@@ -62,15 +62,13 @@ class _$ChangePasswordViewStateCopyWithImpl<$Res>
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
@@ -158,10 +156,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ChangePasswordViewState() when $default != null:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return orElse();
}
@@ -179,10 +177,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _ChangePasswordViewState():
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -199,10 +197,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _ChangePasswordViewState() when $default != null:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return null;
}
@@ -214,15 +212,13 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
class _ChangePasswordViewState implements ChangePasswordViewState {
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showCurrentPassword = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.currentPassword = '', this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
@override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isComplete;
@override@JsonKey() final bool showCurrentPassword;
@override@JsonKey() final bool showNewPassword;
@override@JsonKey() final bool showRepeatedPassword;
@override@JsonKey() final String currentPassword;
@override@JsonKey() final String newPassword;
@override@JsonKey() final String repeatPassword;
@override@JsonKey() final String errorMessage;
@@ -237,16 +233,16 @@ _$ChangePasswordViewStateCopyWith<_ChangePasswordViewState> get copyWith => __$C
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
@override
String toString() {
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
}
@@ -257,7 +253,7 @@ abstract mixin class _$ChangePasswordViewStateCopyWith<$Res> implements $ChangeP
factory _$ChangePasswordViewStateCopyWith(_ChangePasswordViewState value, $Res Function(_ChangePasswordViewState) _then) = __$ChangePasswordViewStateCopyWithImpl;
@override @useResult
$Res call({
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
});
@@ -274,15 +270,13 @@ class __$ChangePasswordViewStateCopyWithImpl<$Res>
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
return _then(_ChangePasswordViewState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,

View File

@@ -1,7 +1,6 @@
import 'package:account/src/core/domain/repositories/users_repository.dart';
import 'package:account/src/core/providers/users_repository_provider.dart';
import 'package:account/src/features/delete_account/presentation/state/delete_account_view_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_shared.dart';
@@ -14,18 +13,12 @@ NotifierProvider.autoDispose<DeleteAccountViewModel, DeleteAccountViewState>(
class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
late final UsersRepository _usersRepository;
late final SharedDevicesRepository _devicesRepository;
late final TextEditingController passwordController;
@override
DeleteAccountViewState build() {
_usersRepository = ref.read(usersRepositoryProvider);
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
passwordController = TextEditingController();
passwordController.addListener(_onPasswordChanged);
ref.onDispose(disposeListeners);
Future.microtask(() => load());
return const DeleteAccountViewState();
@@ -45,13 +38,13 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
void setDevices(List<DeviceEntity> devices) {
state = state.copyWith(
deviceNames: devices.map((device) => device.carrierName!).toList(),
devices: devices.toList(),
deleteDevices: List<bool>.generate(devices.length, (_)=>false),
);
}
void toggleDeleteDevice(int index) {
List<bool> deleteDevices = state.deleteDevices;
List<bool> deleteDevices = state.deleteDevices.toList();
deleteDevices[index] = !deleteDevices[index];
state = state.copyWith(
@@ -59,40 +52,6 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
);
}
void _onPasswordChanged() {
final value = passwordController.text;
if (value == state.password) return;
state = state.copyWith(
password: value,
errorMessage: ''
);
}
bool _validateForm() {
if (state.password.trim().isEmpty) {
state = state.copyWith(errorMessage: 'errorMessagePasswordIsEmpty');
return false;
}
/*if (state.password.trim() != state.loggedUser.password.trim()) {
state = state.copyWith(errorMessage: 'errorMessagePasswordsDontMatch');
return false;
}*/
return true;
}
void nextStep() {
final step = state.confirmStep;
if (step == 0 && !_validateForm()) return;
state = state.copyWith(confirmStep: step + 1);
}
void resetConfirmStep() {
state = state.copyWith(confirmStep: 0);
}
Future<void> deleteAccount() async {
if (state.isLoading) return;
@@ -102,6 +61,12 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
isComplete: false,
);
await state.devices.indexed.map(((int i, DeviceEntity device) element) async {
if (state.deleteDevices[element.$1]){
return await _devicesRepository.deleteDevice(deviceId: element.$2.id);
}
}).wait;
await _usersRepository.deleteUser(userId: state.loggedUser!.id);
if (!ref.mounted) return;
@@ -123,9 +88,4 @@ class DeleteAccountViewModel extends Notifier<DeleteAccountViewState> {
errorMessage: message,
);
}
void disposeListeners() {
passwordController.removeListener(_onPasswordChanged);
passwordController.dispose();
}
}

View File

@@ -11,7 +11,7 @@ abstract class DeleteAccountViewState with _$DeleteAccountViewState {
@Default(false) bool isLoading,
@Default(false) bool isComplete,
@Default(0) int confirmStep,
@Default([]) List<String> deviceNames,
@Default([]) List<DeviceEntity> devices,
@Default([]) List<bool> deleteDevices,
@Default('') String errorMessage,
}) = _DeleteAccountViewState;

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$DeleteAccountViewState {
UserEntity? get loggedUser; String get password; bool get isLoading; bool get isComplete; int get confirmStep; List<String> get deviceNames; List<bool> get deleteDevices; String get errorMessage;
UserEntity? get loggedUser; String get password; bool get isLoading; bool get isComplete; int get confirmStep; List<DeviceEntity> get devices; List<bool> get deleteDevices; String get errorMessage;
/// Create a copy of DeleteAccountViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $DeleteAccountViewStateCopyWith<DeleteAccountViewState> get copyWith => _$Delete
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other.deviceNames, deviceNames)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other.devices, devices)&&const DeepCollectionEquality().equals(other.deleteDevices, deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(deviceNames),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(devices),const DeepCollectionEquality().hash(deleteDevices),errorMessage);
@override
String toString() {
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, devices: $devices, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $DeleteAccountViewStateCopyWith<$Res> {
factory $DeleteAccountViewStateCopyWith(DeleteAccountViewState value, $Res Function(DeleteAccountViewState) _then) = _$DeleteAccountViewStateCopyWithImpl;
@useResult
$Res call({
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage
});
@@ -62,15 +62,15 @@ class _$DeleteAccountViewStateCopyWithImpl<$Res>
/// Create a copy of DeleteAccountViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? devices = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
as int,deviceNames: null == deviceNames ? _self.deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
as List<String>,deleteDevices: null == deleteDevices ? _self.deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
as int,devices: null == devices ? _self.devices : devices // ignore: cast_nullable_to_non_nullable
as List<DeviceEntity>,deleteDevices: null == deleteDevices ? _self.deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
@@ -169,10 +169,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _DeleteAccountViewState() when $default != null:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
return orElse();
}
@@ -190,10 +190,10 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _DeleteAccountViewState():
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -210,10 +210,10 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _DeleteAccountViewState() when $default != null:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.deviceNames,_that.deleteDevices,_that.errorMessage);case _:
return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete,_that.confirmStep,_that.devices,_that.deleteDevices,_that.errorMessage);case _:
return null;
}
@@ -225,7 +225,7 @@ return $default(_that.loggedUser,_that.password,_that.isLoading,_that.isComplete
class _DeleteAccountViewState implements DeleteAccountViewState {
const _DeleteAccountViewState({this.loggedUser, this.password = '', this.isLoading = false, this.isComplete = false, this.confirmStep = 0, final List<String> deviceNames = const [], final List<bool> deleteDevices = const [], this.errorMessage = ''}): _deviceNames = deviceNames,_deleteDevices = deleteDevices;
const _DeleteAccountViewState({this.loggedUser, this.password = '', this.isLoading = false, this.isComplete = false, this.confirmStep = 0, final List<DeviceEntity> devices = const [], final List<bool> deleteDevices = const [], this.errorMessage = ''}): _devices = devices,_deleteDevices = deleteDevices;
@override final UserEntity? loggedUser;
@@ -233,11 +233,11 @@ class _DeleteAccountViewState implements DeleteAccountViewState {
@override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isComplete;
@override@JsonKey() final int confirmStep;
final List<String> _deviceNames;
@override@JsonKey() List<String> get deviceNames {
if (_deviceNames is EqualUnmodifiableListView) return _deviceNames;
final List<DeviceEntity> _devices;
@override@JsonKey() List<DeviceEntity> get devices {
if (_devices is EqualUnmodifiableListView) return _devices;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_deviceNames);
return EqualUnmodifiableListView(_devices);
}
final List<bool> _deleteDevices;
@@ -259,16 +259,16 @@ _$DeleteAccountViewStateCopyWith<_DeleteAccountViewState> get copyWith => __$Del
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other._deviceNames, _deviceNames)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DeleteAccountViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&(identical(other.password, password) || other.password == password)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.confirmStep, confirmStep) || other.confirmStep == confirmStep)&&const DeepCollectionEquality().equals(other._devices, _devices)&&const DeepCollectionEquality().equals(other._deleteDevices, _deleteDevices)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_deviceNames),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
int get hashCode => Object.hash(runtimeType,loggedUser,password,isLoading,isComplete,confirmStep,const DeepCollectionEquality().hash(_devices),const DeepCollectionEquality().hash(_deleteDevices),errorMessage);
@override
String toString() {
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, deviceNames: $deviceNames, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
return 'DeleteAccountViewState(loggedUser: $loggedUser, password: $password, isLoading: $isLoading, isComplete: $isComplete, confirmStep: $confirmStep, devices: $devices, deleteDevices: $deleteDevices, errorMessage: $errorMessage)';
}
@@ -279,7 +279,7 @@ abstract mixin class _$DeleteAccountViewStateCopyWith<$Res> implements $DeleteAc
factory _$DeleteAccountViewStateCopyWith(_DeleteAccountViewState value, $Res Function(_DeleteAccountViewState) _then) = __$DeleteAccountViewStateCopyWithImpl;
@override @useResult
$Res call({
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<String> deviceNames, List<bool> deleteDevices, String errorMessage
UserEntity? loggedUser, String password, bool isLoading, bool isComplete, int confirmStep, List<DeviceEntity> devices, List<bool> deleteDevices, String errorMessage
});
@@ -296,15 +296,15 @@ class __$DeleteAccountViewStateCopyWithImpl<$Res>
/// Create a copy of DeleteAccountViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? deviceNames = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? password = null,Object? isLoading = null,Object? isComplete = null,Object? confirmStep = null,Object? devices = null,Object? deleteDevices = null,Object? errorMessage = null,}) {
return _then(_DeleteAccountViewState(
loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable
as UserEntity?,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,confirmStep: null == confirmStep ? _self.confirmStep : confirmStep // ignore: cast_nullable_to_non_nullable
as int,deviceNames: null == deviceNames ? _self._deviceNames : deviceNames // ignore: cast_nullable_to_non_nullable
as List<String>,deleteDevices: null == deleteDevices ? _self._deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
as int,devices: null == devices ? _self._devices : devices // ignore: cast_nullable_to_non_nullable
as List<DeviceEntity>,deleteDevices: null == deleteDevices ? _self._deleteDevices : deleteDevices // ignore: cast_nullable_to_non_nullable
as List<bool>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));

View File

@@ -5,6 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:navigation/app_routes.dart';
import 'package:navigation/navigation_contract.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:utils/utils.dart';
class ConfirmDialog extends ConsumerWidget{
@@ -24,140 +25,43 @@ class ConfirmDialog extends ConsumerWidget{
final state = ref.watch(deleteAccountViewModelProvider);
final viewModel = ref.read(deleteAccountViewModelProvider.notifier);
final steps = [
_VerifyAccountStep(
theme: theme,
email: state.loggedUser!.email,
passwordController: viewModel.passwordController,
errorMessage: state.errorMessage,
nextStep: viewModel.nextStep,
),
_ConfirmRequestStep(
theme: theme,
toggleDeleteDevice: viewModel.toggleDeleteDevice,
deviceNames: state.deviceNames,
onCancel: (){
viewModel.resetConfirmStep();
Navigator.pop(context);
},
onSubmit: () async {
viewModel.deleteAccount();
if (!context.mounted) return;
final isComplete = ref.read(
return _ConfirmRequestStep(
theme: theme,
toggleDeleteDevice: viewModel.toggleDeleteDevice,
devices: state.devices,
deleteDevices: state.deleteDevices,
onCancel: (){
Navigator.pop(context);
},
onSubmit: () async {
viewModel.deleteAccount();
if (!context.mounted) return;
final isComplete = ref.read(
deleteAccountViewModelProvider.select((s)=>s.isComplete)
);
if (isComplete) {
navigationContract.goTo(AppRoutes.login);
}
},
),
];
return steps[state.confirmStep];
}
}
class _VerifyAccountStep extends StatelessWidget {
final String email;
final TextEditingController passwordController;
final String errorMessage;
final VoidCallback nextStep;
final ThemePort theme;
const _VerifyAccountStep({
required this.email,
required this.passwordController,
required this.errorMessage,
required this.nextStep,
required this.theme,
});
@override
Widget build(BuildContext context) {
return Container(
height: 210,
width: 500,
color: Colors.white,
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 22, vertical: 11),
big: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(context.translate(I18n.verifyAccount),
style: TextStyle(
fontWeight: FontWeight.w500
),
),
SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)),
Text('${context.translate(I18n.email)}: ${email}'),
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 6)),
Row(
children: [
Text('${context.translate(I18n.password)}: '),
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
Expanded(child: TextField(
controller: passwordController,
style: TextStyle(fontSize: 12),
decoration: InputDecoration(hintText: context.translate(I18n.password)),
obscureText: true,
enableSuggestions: false,
autocorrect: true,
))
],
),
if (errorMessage.isNotEmpty)
Text(
errorMessage,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
fontSize: 13,
),
),
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
Row(
children: [
Expanded(child: SecondaryButton(
onPressed: (){Navigator.pop(context);},
text: context.translate(I18n.cancel),
color: theme.getColorFor(ThemeCode.legacyPrimary),
height: 40,
radius: 20,
)),
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
Expanded(child: PrimaryButton(
onPressed: nextStep,
text: context.translate(I18n.accept),
color: theme.getColorFor(ThemeCode.legacyPrimary),
height: 40,
radius: 20,
)),
],
)
],
),
);
if (isComplete) {
navigationContract.goTo(AppRoutes.login);
}
},
);
}
}
class _ConfirmRequestStep extends StatelessWidget {
final ThemePort theme;
final Function toggleDeleteDevice;
final List<String> deviceNames;
final List<DeviceEntity> devices;
final List<bool> deleteDevices;
final VoidCallback onCancel;
final VoidCallback onSubmit;
const _ConfirmRequestStep({
required this.theme,
required this.toggleDeleteDevice,
required this.deviceNames,
required this.devices,
required this.deleteDevices,
required this.onCancel,
required this.onSubmit,
});
@@ -165,7 +69,7 @@ class _ConfirmRequestStep extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 300,
height: 370,
width: 500,
color: Colors.white,
padding: SizeUtils.getByScreen(
@@ -189,16 +93,16 @@ class _ConfirmRequestStep extends StatelessWidget {
style: TextStyle(height: 1.5),
),
SizedBox(height: SizeUtils.getByScreen(small: 12, big: 10)),
...List<Widget>.generate(deviceNames.length, (int index) =>
...List<Widget>.generate(devices.length, (int index) =>
CheckboxListTile(
contentPadding: EdgeInsets.zero,
title: Text(context.translate(I18n.deleteDeviceData,
args: {'name': deviceNames[index]}
args: {'name': devices[index].carrierName}
),
style: TextStyle(height: 0),
),
controlAffinity: ListTileControlAffinity.leading,
value: false,
value: deleteDevices[index],
onChanged: (_){
toggleDeleteDevice(index);
}

View File

@@ -27,16 +27,20 @@ class LinkedDevicesScreen extends ConsumerWidget {
title: context.translate(I18n.linkedDevices),
showEdit: true,
onEditChange: vm.toggleIsEditing,
body: ListView.separated(
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
device: state.linkedDevices[index],
isEditing: state.isEditing,
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: SizeUtils.getByScreen(small: 10, big: 12)),
child: ListView.separated(
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
navigationContract: navigationContract,
device: state.linkedDevices[index],
isEditing: state.isEditing,
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
),
separatorBuilder: (BuildContext context, int index)=>SizedBox(
height: SizeUtils.getByScreen(small: 18, big: 17)
),
itemCount: state.linkedDevices.length
),
separatorBuilder: (BuildContext context, int index)=>SizedBox(
height: SizeUtils.getByScreen(small: 18, big: 17)
),
itemCount: state.linkedDevices.length
),
);
}
@@ -44,11 +48,13 @@ class LinkedDevicesScreen extends ConsumerWidget {
class _LinkedDeviceCard extends ConsumerWidget {
final NavigationContract navigationContract;
final DeviceEntity device;
final bool isEditing;
final Function onDelete;
const _LinkedDeviceCard({
required this.navigationContract,
required this.device,
required this.isEditing,
required this.onDelete,
@@ -76,7 +82,7 @@ class _LinkedDeviceCard extends ConsumerWidget {
shape: BoxShape.circle,
color: theme.getColorFor(ThemeCode.backgroundPrimary),
),
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 8, big: 12)),
child: Icon(SFIcons.watch,
size: SizeUtils.getByScreen(small: 40, big: 44),
color: theme.getColorFor(ThemeCode.legacyPrimary),
@@ -110,7 +116,10 @@ class _LinkedDeviceCard extends ConsumerWidget {
),
child: IconButton(
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
child: DeleteDeviceDialog(device: device),
child: DeleteDeviceDialog(
navigationContract: navigationContract,
device: device,
),
));},
icon: Icon(
Icons.close,

View File

@@ -1,28 +1,23 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
import 'package:legacy_shared/src/data/models/entities/update_device_request_entity.dart';
import 'package:account/src/features/linked_devices/presentation/state/linked_devices_view_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_shared.dart';
import '../../../../core/domain/repositories/devices_repository.dart';
import '../../../../core/providers/devices_repository_provider.dart';
final linkedDevicesViewModelProvider =
NotifierProvider.autoDispose<LinkedDevicesViewModel, LinkedDevicesViewState>(
LinkedDevicesViewModel.new,
);
class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
late final SharedDevicesRepository _getDevicesRepository;
late final DevicesRepository _devicesRepository;
late final SharedDevicesRepository _devicesRepository;
late final TextEditingController deviceNameController;
@override
LinkedDevicesViewState build() {
_getDevicesRepository = ref.read(sharedDevicesRepositoryProvider);
_devicesRepository = ref.read(devicesRepositoryProvider);
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
_initControllers();
_init();
@@ -41,7 +36,7 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
final user = await ref.read(userInfoProvider.future);
state = state.copyWith(loggedUser: user);
final linkedDevices = await _getDevicesRepository.getDevices();
final linkedDevices = await _devicesRepository.getDevices();
state = state.copyWith(
linkedDevices: linkedDevices,
isLoading: false,
@@ -70,19 +65,32 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
);
}
Future<bool> deleteDevice(DeviceEntity device) async {
Future<void> deleteDevice(DeviceEntity device) async {
try {
await _devicesRepository.deleteDevice(userId: state.loggedUser!.id, deviceId: device.identificator);
List<DeviceEntity> newList = state.linkedDevices;
newList.remove(device);
state = state.copyWith(
linkedDevices: newList
isLoading: true,
isComplete: false,
);
return true;
await _devicesRepository.deleteDevice(deviceId: device.id);
List<DeviceEntity> newList = state.linkedDevices.toList();
newList.remove(device);
if (device == state.selectedDevice) {
ref.invalidate(selectedDeviceProvider);
}
state = state.copyWith(
linkedDevices: newList,
isLoading: false,
isComplete: true,
);
} catch (e) {
return false;
state = state.copyWith(
isLoading: false,
errorMessage: e.toString(),
);
return;
}
}
@@ -102,9 +110,7 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
if (deviceName.isEmpty) return;
try {
final userId = state.loggedUser!.id;
_devicesRepository.updateDevice(
userId: userId,
request: _toRequest(device));
} catch(e) {
@@ -114,8 +120,6 @@ class LinkedDevicesViewModel extends Notifier<LinkedDevicesViewState> {
errorMessage: e.toString()
);
}
}
void disposeControllers() {

View File

@@ -2,15 +2,20 @@ import 'package:account/src/features/linked_devices/presentation/state/linked_de
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:utils/utils.dart';
class DeleteDeviceDialog extends ConsumerWidget {
final NavigationContract navigationContract;
final DeviceEntity device;
const DeleteDeviceDialog({required this.device});
const DeleteDeviceDialog({
required this.navigationContract,
required this.device
});
@override
Widget build(BuildContext context, WidgetRef ref) {
@@ -21,15 +26,15 @@ class DeleteDeviceDialog extends ConsumerWidget {
return Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
big: EdgeInsets.symmetric(horizontal: 24, vertical: 18)
),
width: SizeUtils.getByScreen(small: 360, big: 350),
height: SizeUtils.getByScreen(small: 195, big: 185),
height: SizeUtils.getByScreen(small: 184, big: 160),
child: Column(
children: [
Text(context.translate(I18n.deleteDeviceDialog),
textAlign: TextAlign.center,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)),
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 17, big: 16)),
),
SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)),
Row(
@@ -46,7 +51,20 @@ class DeleteDeviceDialog extends ConsumerWidget {
Expanded(child: PrimaryButton(
onPressed: () async {
await vm.deleteDevice(device);
Navigator.pop(context);
final isComplete = ref.read(
linkedDevicesViewModelProvider.select((s)=>s.isComplete)
);
if (isComplete) {
Navigator.pop(context);
}
final noMoreDevices = ref.read(
linkedDevicesViewModelProvider.select((s)=>s.linkedDevices)
).isEmpty;
if (noMoreDevices) {
navigationContract.goTo(AppRoutes.legacyDeviceSetup);
}
},
text: context.translate(I18n.delete),
color: theme.getColorFor(ThemeCode.legacyPrimary),

View File

@@ -8,6 +8,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:navigation/navigation_contract.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart';
import 'widgets/activation_code_dialog.dart';
class LegacyDeviceSetupScreen extends ConsumerWidget {
final NavigationContract navigationContract;
@@ -54,7 +57,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 12, left: 8, right: 8),
padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 4, big: 12), left: 8, right: 8),
child: Row(
children: [
if (isIntro)
@@ -114,6 +117,9 @@ class LegacyDeviceSetupScreen extends ConsumerWidget {
}
return;
}
if (state.step == LegacyAddKidStep.scanWatch && state.errorMessage.isEmpty) {
showActivationCodeDialog(context);
}
await vm.next();
},
theme: theme,

View File

@@ -3,6 +3,7 @@ import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart';
class LegacyIntroStepScreen extends ConsumerWidget {
const LegacyIntroStepScreen({super.key});
@@ -11,29 +12,34 @@ class LegacyIntroStepScreen extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themePortProvider);
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
context.translate(I18n.deviceSetup_intro_title),
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
const SizedBox(height: 30),
Text(
context.translate(I18n.deviceSetup_intro_subtitle),
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
SizedBox(height: 40),
LegacyNumberedSteps(
steps: [
context.translate(I18n.deviceSetup_intro_step_1),
context.translate(I18n.deviceSetup_intro_step_2),
],
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
],
return Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeUtils.getByScreen(small: 8, big: 2)
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
context.translate(I18n.deviceSetup_intro_title),
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
const SizedBox(height: 30),
Text(
context.translate(I18n.deviceSetup_intro_subtitle),
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
SizedBox(height: 40),
LegacyNumberedSteps(
steps: [
context.translate(I18n.deviceSetup_intro_step_1),
context.translate(I18n.deviceSetup_intro_step_2),
],
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
],
),
);
}
}

View File

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart';
class LegacyLinkInfoStepScreen extends ConsumerWidget {
const LegacyLinkInfoStepScreen({super.key});
@@ -13,7 +14,7 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget {
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 30),
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 30)),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 65),
child: Text(

View File

@@ -147,7 +147,7 @@ class LegacyProfileStepScreen extends ConsumerWidget {
CustomTextField(
label: context.translate(I18n.activationKeyLabel),
hint: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
hint: 'XXXXXXXX',
controller: vm.activationKeyController,
),

View File

@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart';
void showActivationCodeDialog(BuildContext context) {
showDialog(context: context, builder: (context) =>
Dialog(
backgroundColor: Colors.transparent,
child: _ActivationCodeDialog(),
)
);
}
class _ActivationCodeDialog extends StatelessWidget {
const _ActivationCodeDialog();
@override
Widget build(BuildContext context) {
return Container(
padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 14, vertical: 24),
big: EdgeInsets.symmetric(horizontal: 12, vertical: 20),
),
color: Colors.white,
child: Text(context.translate(I18n.activationCodeMessage),
textAlign: TextAlign.center,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 16, big: 15)),
),
);
}
}

View File

@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:legacy_auth/src/features/login/presentation/widgets/otp_code_fields.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:utils/utils.dart';
class LegacyTwoFactorBottomSheetView extends StatelessWidget {
const LegacyTwoFactorBottomSheetView({
@@ -88,6 +89,7 @@ class LegacyTwoFactorBottomSheetView extends StatelessWidget {
if (isOtpLoading || !_isValidOtp) return;
unawaited(onVerify());
},
gap: SizeUtils.getByScreen(small: 10, big: 8),
),
const SizedBox(height: 20),

View File

@@ -1,5 +1,11 @@
import 'package:sf_shared/sf_shared.dart';
import '../models/entities/update_device_request_entity.dart';
abstract class DevicesRemoteDatasource {
Future<List<DeviceEntity>> getDevices();
Future<void> deleteDevice({required String deviceId});
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
}

View File

@@ -1,7 +1,10 @@
import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:legacy_shared/src/data/models/update_device_request_model.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart';
import 'package:sf_shared/sf_shared.dart';
import '../models/entities/update_device_request_entity.dart';
import 'devices_remote_datasource.dart';
class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
@@ -24,4 +27,28 @@ class DevicesRemoteDatasourceImpl implements DevicesRemoteDatasource {
final model = GetDevicesResponseModel.fromJson(data);
return model.toEntity();
}
@override
Future<void> deleteDevice({required String deviceId}) async {
try {
await _repository.delete<void>(
'/devices/$deviceId',
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to delete device');
}
}
@override
Future<void> updateDevice({required UpdateDeviceRequestEntity request}) async {
try {
final body = request.toModel().toJson();
await _repository.put<void>(
'/devices',
body: body,
);
} on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to update device');
}
}
}

View File

@@ -1,6 +1,7 @@
import 'package:account/src/features/linked_devices/domain/entities/update_device_request_entity.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'entities/update_device_request_entity.dart';
part 'update_device_request_model.freezed.dart';
part 'update_device_request_model.g.dart';

View File

@@ -2,6 +2,7 @@ import 'package:sf_shared/sf_shared.dart';
import '../../domain/repositories/devices_repository.dart';
import '../datasources/devices_remote_datasource.dart';
import '../models/entities/update_device_request_entity.dart';
class DevicesRepositoryImpl implements SharedDevicesRepository {
const DevicesRepositoryImpl(this._remote);
@@ -12,4 +13,14 @@ class DevicesRepositoryImpl implements SharedDevicesRepository {
Future<List<DeviceEntity>> getDevices() async {
return _remote.getDevices();
}
@override
Future<void> deleteDevice({required String deviceId}) {
return _remote.deleteDevice(deviceId: deviceId);
}
@override
Future<void> updateDevice({required UpdateDeviceRequestEntity request}) {
return _remote.updateDevice(request: request);
}
}

View File

@@ -1,5 +1,11 @@
import 'package:sf_shared/sf_shared.dart';
import '../../data/models/entities/update_device_request_entity.dart';
abstract class SharedDevicesRepository {
Future<List<DeviceEntity>> getDevices();
Future<void> updateDevice({required UpdateDeviceRequestEntity request});
Future<void> deleteDevice({required String deviceId});
}

View File

@@ -298,11 +298,13 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
try {
final treezorRepo = ref.read(treezorRepositoryProvider);
final beneficiaryValidationId = await treezorRepo
final validation = await treezorRepo
.validateTransactionBeneficiary(beneficiaryId: beneficiary.id);
if (!ref.mounted) return;
final beneficiaryValidationId = validation.beneficiaryValidationId;
final url = 'https://savefamily.sandbox.treezor.co/v1/payouts';
final scaInput = {
'url': url,

View File

@@ -70,7 +70,7 @@ class _SplashScreenState extends State<SplashScreen>
controller: _controller,
onLoaded: (composition) {
_controller
..duration = composition.duration
..duration = composition.duration * 0.8
..forward();
},
),

View File

@@ -7,6 +7,6 @@
<versions>
<version>2.6.4</version>
</versions>
<lastUpdated>20260316000000</lastUpdated>
<lastUpdated>20260318000000</lastUpdated>
</versioning>
</metadata>

View File

@@ -1 +1 @@
a0ed8b315dd3aaa92839422686f00f9d
f9e85f64806f37132f0c0cc4ef8a67ec

View File

@@ -1 +1 @@
4888c373e3701bd965ce8ff0daaa19071f7d9a9e
b7a72907f1f917f7b7d0cd57cb170901965b4113

View File

@@ -16,16 +16,19 @@ class TreezorTokenInterceptor extends Interceptor {
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
if (!_handling) {
final message = _extractApiMessage(err.response?.data);
if (message != null && message.contains('Treezor Token Expired')) {
_handling = true;
_onTokenExpired();
Future.delayed(const Duration(seconds: 2), () => _handling = false);
} else if (err.response?.statusCode == 500) {
_handling = true;
_onTokenExpired();
Future.delayed(const Duration(seconds: 2), () => _handling = false);
} else if (err.response?.statusCode == 401) {
// final message = _extractApiMessage(err.response?.data);
// if (message != null && message.contains('Treezor Token Expired')) {
// _handling = true;
// _onTokenExpired();
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
// }
// else if (err.response?.statusCode == 500) {
// _handling = true;
// _onTokenExpired();
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
// }
// else
if (err.response?.statusCode == 401) {
_handling = true;
_onUnauthorized();
Future.delayed(const Duration(seconds: 2), () => _handling = false);

View File

@@ -582,7 +582,7 @@
"deviceSetup_weightHint": "30",
"deviceSetup_heightLabel": "Height (cm)",
"deviceSetup_heightHint": "120",
"activationKeyLabel": "Activation key",
"activationKeyLabel": "Activation key (check your email)",
"rewardsMessage": "*Using this feature you can reward your child for goals achieved or good actions.",
"sendRewards": "Send rewards!",
"rewardsSent": "Rewards sent!",
@@ -705,5 +705,6 @@
"wifiBssidHint": "e.g. 0c:80:63:e4:cb:e1",
"editChildProfile": "Edit profile",
"editChildProfileSaveSuccess": "Child profile updated successfully",
"editChildProfileTitle": "Edit child profile"
"editChildProfileTitle": "Edit child profile",
"activationCodeMessage": "An activation key has been sent to your email"
}

View File

@@ -580,7 +580,7 @@
"deviceSetup_weightHint": "30",
"deviceSetup_heightLabel": "Altura (cm)",
"deviceSetup_heightHint": "120",
"activationKeyLabel": "Clave de activación",
"activationKeyLabel": "Clave de activación (consulta tu correo electrónico)",
"rewardsMessage": "*Usando esta función puedes recompensar a tu hijo por metas alcanzadas o buenas acciones.",
"sendRewards": "¡Enviar recompensas!",
"rewardsSent": "¡Recompensas enviadas!",
@@ -703,5 +703,6 @@
"wifiBssidHint": "ej. 0c:80:63:e4:cb:e1",
"editChildProfile": "Editar perfil",
"editChildProfileTitle": "Editar perfil del niño",
"editChildProfileSaveSuccess": "Perfil del niño actualizado correctamente"
"editChildProfileSaveSuccess": "Perfil del niño actualizado correctamente",
"activationCodeMessage": "Se ha enviado un código de activación a tu correo electrónico"
}

View File

@@ -829,4 +829,5 @@ class I18n {
static const String editChildProfile = 'editChildProfile';
static const String editChildProfileTitle = 'editChildProfileTitle';
static const String editChildProfileSaveSuccess = 'editChildProfileSaveSuccess';
static const String activationCodeMessage = 'activationCodeMessage';
}

View File

@@ -29,6 +29,7 @@ export 'src/providers/user_info_provider.dart';
export 'src/domain/repositories/user_repository.dart';
export 'src/data/repositories/user_repository_impl.dart';
export 'src/data/datasource/user_remote_datasource_impl.dart';
export 'src/domain/entities/beneficiary_validation_entity.dart';
export 'src/domain/entities/transaction_beneficiary_entity.dart';
export 'src/data/models/payout_beneficiary_model.dart';
export 'src/domain/entities/payout_beneficiary_entity.dart';

View File

@@ -3,6 +3,7 @@ import 'package:sf_shared/src/data/models/mcc_group_model.dart';
import 'package:sf_shared/src/data/models/payment_profile_response_model.dart';
import 'package:sf_shared/src/data/models/payout_beneficiary_model.dart';
import 'package:sf_shared/src/data/models/sca_wallet_model.dart';
import 'package:sf_shared/src/data/models/beneficiary_validation_model.dart';
import 'package:sf_shared/src/data/models/transaction_beneficiary_model.dart';
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
@@ -41,7 +42,7 @@ abstract class TreezorRemoteDatasource {
required String scaProof,
});
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
Future<BeneficiaryValidationResponseModel> validateTransactionBeneficiary({required int beneficiaryId});
Future<void> walletTransfer({
required int beneficiaryId,

View File

@@ -7,6 +7,7 @@ import 'package:sf_shared/src/data/models/mcc_group_model.dart';
import 'package:sf_shared/src/data/models/payment_profile_response_model.dart';
import 'package:sf_shared/src/data/models/payout_beneficiary_model.dart';
import 'package:sf_shared/src/data/models/sca_wallet_model.dart';
import 'package:sf_shared/src/data/models/beneficiary_validation_model.dart';
import 'package:sf_shared/src/data/models/transaction_beneficiary_model.dart';
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
@@ -241,7 +242,7 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
}
@override
Future<String> validateTransactionBeneficiary({
Future<BeneficiaryValidationResponseModel> validateTransactionBeneficiary({
required int beneficiaryId,
}) async {
try {
@@ -254,7 +255,9 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
'Invalid response from /transaction-beneficiaries/$beneficiaryId/validation',
);
}
return data['item'] as String;
return BeneficiaryValidationResponseModel.fromJson(
Map<String, dynamic>.from(data),
);
} on DioException catch (error) {
throw _mapDioError(
error,

View File

@@ -0,0 +1,54 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:sf_shared/src/domain/entities/beneficiary_validation_entity.dart';
part 'beneficiary_validation_model.freezed.dart';
part 'beneficiary_validation_model.g.dart';
@freezed
abstract class BeneficiaryValidationResponseModel
with _$BeneficiaryValidationResponseModel {
const BeneficiaryValidationResponseModel._();
const factory BeneficiaryValidationResponseModel({
@Default(false) bool isCreated,
required BeneficiaryValidationItemModel item,
}) = _BeneficiaryValidationResponseModel;
factory BeneficiaryValidationResponseModel.fromJson(
Map<String, dynamic> json,
) =>
_$BeneficiaryValidationResponseModelFromJson(json);
BeneficiaryValidationEntity toEntity() => BeneficiaryValidationEntity(
isCreated: isCreated,
beneficiaryValidationId: item.beneficiaryValidationId,
createdDate: item.createdDate,
vopResult: item.vop?.result ?? '',
);
}
@freezed
abstract class BeneficiaryValidationItemModel
with _$BeneficiaryValidationItemModel {
const factory BeneficiaryValidationItemModel({
required String beneficiaryValidationId,
@Default('') String createdDate,
BeneficiaryValidationVopModel? vop,
}) = _BeneficiaryValidationItemModel;
factory BeneficiaryValidationItemModel.fromJson(Map<String, dynamic> json) =>
_$BeneficiaryValidationItemModelFromJson(json);
}
@freezed
abstract class BeneficiaryValidationVopModel
with _$BeneficiaryValidationVopModel {
const factory BeneficiaryValidationVopModel({
@Default('') String matchedName,
@Default('') String recurrenceType,
@Default('') String result,
}) = _BeneficiaryValidationVopModel;
factory BeneficiaryValidationVopModel.fromJson(Map<String, dynamic> json) =>
_$BeneficiaryValidationVopModelFromJson(json);
}

View File

@@ -0,0 +1,860 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'beneficiary_validation_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$BeneficiaryValidationResponseModel {
bool get isCreated; BeneficiaryValidationItemModel get item;
/// Create a copy of BeneficiaryValidationResponseModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BeneficiaryValidationResponseModelCopyWith<BeneficiaryValidationResponseModel> get copyWith => _$BeneficiaryValidationResponseModelCopyWithImpl<BeneficiaryValidationResponseModel>(this as BeneficiaryValidationResponseModel, _$identity);
/// Serializes this BeneficiaryValidationResponseModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'BeneficiaryValidationResponseModel(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class $BeneficiaryValidationResponseModelCopyWith<$Res> {
factory $BeneficiaryValidationResponseModelCopyWith(BeneficiaryValidationResponseModel value, $Res Function(BeneficiaryValidationResponseModel) _then) = _$BeneficiaryValidationResponseModelCopyWithImpl;
@useResult
$Res call({
bool isCreated, BeneficiaryValidationItemModel item
});
$BeneficiaryValidationItemModelCopyWith<$Res> get item;
}
/// @nodoc
class _$BeneficiaryValidationResponseModelCopyWithImpl<$Res>
implements $BeneficiaryValidationResponseModelCopyWith<$Res> {
_$BeneficiaryValidationResponseModelCopyWithImpl(this._self, this._then);
final BeneficiaryValidationResponseModel _self;
final $Res Function(BeneficiaryValidationResponseModel) _then;
/// Create a copy of BeneficiaryValidationResponseModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_self.copyWith(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as BeneficiaryValidationItemModel,
));
}
/// Create a copy of BeneficiaryValidationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$BeneficiaryValidationItemModelCopyWith<$Res> get item {
return $BeneficiaryValidationItemModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// Adds pattern-matching-related methods to [BeneficiaryValidationResponseModel].
extension BeneficiaryValidationResponseModelPatterns on BeneficiaryValidationResponseModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BeneficiaryValidationResponseModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BeneficiaryValidationResponseModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BeneficiaryValidationResponseModel value) $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationResponseModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BeneficiaryValidationResponseModel value)? $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationResponseModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, BeneficiaryValidationItemModel item)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BeneficiaryValidationResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, BeneficiaryValidationItemModel item) $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationResponseModel():
return $default(_that.isCreated,_that.item);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, BeneficiaryValidationItemModel item)? $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationResponseModel() when $default != null:
return $default(_that.isCreated,_that.item);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _BeneficiaryValidationResponseModel extends BeneficiaryValidationResponseModel {
const _BeneficiaryValidationResponseModel({this.isCreated = false, required this.item}): super._();
factory _BeneficiaryValidationResponseModel.fromJson(Map<String, dynamic> json) => _$BeneficiaryValidationResponseModelFromJson(json);
@override@JsonKey() final bool isCreated;
@override final BeneficiaryValidationItemModel item;
/// Create a copy of BeneficiaryValidationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BeneficiaryValidationResponseModelCopyWith<_BeneficiaryValidationResponseModel> get copyWith => __$BeneficiaryValidationResponseModelCopyWithImpl<_BeneficiaryValidationResponseModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$BeneficiaryValidationResponseModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,isCreated,item);
@override
String toString() {
return 'BeneficiaryValidationResponseModel(isCreated: $isCreated, item: $item)';
}
}
/// @nodoc
abstract mixin class _$BeneficiaryValidationResponseModelCopyWith<$Res> implements $BeneficiaryValidationResponseModelCopyWith<$Res> {
factory _$BeneficiaryValidationResponseModelCopyWith(_BeneficiaryValidationResponseModel value, $Res Function(_BeneficiaryValidationResponseModel) _then) = __$BeneficiaryValidationResponseModelCopyWithImpl;
@override @useResult
$Res call({
bool isCreated, BeneficiaryValidationItemModel item
});
@override $BeneficiaryValidationItemModelCopyWith<$Res> get item;
}
/// @nodoc
class __$BeneficiaryValidationResponseModelCopyWithImpl<$Res>
implements _$BeneficiaryValidationResponseModelCopyWith<$Res> {
__$BeneficiaryValidationResponseModelCopyWithImpl(this._self, this._then);
final _BeneficiaryValidationResponseModel _self;
final $Res Function(_BeneficiaryValidationResponseModel) _then;
/// Create a copy of BeneficiaryValidationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) {
return _then(_BeneficiaryValidationResponseModel(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
as BeneficiaryValidationItemModel,
));
}
/// Create a copy of BeneficiaryValidationResponseModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$BeneficiaryValidationItemModelCopyWith<$Res> get item {
return $BeneficiaryValidationItemModelCopyWith<$Res>(_self.item, (value) {
return _then(_self.copyWith(item: value));
});
}
}
/// @nodoc
mixin _$BeneficiaryValidationItemModel {
String get beneficiaryValidationId; String get createdDate; BeneficiaryValidationVopModel? get vop;
/// Create a copy of BeneficiaryValidationItemModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BeneficiaryValidationItemModelCopyWith<BeneficiaryValidationItemModel> get copyWith => _$BeneficiaryValidationItemModelCopyWithImpl<BeneficiaryValidationItemModel>(this as BeneficiaryValidationItemModel, _$identity);
/// Serializes this BeneficiaryValidationItemModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationItemModel&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vop, vop) || other.vop == vop));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,beneficiaryValidationId,createdDate,vop);
@override
String toString() {
return 'BeneficiaryValidationItemModel(beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vop: $vop)';
}
}
/// @nodoc
abstract mixin class $BeneficiaryValidationItemModelCopyWith<$Res> {
factory $BeneficiaryValidationItemModelCopyWith(BeneficiaryValidationItemModel value, $Res Function(BeneficiaryValidationItemModel) _then) = _$BeneficiaryValidationItemModelCopyWithImpl;
@useResult
$Res call({
String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop
});
$BeneficiaryValidationVopModelCopyWith<$Res>? get vop;
}
/// @nodoc
class _$BeneficiaryValidationItemModelCopyWithImpl<$Res>
implements $BeneficiaryValidationItemModelCopyWith<$Res> {
_$BeneficiaryValidationItemModelCopyWithImpl(this._self, this._then);
final BeneficiaryValidationItemModel _self;
final $Res Function(BeneficiaryValidationItemModel) _then;
/// Create a copy of BeneficiaryValidationItemModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vop = freezed,}) {
return _then(_self.copyWith(
beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
as String,vop: freezed == vop ? _self.vop : vop // ignore: cast_nullable_to_non_nullable
as BeneficiaryValidationVopModel?,
));
}
/// Create a copy of BeneficiaryValidationItemModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$BeneficiaryValidationVopModelCopyWith<$Res>? get vop {
if (_self.vop == null) {
return null;
}
return $BeneficiaryValidationVopModelCopyWith<$Res>(_self.vop!, (value) {
return _then(_self.copyWith(vop: value));
});
}
}
/// Adds pattern-matching-related methods to [BeneficiaryValidationItemModel].
extension BeneficiaryValidationItemModelPatterns on BeneficiaryValidationItemModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BeneficiaryValidationItemModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BeneficiaryValidationItemModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BeneficiaryValidationItemModel value) $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationItemModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BeneficiaryValidationItemModel value)? $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationItemModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BeneficiaryValidationItemModel() when $default != null:
return $default(_that.beneficiaryValidationId,_that.createdDate,_that.vop);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop) $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationItemModel():
return $default(_that.beneficiaryValidationId,_that.createdDate,_that.vop);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop)? $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationItemModel() when $default != null:
return $default(_that.beneficiaryValidationId,_that.createdDate,_that.vop);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _BeneficiaryValidationItemModel implements BeneficiaryValidationItemModel {
const _BeneficiaryValidationItemModel({required this.beneficiaryValidationId, this.createdDate = '', this.vop});
factory _BeneficiaryValidationItemModel.fromJson(Map<String, dynamic> json) => _$BeneficiaryValidationItemModelFromJson(json);
@override final String beneficiaryValidationId;
@override@JsonKey() final String createdDate;
@override final BeneficiaryValidationVopModel? vop;
/// Create a copy of BeneficiaryValidationItemModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BeneficiaryValidationItemModelCopyWith<_BeneficiaryValidationItemModel> get copyWith => __$BeneficiaryValidationItemModelCopyWithImpl<_BeneficiaryValidationItemModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$BeneficiaryValidationItemModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationItemModel&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vop, vop) || other.vop == vop));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,beneficiaryValidationId,createdDate,vop);
@override
String toString() {
return 'BeneficiaryValidationItemModel(beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vop: $vop)';
}
}
/// @nodoc
abstract mixin class _$BeneficiaryValidationItemModelCopyWith<$Res> implements $BeneficiaryValidationItemModelCopyWith<$Res> {
factory _$BeneficiaryValidationItemModelCopyWith(_BeneficiaryValidationItemModel value, $Res Function(_BeneficiaryValidationItemModel) _then) = __$BeneficiaryValidationItemModelCopyWithImpl;
@override @useResult
$Res call({
String beneficiaryValidationId, String createdDate, BeneficiaryValidationVopModel? vop
});
@override $BeneficiaryValidationVopModelCopyWith<$Res>? get vop;
}
/// @nodoc
class __$BeneficiaryValidationItemModelCopyWithImpl<$Res>
implements _$BeneficiaryValidationItemModelCopyWith<$Res> {
__$BeneficiaryValidationItemModelCopyWithImpl(this._self, this._then);
final _BeneficiaryValidationItemModel _self;
final $Res Function(_BeneficiaryValidationItemModel) _then;
/// Create a copy of BeneficiaryValidationItemModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vop = freezed,}) {
return _then(_BeneficiaryValidationItemModel(
beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
as String,vop: freezed == vop ? _self.vop : vop // ignore: cast_nullable_to_non_nullable
as BeneficiaryValidationVopModel?,
));
}
/// Create a copy of BeneficiaryValidationItemModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$BeneficiaryValidationVopModelCopyWith<$Res>? get vop {
if (_self.vop == null) {
return null;
}
return $BeneficiaryValidationVopModelCopyWith<$Res>(_self.vop!, (value) {
return _then(_self.copyWith(vop: value));
});
}
}
/// @nodoc
mixin _$BeneficiaryValidationVopModel {
String get matchedName; String get recurrenceType; String get result;
/// Create a copy of BeneficiaryValidationVopModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BeneficiaryValidationVopModelCopyWith<BeneficiaryValidationVopModel> get copyWith => _$BeneficiaryValidationVopModelCopyWithImpl<BeneficiaryValidationVopModel>(this as BeneficiaryValidationVopModel, _$identity);
/// Serializes this BeneficiaryValidationVopModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationVopModel&&(identical(other.matchedName, matchedName) || other.matchedName == matchedName)&&(identical(other.recurrenceType, recurrenceType) || other.recurrenceType == recurrenceType)&&(identical(other.result, result) || other.result == result));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,matchedName,recurrenceType,result);
@override
String toString() {
return 'BeneficiaryValidationVopModel(matchedName: $matchedName, recurrenceType: $recurrenceType, result: $result)';
}
}
/// @nodoc
abstract mixin class $BeneficiaryValidationVopModelCopyWith<$Res> {
factory $BeneficiaryValidationVopModelCopyWith(BeneficiaryValidationVopModel value, $Res Function(BeneficiaryValidationVopModel) _then) = _$BeneficiaryValidationVopModelCopyWithImpl;
@useResult
$Res call({
String matchedName, String recurrenceType, String result
});
}
/// @nodoc
class _$BeneficiaryValidationVopModelCopyWithImpl<$Res>
implements $BeneficiaryValidationVopModelCopyWith<$Res> {
_$BeneficiaryValidationVopModelCopyWithImpl(this._self, this._then);
final BeneficiaryValidationVopModel _self;
final $Res Function(BeneficiaryValidationVopModel) _then;
/// Create a copy of BeneficiaryValidationVopModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? matchedName = null,Object? recurrenceType = null,Object? result = null,}) {
return _then(_self.copyWith(
matchedName: null == matchedName ? _self.matchedName : matchedName // ignore: cast_nullable_to_non_nullable
as String,recurrenceType: null == recurrenceType ? _self.recurrenceType : recurrenceType // ignore: cast_nullable_to_non_nullable
as String,result: null == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [BeneficiaryValidationVopModel].
extension BeneficiaryValidationVopModelPatterns on BeneficiaryValidationVopModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BeneficiaryValidationVopModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BeneficiaryValidationVopModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BeneficiaryValidationVopModel value) $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationVopModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BeneficiaryValidationVopModel value)? $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationVopModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String matchedName, String recurrenceType, String result)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BeneficiaryValidationVopModel() when $default != null:
return $default(_that.matchedName,_that.recurrenceType,_that.result);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String matchedName, String recurrenceType, String result) $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationVopModel():
return $default(_that.matchedName,_that.recurrenceType,_that.result);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String matchedName, String recurrenceType, String result)? $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationVopModel() when $default != null:
return $default(_that.matchedName,_that.recurrenceType,_that.result);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _BeneficiaryValidationVopModel implements BeneficiaryValidationVopModel {
const _BeneficiaryValidationVopModel({this.matchedName = '', this.recurrenceType = '', this.result = ''});
factory _BeneficiaryValidationVopModel.fromJson(Map<String, dynamic> json) => _$BeneficiaryValidationVopModelFromJson(json);
@override@JsonKey() final String matchedName;
@override@JsonKey() final String recurrenceType;
@override@JsonKey() final String result;
/// Create a copy of BeneficiaryValidationVopModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BeneficiaryValidationVopModelCopyWith<_BeneficiaryValidationVopModel> get copyWith => __$BeneficiaryValidationVopModelCopyWithImpl<_BeneficiaryValidationVopModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$BeneficiaryValidationVopModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationVopModel&&(identical(other.matchedName, matchedName) || other.matchedName == matchedName)&&(identical(other.recurrenceType, recurrenceType) || other.recurrenceType == recurrenceType)&&(identical(other.result, result) || other.result == result));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,matchedName,recurrenceType,result);
@override
String toString() {
return 'BeneficiaryValidationVopModel(matchedName: $matchedName, recurrenceType: $recurrenceType, result: $result)';
}
}
/// @nodoc
abstract mixin class _$BeneficiaryValidationVopModelCopyWith<$Res> implements $BeneficiaryValidationVopModelCopyWith<$Res> {
factory _$BeneficiaryValidationVopModelCopyWith(_BeneficiaryValidationVopModel value, $Res Function(_BeneficiaryValidationVopModel) _then) = __$BeneficiaryValidationVopModelCopyWithImpl;
@override @useResult
$Res call({
String matchedName, String recurrenceType, String result
});
}
/// @nodoc
class __$BeneficiaryValidationVopModelCopyWithImpl<$Res>
implements _$BeneficiaryValidationVopModelCopyWith<$Res> {
__$BeneficiaryValidationVopModelCopyWithImpl(this._self, this._then);
final _BeneficiaryValidationVopModel _self;
final $Res Function(_BeneficiaryValidationVopModel) _then;
/// Create a copy of BeneficiaryValidationVopModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? matchedName = null,Object? recurrenceType = null,Object? result = null,}) {
return _then(_BeneficiaryValidationVopModel(
matchedName: null == matchedName ? _self.matchedName : matchedName // ignore: cast_nullable_to_non_nullable
as String,recurrenceType: null == recurrenceType ? _self.recurrenceType : recurrenceType // ignore: cast_nullable_to_non_nullable
as String,result: null == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View File

@@ -0,0 +1,56 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'beneficiary_validation_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_BeneficiaryValidationResponseModel
_$BeneficiaryValidationResponseModelFromJson(Map<String, dynamic> json) =>
_BeneficiaryValidationResponseModel(
isCreated: json['isCreated'] as bool? ?? false,
item: BeneficiaryValidationItemModel.fromJson(
json['item'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$BeneficiaryValidationResponseModelToJson(
_BeneficiaryValidationResponseModel instance,
) => <String, dynamic>{'isCreated': instance.isCreated, 'item': instance.item};
_BeneficiaryValidationItemModel _$BeneficiaryValidationItemModelFromJson(
Map<String, dynamic> json,
) => _BeneficiaryValidationItemModel(
beneficiaryValidationId: json['beneficiaryValidationId'] as String,
createdDate: json['createdDate'] as String? ?? '',
vop: json['vop'] == null
? null
: BeneficiaryValidationVopModel.fromJson(
json['vop'] as Map<String, dynamic>,
),
);
Map<String, dynamic> _$BeneficiaryValidationItemModelToJson(
_BeneficiaryValidationItemModel instance,
) => <String, dynamic>{
'beneficiaryValidationId': instance.beneficiaryValidationId,
'createdDate': instance.createdDate,
'vop': instance.vop,
};
_BeneficiaryValidationVopModel _$BeneficiaryValidationVopModelFromJson(
Map<String, dynamic> json,
) => _BeneficiaryValidationVopModel(
matchedName: json['matchedName'] as String? ?? '',
recurrenceType: json['recurrenceType'] as String? ?? '',
result: json['result'] as String? ?? '',
);
Map<String, dynamic> _$BeneficiaryValidationVopModelToJson(
_BeneficiaryValidationVopModel instance,
) => <String, dynamic>{
'matchedName': instance.matchedName,
'recurrenceType': instance.recurrenceType,
'result': instance.result,
};

View File

@@ -14,6 +14,7 @@ import 'package:sf_shared/src/domain/entities/payment_profile_entity.dart';
import 'package:sf_shared/src/domain/entities/child_wallet_entity.dart';
import 'package:sf_shared/src/domain/entities/payout_beneficiary_entity.dart';
import 'package:sf_shared/src/domain/entities/sca_wallet_entity.dart';
import 'package:sf_shared/src/domain/entities/beneficiary_validation_entity.dart';
import 'package:sf_shared/src/domain/entities/transaction_beneficiary_entity.dart';
import 'package:sf_shared/src/domain/entities/wallet_balance_entity.dart';
import 'package:sf_shared/src/domain/entities/wallet_transaction_entity.dart';
@@ -185,12 +186,13 @@ class TreezorRepositoryImpl implements TreezorRepository {
}
@override
Future<String> validateTransactionBeneficiary({
Future<BeneficiaryValidationEntity> validateTransactionBeneficiary({
required int beneficiaryId,
}) async {
return _remote.validateTransactionBeneficiary(
final model = await _remote.validateTransactionBeneficiary(
beneficiaryId: beneficiaryId,
);
return model.toEntity();
}
@override

View File

@@ -0,0 +1,14 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'beneficiary_validation_entity.freezed.dart';
@freezed
abstract class BeneficiaryValidationEntity
with _$BeneficiaryValidationEntity {
const factory BeneficiaryValidationEntity({
@Default(false) bool isCreated,
required String beneficiaryValidationId,
@Default('') String createdDate,
@Default('') String vopResult,
}) = _BeneficiaryValidationEntity;
}

View File

@@ -0,0 +1,280 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'beneficiary_validation_entity.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$BeneficiaryValidationEntity {
bool get isCreated; String get beneficiaryValidationId; String get createdDate; String get vopResult;
/// Create a copy of BeneficiaryValidationEntity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BeneficiaryValidationEntityCopyWith<BeneficiaryValidationEntity> get copyWith => _$BeneficiaryValidationEntityCopyWithImpl<BeneficiaryValidationEntity>(this as BeneficiaryValidationEntity, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BeneficiaryValidationEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vopResult, vopResult) || other.vopResult == vopResult));
}
@override
int get hashCode => Object.hash(runtimeType,isCreated,beneficiaryValidationId,createdDate,vopResult);
@override
String toString() {
return 'BeneficiaryValidationEntity(isCreated: $isCreated, beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vopResult: $vopResult)';
}
}
/// @nodoc
abstract mixin class $BeneficiaryValidationEntityCopyWith<$Res> {
factory $BeneficiaryValidationEntityCopyWith(BeneficiaryValidationEntity value, $Res Function(BeneficiaryValidationEntity) _then) = _$BeneficiaryValidationEntityCopyWithImpl;
@useResult
$Res call({
bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult
});
}
/// @nodoc
class _$BeneficiaryValidationEntityCopyWithImpl<$Res>
implements $BeneficiaryValidationEntityCopyWith<$Res> {
_$BeneficiaryValidationEntityCopyWithImpl(this._self, this._then);
final BeneficiaryValidationEntity _self;
final $Res Function(BeneficiaryValidationEntity) _then;
/// Create a copy of BeneficiaryValidationEntity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vopResult = null,}) {
return _then(_self.copyWith(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
as String,vopResult: null == vopResult ? _self.vopResult : vopResult // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [BeneficiaryValidationEntity].
extension BeneficiaryValidationEntityPatterns on BeneficiaryValidationEntity {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BeneficiaryValidationEntity value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BeneficiaryValidationEntity() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BeneficiaryValidationEntity value) $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationEntity():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BeneficiaryValidationEntity value)? $default,){
final _that = this;
switch (_that) {
case _BeneficiaryValidationEntity() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BeneficiaryValidationEntity() when $default != null:
return $default(_that.isCreated,_that.beneficiaryValidationId,_that.createdDate,_that.vopResult);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult) $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationEntity():
return $default(_that.isCreated,_that.beneficiaryValidationId,_that.createdDate,_that.vopResult);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult)? $default,) {final _that = this;
switch (_that) {
case _BeneficiaryValidationEntity() when $default != null:
return $default(_that.isCreated,_that.beneficiaryValidationId,_that.createdDate,_that.vopResult);case _:
return null;
}
}
}
/// @nodoc
class _BeneficiaryValidationEntity implements BeneficiaryValidationEntity {
const _BeneficiaryValidationEntity({this.isCreated = false, required this.beneficiaryValidationId, this.createdDate = '', this.vopResult = ''});
@override@JsonKey() final bool isCreated;
@override final String beneficiaryValidationId;
@override@JsonKey() final String createdDate;
@override@JsonKey() final String vopResult;
/// Create a copy of BeneficiaryValidationEntity
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BeneficiaryValidationEntityCopyWith<_BeneficiaryValidationEntity> get copyWith => __$BeneficiaryValidationEntityCopyWithImpl<_BeneficiaryValidationEntity>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BeneficiaryValidationEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.beneficiaryValidationId, beneficiaryValidationId) || other.beneficiaryValidationId == beneficiaryValidationId)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.vopResult, vopResult) || other.vopResult == vopResult));
}
@override
int get hashCode => Object.hash(runtimeType,isCreated,beneficiaryValidationId,createdDate,vopResult);
@override
String toString() {
return 'BeneficiaryValidationEntity(isCreated: $isCreated, beneficiaryValidationId: $beneficiaryValidationId, createdDate: $createdDate, vopResult: $vopResult)';
}
}
/// @nodoc
abstract mixin class _$BeneficiaryValidationEntityCopyWith<$Res> implements $BeneficiaryValidationEntityCopyWith<$Res> {
factory _$BeneficiaryValidationEntityCopyWith(_BeneficiaryValidationEntity value, $Res Function(_BeneficiaryValidationEntity) _then) = __$BeneficiaryValidationEntityCopyWithImpl;
@override @useResult
$Res call({
bool isCreated, String beneficiaryValidationId, String createdDate, String vopResult
});
}
/// @nodoc
class __$BeneficiaryValidationEntityCopyWithImpl<$Res>
implements _$BeneficiaryValidationEntityCopyWith<$Res> {
__$BeneficiaryValidationEntityCopyWithImpl(this._self, this._then);
final _BeneficiaryValidationEntity _self;
final $Res Function(_BeneficiaryValidationEntity) _then;
/// Create a copy of BeneficiaryValidationEntity
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? beneficiaryValidationId = null,Object? createdDate = null,Object? vopResult = null,}) {
return _then(_BeneficiaryValidationEntity(
isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable
as bool,beneficiaryValidationId: null == beneficiaryValidationId ? _self.beneficiaryValidationId : beneficiaryValidationId // ignore: cast_nullable_to_non_nullable
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
as String,vopResult: null == vopResult ? _self.vopResult : vopResult // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View File

@@ -3,6 +3,7 @@ import '../entities/mcc_group_entity.dart';
import '../entities/payment_profile_entity.dart';
import '../entities/payout_beneficiary_entity.dart';
import '../entities/sca_wallet_entity.dart';
import '../entities/beneficiary_validation_entity.dart';
import '../entities/transaction_beneficiary_entity.dart';
import '../entities/wallet_balance_entity.dart';
import '../entities/wallet_card_entity.dart';
@@ -47,7 +48,7 @@ abstract class TreezorRepository {
required String scaProof,
});
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
Future<BeneficiaryValidationEntity> validateTransactionBeneficiary({required int beneficiaryId});
Future<void> walletTransfer({
required int beneficiaryId,