login fixes, added cookies manager to get user info through cookies in header, removed totp factor auth, added two fa request for mail in default
This commit is contained in:
@@ -1,28 +1,45 @@
|
||||
import 'package:auth/src/core/data/models/get_me_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/user_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/sign_up_request_model.dart';
|
||||
import 'package:auth/src/core/data/models/sign_up_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/login_response_model.dart';
|
||||
|
||||
abstract class AuthRemoteDatasource {
|
||||
Future<MeUserModel> getMe();
|
||||
Future<UserModel> getUserInfo();
|
||||
|
||||
Future<void> requestPhoneCode({required String phone});
|
||||
|
||||
Future<void> verifyPhoneCode({required String phone, required String code});
|
||||
|
||||
Future<String> login({required String email, required String password});
|
||||
Future<LoginResponseModel> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
});
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
});
|
||||
|
||||
// Future<String> totpLogin({required String token, required String code});
|
||||
|
||||
Future<void> twoFALogin({required String token, required String code});
|
||||
Future<SignUpResponseModel> signUp({required SignUpRequestModel request});
|
||||
|
||||
Future<TwoFASecretResponseModel> generateTwoFASignUp({required String token});
|
||||
Future<void> verifyTwoFACodeSignUp({
|
||||
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
});
|
||||
|
||||
Future<String> requestPasswordReset({required String email});
|
||||
|
||||
Future<void> recoverPassword({required newPassword, required token});
|
||||
|
||||
Future<String> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:auth/src/core/data/models/get_me_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/user_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/sign_up_request_model.dart';
|
||||
import 'package:auth/src/core/data/models/sign_up_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:auth/src/core/data/models/login_response_model.dart';
|
||||
|
||||
import 'auth_remote_datasource.dart';
|
||||
|
||||
@@ -15,9 +15,8 @@ class AuthRemoteDatasourceImpl implements AuthRemoteDatasource {
|
||||
AuthRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<MeUserModel> getMe() async {
|
||||
Future<UserModel> getUserInfo() async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>('/auth/me');
|
||||
|
||||
@@ -26,7 +25,7 @@ class AuthRemoteDatasourceImpl implements AuthRemoteDatasource {
|
||||
throw Exception('Empty response from /auth/me');
|
||||
}
|
||||
|
||||
final parsed = GetMeResponseModel.fromJson(data);
|
||||
final parsed = UserResponseModel.fromJson(data);
|
||||
return parsed.item;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in /auth/me');
|
||||
@@ -64,7 +63,7 @@ class AuthRemoteDatasourceImpl implements AuthRemoteDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> login({
|
||||
Future<LoginResponseModel> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) async {
|
||||
@@ -73,8 +72,15 @@ class AuthRemoteDatasourceImpl implements AuthRemoteDatasource {
|
||||
'/auth/login',
|
||||
body: <String, dynamic>{'email': email, 'password': password},
|
||||
);
|
||||
final token = response.data!['token'];
|
||||
return token;
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/login');
|
||||
}
|
||||
|
||||
final parsed = LoginResponseModel.fromJson(data);
|
||||
|
||||
return parsed;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
@@ -84,31 +90,67 @@ class AuthRemoteDatasourceImpl implements AuthRemoteDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> twoFALogin({
|
||||
Future<void> twoFARequestCode({
|
||||
//this gonna send a request to the backend to send email code to the user for default
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.post<String>(
|
||||
'/auth/totp/login',
|
||||
await _repository.post<void>(
|
||||
'/auth/2fa/request-code',
|
||||
body: <String, dynamic>{'token': token, 'methodType': methodType},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFARequestCode');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.post<void>(
|
||||
'/auth/twofa/login',
|
||||
body: <String, dynamic>{
|
||||
'token': token,
|
||||
'code': code,
|
||||
'rememberMe': true,
|
||||
'methodType': methodType,
|
||||
},
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /auth/totp/login');
|
||||
}
|
||||
|
||||
return data;
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFALogin');
|
||||
throw _mapDioError(error, defaultMessage: 'Error in twoFASendCode');
|
||||
}
|
||||
}
|
||||
|
||||
// @override
|
||||
// Future<String> totpLogin({
|
||||
// required String token,
|
||||
// required String code,
|
||||
// }) async {
|
||||
// try {
|
||||
// final response = await _repository.post<String>(
|
||||
// '/auth/totp/login',
|
||||
// body: <String, dynamic>{
|
||||
// 'token': token,
|
||||
// 'code': code,
|
||||
// 'rememberMe': true,
|
||||
// },
|
||||
// );
|
||||
|
||||
// final data = response.data;
|
||||
// if (data == null || data.isEmpty) {
|
||||
// throw Exception('Empty response from /auth/totp/login');
|
||||
// }
|
||||
|
||||
// return data;
|
||||
// } on DioException catch (error) {
|
||||
// throw _mapDioError(error, defaultMessage: 'Error in totpLogin');
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Future<SignUpResponseModel> signUp({
|
||||
required SignUpRequestModel request,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:auth/src/core/data/models/user_response_model.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/user_entity.dart';
|
||||
|
||||
extension UserModelMapper on UserModel {
|
||||
UserEntity toEntity() {
|
||||
return UserEntity(
|
||||
id: id,
|
||||
delegationId: delegationId,
|
||||
email: email,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
status: status,
|
||||
role: role,
|
||||
lastLogin: lastLogin,
|
||||
currentLogin: currentLogin,
|
||||
language: language,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
hasApiKey: hasApiKey,
|
||||
phone: phone,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'get_me_response_model.freezed.dart';
|
||||
part 'get_me_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetMeResponseModel with _$GetMeResponseModel {
|
||||
const factory GetMeResponseModel({required MeUserModel item}) =
|
||||
_GetMeResponseModel;
|
||||
|
||||
factory GetMeResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetMeResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class MeUserModel with _$MeUserModel {
|
||||
const factory MeUserModel({
|
||||
required String id,
|
||||
required String delegationId,
|
||||
required String email,
|
||||
required int createdAt,
|
||||
required int updatedAt,
|
||||
required String status,
|
||||
required String role,
|
||||
required int lastLogin,
|
||||
required int currentLogin,
|
||||
required String language,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required bool hasApiKey,
|
||||
required String phone,
|
||||
}) = _MeUserModel;
|
||||
|
||||
factory MeUserModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$MeUserModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'login_response_model.freezed.dart';
|
||||
part 'login_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LoginResponseModel with _$LoginResponseModel {
|
||||
const factory LoginResponseModel({
|
||||
required String token,
|
||||
@Default(<AvailableMethodModel>[])
|
||||
List<AvailableMethodModel> availableMethods,
|
||||
}) = _LoginResponseModel;
|
||||
|
||||
factory LoginResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$LoginResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class AvailableMethodModel with _$AvailableMethodModel {
|
||||
const factory AvailableMethodModel({
|
||||
required String id,
|
||||
required String userId,
|
||||
required String methodType,
|
||||
required String status,
|
||||
required bool isDefault,
|
||||
required int createdAt,
|
||||
}) = _AvailableMethodModel;
|
||||
|
||||
factory AvailableMethodModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$AvailableMethodModelFromJson(json);
|
||||
}
|
||||
|
||||
extension LoginResponseModelMapper on LoginResponseModel {
|
||||
LoginResponseEntity toEntity() {
|
||||
return LoginResponseEntity(
|
||||
token: token,
|
||||
availableMethods: availableMethods
|
||||
.map(
|
||||
(m) => AvailableMethodEntity(
|
||||
id: m.id,
|
||||
userId: m.userId,
|
||||
methodType: m.methodType,
|
||||
status: m.status,
|
||||
isDefault: m.isDefault,
|
||||
createdAt: m.createdAt,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
// 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 'login_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LoginResponseModel {
|
||||
|
||||
String get token; List<AvailableMethodModel> get availableMethods;
|
||||
/// Create a copy of LoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LoginResponseModelCopyWith<LoginResponseModel> get copyWith => _$LoginResponseModelCopyWithImpl<LoginResponseModel>(this as LoginResponseModel, _$identity);
|
||||
|
||||
/// Serializes this LoginResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginResponseModel&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoginResponseModel(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LoginResponseModelCopyWith<$Res> {
|
||||
factory $LoginResponseModelCopyWith(LoginResponseModel value, $Res Function(LoginResponseModel) _then) = _$LoginResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String token, List<AvailableMethodModel> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LoginResponseModelCopyWithImpl<$Res>
|
||||
implements $LoginResponseModelCopyWith<$Res> {
|
||||
_$LoginResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LoginResponseModel _self;
|
||||
final $Res Function(LoginResponseModel) _then;
|
||||
|
||||
/// Create a copy of LoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self.availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<AvailableMethodModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LoginResponseModel].
|
||||
extension LoginResponseModelPatterns on LoginResponseModel {
|
||||
/// 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( _LoginResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseModel() 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( _LoginResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseModel():
|
||||
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( _LoginResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseModel() 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 token, List<AvailableMethodModel> availableMethods)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseModel() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<AvailableMethodModel> availableMethods) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseModel():
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<AvailableMethodModel> availableMethods)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseModel() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _LoginResponseModel implements LoginResponseModel {
|
||||
const _LoginResponseModel({required this.token, final List<AvailableMethodModel> availableMethods = const <AvailableMethodModel>[]}): _availableMethods = availableMethods;
|
||||
factory _LoginResponseModel.fromJson(Map<String, dynamic> json) => _$LoginResponseModelFromJson(json);
|
||||
|
||||
@override final String token;
|
||||
final List<AvailableMethodModel> _availableMethods;
|
||||
@override@JsonKey() List<AvailableMethodModel> get availableMethods {
|
||||
if (_availableMethods is EqualUnmodifiableListView) return _availableMethods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_availableMethods);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of LoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LoginResponseModelCopyWith<_LoginResponseModel> get copyWith => __$LoginResponseModelCopyWithImpl<_LoginResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$LoginResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginResponseModel&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(_availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoginResponseModel(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LoginResponseModelCopyWith<$Res> implements $LoginResponseModelCopyWith<$Res> {
|
||||
factory _$LoginResponseModelCopyWith(_LoginResponseModel value, $Res Function(_LoginResponseModel) _then) = __$LoginResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String token, List<AvailableMethodModel> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LoginResponseModelCopyWithImpl<$Res>
|
||||
implements _$LoginResponseModelCopyWith<$Res> {
|
||||
__$LoginResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LoginResponseModel _self;
|
||||
final $Res Function(_LoginResponseModel) _then;
|
||||
|
||||
/// Create a copy of LoginResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_LoginResponseModel(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self._availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<AvailableMethodModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AvailableMethodModel {
|
||||
|
||||
String get id; String get userId; String get methodType; String get status; bool get isDefault; int get createdAt;
|
||||
/// Create a copy of AvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$AvailableMethodModelCopyWith<AvailableMethodModel> get copyWith => _$AvailableMethodModelCopyWithImpl<AvailableMethodModel>(this as AvailableMethodModel, _$identity);
|
||||
|
||||
/// Serializes this AvailableMethodModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is AvailableMethodModel&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AvailableMethodModel(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $AvailableMethodModelCopyWith<$Res> {
|
||||
factory $AvailableMethodModelCopyWith(AvailableMethodModel value, $Res Function(AvailableMethodModel) _then) = _$AvailableMethodModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$AvailableMethodModelCopyWithImpl<$Res>
|
||||
implements $AvailableMethodModelCopyWith<$Res> {
|
||||
_$AvailableMethodModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final AvailableMethodModel _self;
|
||||
final $Res Function(AvailableMethodModel) _then;
|
||||
|
||||
/// Create a copy of AvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [AvailableMethodModel].
|
||||
extension AvailableMethodModelPatterns on AvailableMethodModel {
|
||||
/// 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( _AvailableMethodModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodModel() 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( _AvailableMethodModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodModel():
|
||||
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( _AvailableMethodModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodModel() 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 id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodModel() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);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 id, String userId, String methodType, String status, bool isDefault, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodModel():
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);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 id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodModel() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _AvailableMethodModel implements AvailableMethodModel {
|
||||
const _AvailableMethodModel({required this.id, required this.userId, required this.methodType, required this.status, required this.isDefault, required this.createdAt});
|
||||
factory _AvailableMethodModel.fromJson(Map<String, dynamic> json) => _$AvailableMethodModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String userId;
|
||||
@override final String methodType;
|
||||
@override final String status;
|
||||
@override final bool isDefault;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of AvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AvailableMethodModelCopyWith<_AvailableMethodModel> get copyWith => __$AvailableMethodModelCopyWithImpl<_AvailableMethodModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$AvailableMethodModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AvailableMethodModel&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AvailableMethodModel(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AvailableMethodModelCopyWith<$Res> implements $AvailableMethodModelCopyWith<$Res> {
|
||||
factory _$AvailableMethodModelCopyWith(_AvailableMethodModel value, $Res Function(_AvailableMethodModel) _then) = __$AvailableMethodModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$AvailableMethodModelCopyWithImpl<$Res>
|
||||
implements _$AvailableMethodModelCopyWith<$Res> {
|
||||
__$AvailableMethodModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AvailableMethodModel _self;
|
||||
final $Res Function(_AvailableMethodModel) _then;
|
||||
|
||||
/// Create a copy of AvailableMethodModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_AvailableMethodModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,47 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'login_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LoginResponseModel _$LoginResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_LoginResponseModel(
|
||||
token: json['token'] as String,
|
||||
availableMethods:
|
||||
(json['availableMethods'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) => AvailableMethodModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList() ??
|
||||
const <AvailableMethodModel>[],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LoginResponseModelToJson(_LoginResponseModel instance) =>
|
||||
<String, dynamic>{
|
||||
'token': instance.token,
|
||||
'availableMethods': instance.availableMethods,
|
||||
};
|
||||
|
||||
_AvailableMethodModel _$AvailableMethodModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _AvailableMethodModel(
|
||||
id: json['id'] as String,
|
||||
userId: json['userId'] as String,
|
||||
methodType: json['methodType'] as String,
|
||||
status: json['status'] as String,
|
||||
isDefault: json['isDefault'] as bool,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AvailableMethodModelToJson(
|
||||
_AvailableMethodModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'userId': instance.userId,
|
||||
'methodType': instance.methodType,
|
||||
'status': instance.status,
|
||||
'isDefault': instance.isDefault,
|
||||
'createdAt': instance.createdAt,
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'user_response_model.freezed.dart';
|
||||
part 'user_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UserResponseModel with _$UserResponseModel {
|
||||
const factory UserResponseModel({required UserModel item}) =
|
||||
_UserResponseModel;
|
||||
|
||||
factory UserResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class UserModel with _$UserModel {
|
||||
const factory UserModel({
|
||||
required String id,
|
||||
String? delegationId,
|
||||
required String email,
|
||||
required int createdAt,
|
||||
int? updatedAt,
|
||||
required String status,
|
||||
required String role,
|
||||
required int lastLogin,
|
||||
required int currentLogin,
|
||||
required String language,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required bool hasApiKey,
|
||||
required String phone,
|
||||
}) = _UserModel;
|
||||
|
||||
factory UserModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserModelFromJson(json);
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
// 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 'get_me_response_model.dart';
|
||||
part of 'user_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
@@ -13,22 +13,22 @@ part of 'get_me_response_model.dart';
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetMeResponseModel {
|
||||
mixin _$UserResponseModel {
|
||||
|
||||
MeUserModel get item;
|
||||
/// Create a copy of GetMeResponseModel
|
||||
UserModel get item;
|
||||
/// Create a copy of UserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetMeResponseModelCopyWith<GetMeResponseModel> get copyWith => _$GetMeResponseModelCopyWithImpl<GetMeResponseModel>(this as GetMeResponseModel, _$identity);
|
||||
$UserResponseModelCopyWith<UserResponseModel> get copyWith => _$UserResponseModelCopyWithImpl<UserResponseModel>(this as UserResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetMeResponseModel to a JSON map.
|
||||
/// Serializes this UserResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetMeResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UserResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -37,55 +37,55 @@ int get hashCode => Object.hash(runtimeType,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetMeResponseModel(item: $item)';
|
||||
return 'UserResponseModel(item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetMeResponseModelCopyWith<$Res> {
|
||||
factory $GetMeResponseModelCopyWith(GetMeResponseModel value, $Res Function(GetMeResponseModel) _then) = _$GetMeResponseModelCopyWithImpl;
|
||||
abstract mixin class $UserResponseModelCopyWith<$Res> {
|
||||
factory $UserResponseModelCopyWith(UserResponseModel value, $Res Function(UserResponseModel) _then) = _$UserResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
MeUserModel item
|
||||
UserModel item
|
||||
});
|
||||
|
||||
|
||||
$MeUserModelCopyWith<$Res> get item;
|
||||
$UserModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetMeResponseModelCopyWithImpl<$Res>
|
||||
implements $GetMeResponseModelCopyWith<$Res> {
|
||||
_$GetMeResponseModelCopyWithImpl(this._self, this._then);
|
||||
class _$UserResponseModelCopyWithImpl<$Res>
|
||||
implements $UserResponseModelCopyWith<$Res> {
|
||||
_$UserResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetMeResponseModel _self;
|
||||
final $Res Function(GetMeResponseModel) _then;
|
||||
final UserResponseModel _self;
|
||||
final $Res Function(UserResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetMeResponseModel
|
||||
/// Create a copy of UserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as MeUserModel,
|
||||
as UserModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of GetMeResponseModel
|
||||
/// Create a copy of UserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$MeUserModelCopyWith<$Res> get item {
|
||||
$UserModelCopyWith<$Res> get item {
|
||||
|
||||
return $MeUserModelCopyWith<$Res>(_self.item, (value) {
|
||||
return $UserModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetMeResponseModel].
|
||||
extension GetMeResponseModelPatterns on GetMeResponseModel {
|
||||
/// Adds pattern-matching-related methods to [UserResponseModel].
|
||||
extension UserResponseModelPatterns on UserResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
@@ -98,10 +98,10 @@ extension GetMeResponseModelPatterns on GetMeResponseModel {
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetMeResponseModel value)? $default,{required TResult orElse(),}){
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UserResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetMeResponseModel() when $default != null:
|
||||
case _UserResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
@@ -120,10 +120,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetMeResponseModel value) $default,){
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UserResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetMeResponseModel():
|
||||
case _UserResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
@@ -141,10 +141,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetMeResponseModel value)? $default,){
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UserResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetMeResponseModel() when $default != null:
|
||||
case _UserResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
@@ -162,9 +162,9 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( MeUserModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( UserModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetMeResponseModel() when $default != null:
|
||||
case _UserResponseModel() when $default != null:
|
||||
return $default(_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
@@ -183,9 +183,9 @@ return $default(_that.item);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( MeUserModel item) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( UserModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetMeResponseModel():
|
||||
case _UserResponseModel():
|
||||
return $default(_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
@@ -203,9 +203,9 @@ return $default(_that.item);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( MeUserModel item)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( UserModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetMeResponseModel() when $default != null:
|
||||
case _UserResponseModel() when $default != null:
|
||||
return $default(_that.item);case _:
|
||||
return null;
|
||||
|
||||
@@ -217,26 +217,26 @@ return $default(_that.item);case _:
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetMeResponseModel implements GetMeResponseModel {
|
||||
const _GetMeResponseModel({required this.item});
|
||||
factory _GetMeResponseModel.fromJson(Map<String, dynamic> json) => _$GetMeResponseModelFromJson(json);
|
||||
class _UserResponseModel implements UserResponseModel {
|
||||
const _UserResponseModel({required this.item});
|
||||
factory _UserResponseModel.fromJson(Map<String, dynamic> json) => _$UserResponseModelFromJson(json);
|
||||
|
||||
@override final MeUserModel item;
|
||||
@override final UserModel item;
|
||||
|
||||
/// Create a copy of GetMeResponseModel
|
||||
/// Create a copy of UserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetMeResponseModelCopyWith<_GetMeResponseModel> get copyWith => __$GetMeResponseModelCopyWithImpl<_GetMeResponseModel>(this, _$identity);
|
||||
_$UserResponseModelCopyWith<_UserResponseModel> get copyWith => __$UserResponseModelCopyWithImpl<_UserResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetMeResponseModelToJson(this, );
|
||||
return _$UserResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetMeResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UserResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -245,48 +245,48 @@ int get hashCode => Object.hash(runtimeType,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetMeResponseModel(item: $item)';
|
||||
return 'UserResponseModel(item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetMeResponseModelCopyWith<$Res> implements $GetMeResponseModelCopyWith<$Res> {
|
||||
factory _$GetMeResponseModelCopyWith(_GetMeResponseModel value, $Res Function(_GetMeResponseModel) _then) = __$GetMeResponseModelCopyWithImpl;
|
||||
abstract mixin class _$UserResponseModelCopyWith<$Res> implements $UserResponseModelCopyWith<$Res> {
|
||||
factory _$UserResponseModelCopyWith(_UserResponseModel value, $Res Function(_UserResponseModel) _then) = __$UserResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
MeUserModel item
|
||||
UserModel item
|
||||
});
|
||||
|
||||
|
||||
@override $MeUserModelCopyWith<$Res> get item;
|
||||
@override $UserModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetMeResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetMeResponseModelCopyWith<$Res> {
|
||||
__$GetMeResponseModelCopyWithImpl(this._self, this._then);
|
||||
class __$UserResponseModelCopyWithImpl<$Res>
|
||||
implements _$UserResponseModelCopyWith<$Res> {
|
||||
__$UserResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetMeResponseModel _self;
|
||||
final $Res Function(_GetMeResponseModel) _then;
|
||||
final _UserResponseModel _self;
|
||||
final $Res Function(_UserResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetMeResponseModel
|
||||
/// Create a copy of UserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? item = null,}) {
|
||||
return _then(_GetMeResponseModel(
|
||||
return _then(_UserResponseModel(
|
||||
item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as MeUserModel,
|
||||
as UserModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of GetMeResponseModel
|
||||
/// Create a copy of UserResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$MeUserModelCopyWith<$Res> get item {
|
||||
$UserModelCopyWith<$Res> get item {
|
||||
|
||||
return $MeUserModelCopyWith<$Res>(_self.item, (value) {
|
||||
return $UserModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
@@ -294,22 +294,22 @@ $MeUserModelCopyWith<$Res> get item {
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$MeUserModel {
|
||||
mixin _$UserModel {
|
||||
|
||||
String get id; String get delegationId; String get email; int get createdAt; int get updatedAt; String get status; String get role; int get lastLogin; int get currentLogin; String get language; String get firstName; String get lastName; bool get hasApiKey; String get phone;
|
||||
/// Create a copy of MeUserModel
|
||||
String get id; String? get delegationId; String get email; int get createdAt; int? get updatedAt; String get status; String get role; int get lastLogin; int get currentLogin; String get language; String get firstName; String get lastName; bool get hasApiKey; String get phone;
|
||||
/// Create a copy of UserModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$MeUserModelCopyWith<MeUserModel> get copyWith => _$MeUserModelCopyWithImpl<MeUserModel>(this as MeUserModel, _$identity);
|
||||
$UserModelCopyWith<UserModel> get copyWith => _$UserModelCopyWithImpl<UserModel>(this as UserModel, _$identity);
|
||||
|
||||
/// Serializes this MeUserModel to a JSON map.
|
||||
/// Serializes this UserModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is MeUserModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UserModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -318,18 +318,18 @@ int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,upda
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MeUserModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
return 'UserModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $MeUserModelCopyWith<$Res> {
|
||||
factory $MeUserModelCopyWith(MeUserModel value, $Res Function(MeUserModel) _then) = _$MeUserModelCopyWithImpl;
|
||||
abstract mixin class $UserModelCopyWith<$Res> {
|
||||
factory $UserModelCopyWith(UserModel value, $Res Function(UserModel) _then) = _$UserModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String delegationId, String email, int createdAt, int updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
|
||||
String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
|
||||
});
|
||||
|
||||
|
||||
@@ -337,23 +337,23 @@ $Res call({
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$MeUserModelCopyWithImpl<$Res>
|
||||
implements $MeUserModelCopyWith<$Res> {
|
||||
_$MeUserModelCopyWithImpl(this._self, this._then);
|
||||
class _$UserModelCopyWithImpl<$Res>
|
||||
implements $UserModelCopyWith<$Res> {
|
||||
_$UserModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final MeUserModel _self;
|
||||
final $Res Function(MeUserModel) _then;
|
||||
final UserModel _self;
|
||||
final $Res Function(UserModel) _then;
|
||||
|
||||
/// Create a copy of MeUserModel
|
||||
/// Create a copy of UserModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = null,Object? email = null,Object? createdAt = null,Object? updatedAt = null,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = null,Object? createdAt = null,Object? updatedAt = freezed,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: null == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastLogin: null == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as int,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
@@ -369,8 +369,8 @@ as String,
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [MeUserModel].
|
||||
extension MeUserModelPatterns on MeUserModel {
|
||||
/// Adds pattern-matching-related methods to [UserModel].
|
||||
extension UserModelPatterns on UserModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
@@ -383,10 +383,10 @@ extension MeUserModelPatterns on MeUserModel {
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _MeUserModel value)? $default,{required TResult orElse(),}){
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UserModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _MeUserModel() when $default != null:
|
||||
case _UserModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
@@ -405,10 +405,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _MeUserModel value) $default,){
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UserModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _MeUserModel():
|
||||
case _UserModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
@@ -426,10 +426,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _MeUserModel value)? $default,){
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UserModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _MeUserModel() when $default != null:
|
||||
case _UserModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
@@ -447,9 +447,9 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String delegationId, String email, int createdAt, int updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _MeUserModel() when $default != null:
|
||||
case _UserModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return orElse();
|
||||
|
||||
@@ -468,9 +468,9 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String delegationId, String email, int createdAt, int updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _MeUserModel():
|
||||
case _UserModel():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
@@ -488,9 +488,9 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String delegationId, String email, int createdAt, int updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _MeUserModel() when $default != null:
|
||||
case _UserModel() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
@@ -502,15 +502,15 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _MeUserModel implements MeUserModel {
|
||||
const _MeUserModel({required this.id, required this.delegationId, required this.email, required this.createdAt, required this.updatedAt, required this.status, required this.role, required this.lastLogin, required this.currentLogin, required this.language, required this.firstName, required this.lastName, required this.hasApiKey, required this.phone});
|
||||
factory _MeUserModel.fromJson(Map<String, dynamic> json) => _$MeUserModelFromJson(json);
|
||||
class _UserModel implements UserModel {
|
||||
const _UserModel({required this.id, this.delegationId, required this.email, required this.createdAt, this.updatedAt, required this.status, required this.role, required this.lastLogin, required this.currentLogin, required this.language, required this.firstName, required this.lastName, required this.hasApiKey, required this.phone});
|
||||
factory _UserModel.fromJson(Map<String, dynamic> json) => _$UserModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String delegationId;
|
||||
@override final String? delegationId;
|
||||
@override final String email;
|
||||
@override final int createdAt;
|
||||
@override final int updatedAt;
|
||||
@override final int? updatedAt;
|
||||
@override final String status;
|
||||
@override final String role;
|
||||
@override final int lastLogin;
|
||||
@@ -521,20 +521,20 @@ class _MeUserModel implements MeUserModel {
|
||||
@override final bool hasApiKey;
|
||||
@override final String phone;
|
||||
|
||||
/// Create a copy of MeUserModel
|
||||
/// Create a copy of UserModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$MeUserModelCopyWith<_MeUserModel> get copyWith => __$MeUserModelCopyWithImpl<_MeUserModel>(this, _$identity);
|
||||
_$UserModelCopyWith<_UserModel> get copyWith => __$UserModelCopyWithImpl<_UserModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$MeUserModelToJson(this, );
|
||||
return _$UserModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _MeUserModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UserModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -543,18 +543,18 @@ int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,upda
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MeUserModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
return 'UserModel(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$MeUserModelCopyWith<$Res> implements $MeUserModelCopyWith<$Res> {
|
||||
factory _$MeUserModelCopyWith(_MeUserModel value, $Res Function(_MeUserModel) _then) = __$MeUserModelCopyWithImpl;
|
||||
abstract mixin class _$UserModelCopyWith<$Res> implements $UserModelCopyWith<$Res> {
|
||||
factory _$UserModelCopyWith(_UserModel value, $Res Function(_UserModel) _then) = __$UserModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String delegationId, String email, int createdAt, int updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
|
||||
String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
|
||||
});
|
||||
|
||||
|
||||
@@ -562,23 +562,23 @@ $Res call({
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$MeUserModelCopyWithImpl<$Res>
|
||||
implements _$MeUserModelCopyWith<$Res> {
|
||||
__$MeUserModelCopyWithImpl(this._self, this._then);
|
||||
class __$UserModelCopyWithImpl<$Res>
|
||||
implements _$UserModelCopyWith<$Res> {
|
||||
__$UserModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _MeUserModel _self;
|
||||
final $Res Function(_MeUserModel) _then;
|
||||
final _UserModel _self;
|
||||
final $Res Function(_UserModel) _then;
|
||||
|
||||
/// Create a copy of MeUserModel
|
||||
/// Create a copy of UserModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = null,Object? email = null,Object? createdAt = null,Object? updatedAt = null,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_MeUserModel(
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = null,Object? createdAt = null,Object? updatedAt = freezed,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_UserModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: null == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastLogin: null == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as int,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1,25 +1,25 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_me_response_model.dart';
|
||||
part of 'user_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetMeResponseModel _$GetMeResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_GetMeResponseModel(
|
||||
item: MeUserModel.fromJson(json['item'] as Map<String, dynamic>),
|
||||
_UserResponseModel _$UserResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_UserResponseModel(
|
||||
item: UserModel.fromJson(json['item'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetMeResponseModelToJson(_GetMeResponseModel instance) =>
|
||||
Map<String, dynamic> _$UserResponseModelToJson(_UserResponseModel instance) =>
|
||||
<String, dynamic>{'item': instance.item};
|
||||
|
||||
_MeUserModel _$MeUserModelFromJson(Map<String, dynamic> json) => _MeUserModel(
|
||||
_UserModel _$UserModelFromJson(Map<String, dynamic> json) => _UserModel(
|
||||
id: json['id'] as String,
|
||||
delegationId: json['delegationId'] as String,
|
||||
delegationId: json['delegationId'] as String?,
|
||||
email: json['email'] as String,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
updatedAt: (json['updatedAt'] as num).toInt(),
|
||||
updatedAt: (json['updatedAt'] as num?)?.toInt(),
|
||||
status: json['status'] as String,
|
||||
role: json['role'] as String,
|
||||
lastLogin: (json['lastLogin'] as num).toInt(),
|
||||
@@ -31,7 +31,7 @@ _MeUserModel _$MeUserModelFromJson(Map<String, dynamic> json) => _MeUserModel(
|
||||
phone: json['phone'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MeUserModelToJson(_MeUserModel instance) =>
|
||||
Map<String, dynamic> _$UserModelToJson(_UserModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'delegationId': instance.delegationId,
|
||||
@@ -1,11 +1,14 @@
|
||||
import 'package:auth/src/core/data/datasource/auth_remote_datasource.dart';
|
||||
import 'package:auth/src/core/data/mappers/user_model_mapper.dart';
|
||||
import 'package:auth/src/core/data/models/sign_up_request_model.dart';
|
||||
import 'package:auth/src/core/data/models/sign_up_response_model.dart';
|
||||
import 'package:auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/user_entity.dart';
|
||||
import 'package:auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
|
||||
import 'package:auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
|
||||
import 'package:auth/src/features/sign_up/domain/entities/two_fa_secret_entity.dart';
|
||||
import 'package:auth/src/core/data/models/login_response_model.dart';
|
||||
|
||||
class AuthRepositoryImpl implements AuthRepository {
|
||||
const AuthRepositoryImpl(this._remote);
|
||||
@@ -23,22 +26,53 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> login({required String email, required String password}) {
|
||||
return _remote.login(email: email, password: password);
|
||||
Future<LoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) async {
|
||||
final responseModel = await _remote.login(email: email, password: password);
|
||||
|
||||
return LoginResponseModelMapper(responseModel).toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFactor({required String token, required String code}) {
|
||||
return _remote.twoFALogin(token: token, code: code);
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _remote.twoFARequestCode(token: token, methodType: methodType);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _remote.twoFASendCode(
|
||||
token: token,
|
||||
code: code,
|
||||
methodType: methodType,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserEntity> getUserInfo() async {
|
||||
final model = await _remote.getUserInfo();
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
// @override
|
||||
// Future<String> totpLogin({required String token, required String code}) {
|
||||
// return _remote.totpLogin(token: token, code: code);
|
||||
// }
|
||||
|
||||
@override
|
||||
Future<SignUpResponseEntity> signUp({
|
||||
required SignUpRequestEntity request,
|
||||
}) async {
|
||||
final model = request.toModel();
|
||||
final responseModel = await _remote.signUp(request: model);
|
||||
|
||||
return responseModel.toEntity();
|
||||
}
|
||||
|
||||
@@ -50,7 +84,7 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> verifyTwoFACodeSignUp({
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
}) {
|
||||
@@ -99,3 +133,23 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension LoginResponseModelMapper on LoginResponseModel {
|
||||
LoginResponseEntity toEntity() {
|
||||
return LoginResponseEntity(
|
||||
token: token,
|
||||
availableMethods: availableMethods
|
||||
.map(
|
||||
(m) => AvailableMethodEntity(
|
||||
id: m.id,
|
||||
userId: m.userId,
|
||||
methodType: m.methodType,
|
||||
status: m.status,
|
||||
isDefault: m.isDefault,
|
||||
createdAt: m.createdAt,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:auth/src/core/data/models/two_fa_secret_response_model.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/user_entity.dart';
|
||||
import 'package:auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart';
|
||||
import 'package:auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart';
|
||||
|
||||
@@ -7,8 +9,31 @@ abstract class AuthRepository {
|
||||
|
||||
Future<void> verifyPhoneCode({required String phone, required String code});
|
||||
|
||||
Future<String> login({required String email, required String password});
|
||||
Future<void> twoFactor({required String token, required String code});
|
||||
Future<LoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
});
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
});
|
||||
Future<UserEntity> getUserInfo();
|
||||
|
||||
// Future<String> totpLogin({required String token, required String code});
|
||||
|
||||
Future<SignUpResponseEntity> signUp({required SignUpRequestEntity request});
|
||||
|
||||
Future<TwoFASecretResponseModel> generateTwoFASignUp({required String token});
|
||||
|
||||
Future<String> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
});
|
||||
|
||||
Future<String> requestPasswordReset({required String email});
|
||||
|
||||
@@ -17,13 +42,6 @@ abstract class AuthRepository {
|
||||
required String token,
|
||||
});
|
||||
|
||||
Future<SignUpResponseEntity> signUp({required SignUpRequestEntity request});
|
||||
|
||||
Future<TwoFASecretResponseModel> generateTwoFASignUp({required String token});
|
||||
Future<void> verifyTwoFACodeSignUp({
|
||||
required String token,
|
||||
required String code,
|
||||
});
|
||||
Future<String> createChildProfile({
|
||||
required String id,
|
||||
required String parentId,
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'login_response_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LoginResponseEntity with _$LoginResponseEntity {
|
||||
const factory LoginResponseEntity({
|
||||
required String token,
|
||||
@Default(<AvailableMethodEntity>[])
|
||||
List<AvailableMethodEntity> availableMethods,
|
||||
}) = _LoginResponseEntity;
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class AvailableMethodEntity with _$AvailableMethodEntity {
|
||||
const factory AvailableMethodEntity({
|
||||
required String id,
|
||||
required String userId,
|
||||
required String methodType,
|
||||
required String status,
|
||||
required bool isDefault,
|
||||
required int createdAt,
|
||||
}) = _AvailableMethodEntity;
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
// 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 'login_response_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LoginResponseEntity {
|
||||
|
||||
String get token; List<AvailableMethodEntity> get availableMethods;
|
||||
/// Create a copy of LoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$LoginResponseEntityCopyWith<LoginResponseEntity> get copyWith => _$LoginResponseEntityCopyWithImpl<LoginResponseEntity>(this as LoginResponseEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginResponseEntity&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoginResponseEntity(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $LoginResponseEntityCopyWith<$Res> {
|
||||
factory $LoginResponseEntityCopyWith(LoginResponseEntity value, $Res Function(LoginResponseEntity) _then) = _$LoginResponseEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String token, List<AvailableMethodEntity> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$LoginResponseEntityCopyWithImpl<$Res>
|
||||
implements $LoginResponseEntityCopyWith<$Res> {
|
||||
_$LoginResponseEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final LoginResponseEntity _self;
|
||||
final $Res Function(LoginResponseEntity) _then;
|
||||
|
||||
/// Create a copy of LoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self.availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<AvailableMethodEntity>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [LoginResponseEntity].
|
||||
extension LoginResponseEntityPatterns on LoginResponseEntity {
|
||||
/// 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( _LoginResponseEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseEntity() 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( _LoginResponseEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseEntity():
|
||||
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( _LoginResponseEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseEntity() 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 token, List<AvailableMethodEntity> availableMethods)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseEntity() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<AvailableMethodEntity> availableMethods) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseEntity():
|
||||
return $default(_that.token,_that.availableMethods);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 token, List<AvailableMethodEntity> availableMethods)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginResponseEntity() when $default != null:
|
||||
return $default(_that.token,_that.availableMethods);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LoginResponseEntity implements LoginResponseEntity {
|
||||
const _LoginResponseEntity({required this.token, final List<AvailableMethodEntity> availableMethods = const <AvailableMethodEntity>[]}): _availableMethods = availableMethods;
|
||||
|
||||
|
||||
@override final String token;
|
||||
final List<AvailableMethodEntity> _availableMethods;
|
||||
@override@JsonKey() List<AvailableMethodEntity> get availableMethods {
|
||||
if (_availableMethods is EqualUnmodifiableListView) return _availableMethods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_availableMethods);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of LoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$LoginResponseEntityCopyWith<_LoginResponseEntity> get copyWith => __$LoginResponseEntityCopyWithImpl<_LoginResponseEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginResponseEntity&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,token,const DeepCollectionEquality().hash(_availableMethods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoginResponseEntity(token: $token, availableMethods: $availableMethods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$LoginResponseEntityCopyWith<$Res> implements $LoginResponseEntityCopyWith<$Res> {
|
||||
factory _$LoginResponseEntityCopyWith(_LoginResponseEntity value, $Res Function(_LoginResponseEntity) _then) = __$LoginResponseEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String token, List<AvailableMethodEntity> availableMethods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$LoginResponseEntityCopyWithImpl<$Res>
|
||||
implements _$LoginResponseEntityCopyWith<$Res> {
|
||||
__$LoginResponseEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _LoginResponseEntity _self;
|
||||
final $Res Function(_LoginResponseEntity) _then;
|
||||
|
||||
/// Create a copy of LoginResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? token = null,Object? availableMethods = null,}) {
|
||||
return _then(_LoginResponseEntity(
|
||||
token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,availableMethods: null == availableMethods ? _self._availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<AvailableMethodEntity>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AvailableMethodEntity {
|
||||
|
||||
String get id; String get userId; String get methodType; String get status; bool get isDefault; int get createdAt;
|
||||
/// Create a copy of AvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$AvailableMethodEntityCopyWith<AvailableMethodEntity> get copyWith => _$AvailableMethodEntityCopyWithImpl<AvailableMethodEntity>(this as AvailableMethodEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is AvailableMethodEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AvailableMethodEntity(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $AvailableMethodEntityCopyWith<$Res> {
|
||||
factory $AvailableMethodEntityCopyWith(AvailableMethodEntity value, $Res Function(AvailableMethodEntity) _then) = _$AvailableMethodEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$AvailableMethodEntityCopyWithImpl<$Res>
|
||||
implements $AvailableMethodEntityCopyWith<$Res> {
|
||||
_$AvailableMethodEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final AvailableMethodEntity _self;
|
||||
final $Res Function(AvailableMethodEntity) _then;
|
||||
|
||||
/// Create a copy of AvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [AvailableMethodEntity].
|
||||
extension AvailableMethodEntityPatterns on AvailableMethodEntity {
|
||||
/// 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( _AvailableMethodEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodEntity() 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( _AvailableMethodEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodEntity():
|
||||
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( _AvailableMethodEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodEntity() 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 id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodEntity() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);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 id, String userId, String methodType, String status, bool isDefault, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodEntity():
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);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 id, String userId, String methodType, String status, bool isDefault, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AvailableMethodEntity() when $default != null:
|
||||
return $default(_that.id,_that.userId,_that.methodType,_that.status,_that.isDefault,_that.createdAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _AvailableMethodEntity implements AvailableMethodEntity {
|
||||
const _AvailableMethodEntity({required this.id, required this.userId, required this.methodType, required this.status, required this.isDefault, required this.createdAt});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String userId;
|
||||
@override final String methodType;
|
||||
@override final String status;
|
||||
@override final bool isDefault;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of AvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AvailableMethodEntityCopyWith<_AvailableMethodEntity> get copyWith => __$AvailableMethodEntityCopyWithImpl<_AvailableMethodEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AvailableMethodEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.status, status) || other.status == status)&&(identical(other.isDefault, isDefault) || other.isDefault == isDefault)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,userId,methodType,status,isDefault,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AvailableMethodEntity(id: $id, userId: $userId, methodType: $methodType, status: $status, isDefault: $isDefault, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AvailableMethodEntityCopyWith<$Res> implements $AvailableMethodEntityCopyWith<$Res> {
|
||||
factory _$AvailableMethodEntityCopyWith(_AvailableMethodEntity value, $Res Function(_AvailableMethodEntity) _then) = __$AvailableMethodEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String userId, String methodType, String status, bool isDefault, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$AvailableMethodEntityCopyWithImpl<$Res>
|
||||
implements _$AvailableMethodEntityCopyWith<$Res> {
|
||||
__$AvailableMethodEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AvailableMethodEntity _self;
|
||||
final $Res Function(_AvailableMethodEntity) _then;
|
||||
|
||||
/// Create a copy of AvailableMethodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? userId = null,Object? methodType = null,Object? status = null,Object? isDefault = null,Object? createdAt = null,}) {
|
||||
return _then(_AvailableMethodEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,isDefault: null == isDefault ? _self.isDefault : isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'user_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UserEntity with _$UserEntity {
|
||||
const factory UserEntity({
|
||||
required String id,
|
||||
final String? delegationId,
|
||||
required String email,
|
||||
required int createdAt,
|
||||
final int? updatedAt,
|
||||
required String status,
|
||||
required String role,
|
||||
required int lastLogin,
|
||||
required int currentLogin,
|
||||
required String language,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required bool hasApiKey,
|
||||
required String phone,
|
||||
}) = _UserEntity;
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
// 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 'user_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$UserEntity {
|
||||
|
||||
String get id; String? get delegationId; String get email; int get createdAt; int? get updatedAt; String get status; String get role; int get lastLogin; int get currentLogin; String get language; String get firstName; String get lastName; bool get hasApiKey; String get phone;
|
||||
/// Create a copy of UserEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UserEntityCopyWith<UserEntity> get copyWith => _$UserEntityCopyWithImpl<UserEntity>(this as UserEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UserEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserEntity(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UserEntityCopyWith<$Res> {
|
||||
factory $UserEntityCopyWith(UserEntity value, $Res Function(UserEntity) _then) = _$UserEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UserEntityCopyWithImpl<$Res>
|
||||
implements $UserEntityCopyWith<$Res> {
|
||||
_$UserEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UserEntity _self;
|
||||
final $Res Function(UserEntity) _then;
|
||||
|
||||
/// Create a copy of UserEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? delegationId = freezed,Object? email = null,Object? createdAt = null,Object? updatedAt = freezed,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastLogin: null == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as int,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as int,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,hasApiKey: null == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as bool,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UserEntity].
|
||||
extension UserEntityPatterns on UserEntity {
|
||||
/// 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( _UserEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserEntity() 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( _UserEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserEntity():
|
||||
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( _UserEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UserEntity() 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 id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserEntity() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);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 id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserEntity():
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);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 id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UserEntity() when $default != null:
|
||||
return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _UserEntity implements UserEntity {
|
||||
const _UserEntity({required this.id, this.delegationId, required this.email, required this.createdAt, this.updatedAt, required this.status, required this.role, required this.lastLogin, required this.currentLogin, required this.language, required this.firstName, required this.lastName, required this.hasApiKey, required this.phone});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@override final String? delegationId;
|
||||
@override final String email;
|
||||
@override final int createdAt;
|
||||
@override final int? updatedAt;
|
||||
@override final String status;
|
||||
@override final String role;
|
||||
@override final int lastLogin;
|
||||
@override final int currentLogin;
|
||||
@override final String language;
|
||||
@override final String firstName;
|
||||
@override final String lastName;
|
||||
@override final bool hasApiKey;
|
||||
@override final String phone;
|
||||
|
||||
/// Create a copy of UserEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UserEntityCopyWith<_UserEntity> get copyWith => __$UserEntityCopyWithImpl<_UserEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UserEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserEntity(id: $id, delegationId: $delegationId, email: $email, createdAt: $createdAt, updatedAt: $updatedAt, status: $status, role: $role, lastLogin: $lastLogin, currentLogin: $currentLogin, language: $language, firstName: $firstName, lastName: $lastName, hasApiKey: $hasApiKey, phone: $phone)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UserEntityCopyWith<$Res> implements $UserEntityCopyWith<$Res> {
|
||||
factory _$UserEntityCopyWith(_UserEntity value, $Res Function(_UserEntity) _then) = __$UserEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String? delegationId, String email, int createdAt, int? updatedAt, String status, String role, int lastLogin, int currentLogin, String language, String firstName, String lastName, bool hasApiKey, String phone
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UserEntityCopyWithImpl<$Res>
|
||||
implements _$UserEntityCopyWith<$Res> {
|
||||
__$UserEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UserEntity _self;
|
||||
final $Res Function(_UserEntity) _then;
|
||||
|
||||
/// Create a copy of UserEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? delegationId = freezed,Object? email = null,Object? createdAt = null,Object? updatedAt = freezed,Object? status = null,Object? role = null,Object? lastLogin = null,Object? currentLogin = null,Object? language = null,Object? firstName = null,Object? lastName = null,Object? hasApiKey = null,Object? phone = null,}) {
|
||||
return _then(_UserEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as int?,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastLogin: null == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable
|
||||
as int,currentLogin: null == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable
|
||||
as int,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,hasApiKey: null == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable
|
||||
as bool,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:auth/src/core/data/models/get_me_response_model.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/user_entity.dart';
|
||||
|
||||
abstract class GetMeUserUseCase {
|
||||
Future<MeUserModel> getMe();
|
||||
abstract class GetUserInfoUseCase {
|
||||
Future<UserEntity> getUserInfo();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
import 'package:auth/src/core/data/models/get_me_response_model.dart';
|
||||
import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/user_entity.dart';
|
||||
import 'package:auth/src/features/login/domain/get_me_user_use_case.dart';
|
||||
|
||||
class GetMeUserUseCaseImpl implements GetMeUserUseCase {
|
||||
GetMeUserUseCaseImpl(this._repository);
|
||||
class GetUserInfoUseCaseImpl implements GetUserInfoUseCase {
|
||||
GetUserInfoUseCaseImpl(this._repository);
|
||||
|
||||
final AuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<String> login({required String email, required String password}) {
|
||||
return _repository.login(email: email, password: password);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MeUserModel> getMe() {
|
||||
// TODO: implement getMe
|
||||
throw UnimplementedError();
|
||||
Future<UserEntity> getUserInfo() {
|
||||
return _repository.getUserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import 'package:auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
|
||||
abstract class LoginUseCase {
|
||||
Future<String> login({required String email, required String password});
|
||||
Future<LoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:auth/src/features/login/domain/login_use_case.dart';
|
||||
|
||||
class LoginUseCaseImpl implements LoginUseCase {
|
||||
@@ -7,7 +8,10 @@ class LoginUseCaseImpl implements LoginUseCase {
|
||||
final AuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<String> login({required String email, required String password}) {
|
||||
Future<LoginResponseEntity> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) {
|
||||
return _repository.login(email: email, password: password);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// abstract class TotpLoginUseCase {
|
||||
// Future<void> totpLogin({required String token, required String code});
|
||||
// }
|
||||
@@ -0,0 +1,13 @@
|
||||
// import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
// import 'package:auth/src/features/login/domain/totp_login_use_case.dart';
|
||||
|
||||
// class TotpLoginUseCaseImpl implements TotpLoginUseCase {
|
||||
// TotpLoginUseCaseImpl(this._repository);
|
||||
|
||||
// final AuthRepository _repository;
|
||||
|
||||
// @override
|
||||
// Future<void> totpLogin({required String token, required String code}) {
|
||||
// return _repository.totpLogin(token: token, code: code);
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class TwoFARequestCodeUseCase {
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_request_code_use_case.dart';
|
||||
|
||||
class TwoFARequestCodeUseCaseImpl implements TwoFARequestCodeUseCase {
|
||||
TwoFARequestCodeUseCaseImpl(this._repository);
|
||||
|
||||
final AuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> twoFARequestCode({
|
||||
required String token,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _repository.twoFARequestCode(token: token, methodType: methodType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
abstract class TwoFASendCodeUseCase {
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_send_code_use_case.dart';
|
||||
|
||||
class TwoFASendCodeUseCaseImpl implements TwoFASendCodeUseCase {
|
||||
TwoFASendCodeUseCaseImpl(this._repository);
|
||||
|
||||
final AuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> twoFASendCode({
|
||||
required String token,
|
||||
required String code,
|
||||
required String methodType,
|
||||
}) {
|
||||
return _repository.twoFASendCode(
|
||||
token: token,
|
||||
methodType: methodType,
|
||||
code: code,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
abstract class TwoFactorUseCase {
|
||||
Future<void> twoFactor({required String token, required String code});
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import 'package:auth/src/core/domain/repositories/auth_repository.dart';
|
||||
import 'package:auth/src/features/login/domain/two_factor_use_case.dart';
|
||||
|
||||
class TwoFactorUseCaseImpl implements TwoFactorUseCase {
|
||||
TwoFactorUseCaseImpl(this._repository);
|
||||
|
||||
final AuthRepository _repository;
|
||||
|
||||
@override
|
||||
Future<void> twoFactor({required String token, required String code}) {
|
||||
return _repository.twoFactor(token: token, code: code);
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,27 @@ class LoginScreen extends ConsumerWidget {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
final vm = ref.read(loginViewModelProvider.notifier);
|
||||
await vm.login();
|
||||
|
||||
final String? token = await vm.login();
|
||||
if (!context.mounted) return;
|
||||
|
||||
if (token == null || token.isEmpty) return;
|
||||
final state = ref.read(loginViewModelProvider);
|
||||
|
||||
vm.prepareTwoFactor();
|
||||
if (state.errorMessage.isNotEmpty) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(state.errorMessage)));
|
||||
return;
|
||||
}
|
||||
|
||||
final token = state.token.trim();
|
||||
if (token.isEmpty) return;
|
||||
|
||||
vm.cleanCode();
|
||||
|
||||
await vm.twoFARequestCode(token: token);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
final bool? verified = await showModalBottomSheet<bool>(
|
||||
context: context,
|
||||
@@ -38,13 +52,13 @@ class LoginScreen extends ConsumerWidget {
|
||||
final vm = ref.read(loginViewModelProvider.notifier);
|
||||
|
||||
final otpErrorKey = ref.watch(
|
||||
loginViewModelProvider.select((s) => s.otpError),
|
||||
loginViewModelProvider.select((s) => s.codeError),
|
||||
);
|
||||
final isOtpLoading = ref.watch(
|
||||
loginViewModelProvider.select((s) => s.isOtpLoading),
|
||||
final isLoading = ref.watch(
|
||||
loginViewModelProvider.select((s) => s.isLoading),
|
||||
);
|
||||
final otpCode = ref.watch(
|
||||
loginViewModelProvider.select((s) => s.otpCode),
|
||||
final code = ref.watch(
|
||||
loginViewModelProvider.select((s) => s.code),
|
||||
);
|
||||
|
||||
final otpErrorText = otpErrorKey.isEmpty
|
||||
@@ -54,10 +68,37 @@ class LoginScreen extends ConsumerWidget {
|
||||
Future<void> onVerify() async {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
|
||||
final ok = await vm.twoFactor(token: token);
|
||||
final ok = await vm.twoFASendCode(token: token);
|
||||
if (!context.mounted) return;
|
||||
|
||||
if (ok) Navigator.of(context).pop(true);
|
||||
if (!ok) {
|
||||
final state = ref.read(loginViewModelProvider);
|
||||
if (state.errorMessage.isNotEmpty) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(state.errorMessage)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final user = await vm.getUserInfo();
|
||||
if (!context.mounted) return;
|
||||
|
||||
if (user == null) {
|
||||
final state = ref.read(loginViewModelProvider);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
state.errorMessage.isEmpty
|
||||
? 'Error getting user info'
|
||||
: state.errorMessage,
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
|
||||
return TwoFactorBottomSheetView(
|
||||
@@ -66,8 +107,8 @@ class LoginScreen extends ConsumerWidget {
|
||||
subtitle: context.translate(I18n.twoFactorSubtitle),
|
||||
verifyText: context.translate(I18n.twoFactorVerify),
|
||||
closeText: context.translate(I18n.close),
|
||||
isOtpLoading: isOtpLoading,
|
||||
otpCode: otpCode,
|
||||
isOtpLoading: isLoading,
|
||||
otpCode: code,
|
||||
otpErrorText: otpErrorText,
|
||||
onChanged: vm.setOtpCode,
|
||||
onVerify: onVerify,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:auth/src/features/login/domain/get_me_user_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/get_me_user_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final getUserInfoUseCaseProvider = Provider.autoDispose<GetUserInfoUseCase>((
|
||||
ref,
|
||||
) {
|
||||
final authRepository = ref.read(authRepositoryProvider);
|
||||
return GetUserInfoUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
// import 'package:auth/src/core/providers/auth_repository_provider.dart';
|
||||
// import 'package:auth/src/features/login/domain/totp_login_use_case.dart';
|
||||
// import 'package:auth/src/features/login/domain/totp_login_use_case_impl.dart';
|
||||
// import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
// final totpLoginUseCaseProvider = Provider.autoDispose<TotpLoginUseCase>((ref) {
|
||||
// final authRepository = ref.read(authRepositoryProvider);
|
||||
// return TotpLoginUseCaseImpl(authRepository);
|
||||
// });
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_request_code_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_request_code_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final twoFARequestCodeUseCaseProvider =
|
||||
Provider.autoDispose<TwoFARequestCodeUseCase>((ref) {
|
||||
final authRepository = ref.read(authRepositoryProvider);
|
||||
return TwoFARequestCodeUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_send_code_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_send_code_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final twoFASendCodeUseCaseProvider = Provider.autoDispose<TwoFASendCodeUseCase>(
|
||||
(ref) {
|
||||
final authRepository = ref.read(authRepositoryProvider);
|
||||
return TwoFASendCodeUseCaseImpl(authRepository);
|
||||
},
|
||||
);
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:auth/src/core/providers/auth_repository_provider.dart';
|
||||
import 'package:auth/src/features/login/domain/two_factor_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/two_factor_use_case_impl.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
final twoFactorUseCaseProvider = Provider.autoDispose<TwoFactorUseCase>((ref) {
|
||||
final authRepository = ref.read(authRepositoryProvider);
|
||||
return TwoFactorUseCaseImpl(authRepository);
|
||||
});
|
||||
@@ -1,7 +1,12 @@
|
||||
import 'package:auth/src/features/login/domain/entities/user_entity.dart';
|
||||
import 'package:auth/src/features/login/domain/get_me_user_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/login_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/two_factor_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_request_code_use_case.dart';
|
||||
import 'package:auth/src/features/login/domain/two_fa_send_code_use_case.dart';
|
||||
import 'package:auth/src/features/login/presentation/providers/get_user_info_provider.dart';
|
||||
import 'package:auth/src/features/login/presentation/providers/login_provider.dart';
|
||||
import 'package:auth/src/features/login/presentation/providers/two_factor_provider.dart';
|
||||
import 'package:auth/src/features/login/presentation/providers/two_fa_request_code_provider.dart';
|
||||
import 'package:auth/src/features/login/presentation/providers/two_fa_send_code_provider.dart';
|
||||
import 'package:auth/src/features/login/presentation/state/login_view_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@@ -14,12 +19,16 @@ final loginViewModelProvider =
|
||||
|
||||
class LoginViewModel extends Notifier<LoginViewState> {
|
||||
late final LoginUseCase _loginUseCase;
|
||||
late final TwoFactorUseCase _twoFactorUseCase;
|
||||
late final TwoFARequestCodeUseCase _twoFARequestCodeUseCase;
|
||||
late final TwoFASendCodeUseCase _twoFASendCodeUseCase;
|
||||
late final GetUserInfoUseCase _getUserInfoUseCase;
|
||||
|
||||
// late final TotpLoginUseCase _totpLoginUseCase;
|
||||
|
||||
late final TextEditingController emailController;
|
||||
late final TextEditingController passwordController;
|
||||
|
||||
late final TextEditingController otpController;
|
||||
late final TextEditingController codeController;
|
||||
|
||||
static final RegExp _emailRegex = RegExp(
|
||||
r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$',
|
||||
@@ -29,15 +38,19 @@ class LoginViewModel extends Notifier<LoginViewState> {
|
||||
@override
|
||||
LoginViewState build() {
|
||||
_loginUseCase = ref.read(loginUseCaseProvider);
|
||||
_twoFactorUseCase = ref.read(twoFactorUseCaseProvider);
|
||||
_twoFARequestCodeUseCase = ref.read(twoFARequestCodeUseCaseProvider);
|
||||
_twoFASendCodeUseCase = ref.read(twoFASendCodeUseCaseProvider);
|
||||
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
|
||||
|
||||
// _totpLoginUseCase = ref.read(totpLoginUseCaseProvider);
|
||||
|
||||
emailController = TextEditingController();
|
||||
passwordController = TextEditingController();
|
||||
otpController = TextEditingController();
|
||||
codeController = TextEditingController();
|
||||
|
||||
emailController.addListener(_onEmailChanged);
|
||||
passwordController.addListener(_onPasswordChanged);
|
||||
otpController.addListener(_onOtpChanged);
|
||||
codeController.addListener(_onOtpChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
@@ -100,103 +113,166 @@ class LoginViewModel extends Notifier<LoginViewState> {
|
||||
return emailError.isEmpty && passwordError.isEmpty;
|
||||
}
|
||||
|
||||
Future<String?> login() async {
|
||||
if (!_validateForm()) return null;
|
||||
Future<void> login() async {
|
||||
if (!_validateForm()) return;
|
||||
|
||||
final email = state.email.trim();
|
||||
final password = state.password.trim();
|
||||
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
state = state.copyWith(isLoading: true);
|
||||
|
||||
try {
|
||||
final String token = await _loginUseCase.login(
|
||||
final response = await _loginUseCase.login(
|
||||
email: email,
|
||||
password: password,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return null;
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(isLoading: false);
|
||||
return token;
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
token: response.token,
|
||||
availableMethods: response.availableMethods,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return null;
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void prepareTwoFactor() {
|
||||
otpController.text = '';
|
||||
state = state.copyWith(otpCode: '', otpError: '', isOtpLoading: false);
|
||||
void cleanCode() {
|
||||
codeController.text = '';
|
||||
state = state.copyWith(code: '', isLoading: false);
|
||||
}
|
||||
|
||||
void _onOtpChanged() {
|
||||
final raw = otpController.text;
|
||||
if (raw == state.otpCode) return;
|
||||
final raw = codeController.text;
|
||||
if (raw == state.code) return;
|
||||
|
||||
state = state.copyWith(otpCode: raw, otpError: '');
|
||||
state = state.copyWith(code: raw);
|
||||
|
||||
if (state.showErrors) {
|
||||
state = state.copyWith(otpError: _otpErrorFor(raw));
|
||||
state = state.copyWith(codeError: _codeErrorFor(raw));
|
||||
}
|
||||
}
|
||||
|
||||
void setOtpCode(String code) {
|
||||
state = state.copyWith(otpCode: code, otpError: '');
|
||||
state = state.copyWith(code: code, codeError: '');
|
||||
}
|
||||
|
||||
String _otpErrorFor(String value) {
|
||||
String _codeErrorFor(String value) {
|
||||
final code = value.trim();
|
||||
if (code.isEmpty) return I18n.errorTwoFactorCodeRequired;
|
||||
if (code.length != 6) return I18n.errorTwoFactorCodeInvalidLength;
|
||||
return '';
|
||||
}
|
||||
|
||||
bool _validateOtp() {
|
||||
final otpError = _otpErrorFor(state.otpCode);
|
||||
|
||||
state = state.copyWith(
|
||||
showErrors: true,
|
||||
otpError: otpError,
|
||||
errorMessage: '',
|
||||
);
|
||||
|
||||
return otpError.isEmpty;
|
||||
}
|
||||
|
||||
Future<bool> twoFactor({required String token}) async {
|
||||
if (!_validateOtp()) return false;
|
||||
|
||||
final code = state.otpCode.trim();
|
||||
|
||||
state = state.copyWith(isOtpLoading: true, otpError: '', errorMessage: '');
|
||||
|
||||
Future<bool> twoFARequestCode({required String token}) async {
|
||||
try {
|
||||
await _twoFactorUseCase.twoFactor(token: token, code: code);
|
||||
await _twoFARequestCodeUseCase.twoFARequestCode(
|
||||
token: token,
|
||||
methodType: state.availableMethods.first.methodType,
|
||||
);
|
||||
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
state = state.copyWith(isOtpLoading: false);
|
||||
state = state.copyWith(isLoading: false);
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
state = state.copyWith(
|
||||
isOtpLoading: false,
|
||||
otpError: I18n.errorTwoFactorCodeInvalid,
|
||||
);
|
||||
state = state.copyWith(isLoading: false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> twoFASendCode({required String token}) async {
|
||||
final codeError = _codeErrorFor(state.code);
|
||||
if (codeError.isNotEmpty) {
|
||||
state = state.copyWith(showErrors: true, codeError: codeError);
|
||||
return false;
|
||||
}
|
||||
|
||||
final method = state.availableMethods.firstWhere(
|
||||
(m) => m.isDefault,
|
||||
orElse: () => state.availableMethods.first,
|
||||
);
|
||||
|
||||
state = state.copyWith(isLoading: true, errorMessage: '', codeError: '');
|
||||
|
||||
try {
|
||||
await _twoFASendCodeUseCase.twoFASendCode(
|
||||
token: token,
|
||||
code: state.code.trim(),
|
||||
methodType: method.methodType,
|
||||
);
|
||||
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(isLoading: false);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<UserEntity?> getUserInfo() async {
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
final user = await _getUserInfoUseCase.getUserInfo();
|
||||
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(isLoading: false);
|
||||
}
|
||||
|
||||
debugPrint('[getUserInfo] userId => ${user.id}');
|
||||
return user;
|
||||
} catch (e) {
|
||||
if (ref.mounted) {
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Future<bool> totpLogin({required String token}) async {
|
||||
// if (!_validateOtp()) return false;
|
||||
|
||||
// final code = state.otpCode.trim();
|
||||
|
||||
// state = state.copyWith(isOtpLoading: true, otpError: '', errorMessage: '');
|
||||
|
||||
// try {
|
||||
// await _totpLoginUseCase.totpLogin(token: token, code: code);
|
||||
|
||||
// if (!ref.mounted) return false;
|
||||
|
||||
// state = state.copyWith(isOtpLoading: false);
|
||||
// return true;
|
||||
// } catch (e) {
|
||||
// if (!ref.mounted) return false;
|
||||
|
||||
// state = state.copyWith(
|
||||
// isOtpLoading: false,
|
||||
// otpError: I18n.errorTwoFactorCodeInvalid,
|
||||
// );
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
void disposeControllers() {
|
||||
emailController.removeListener(_onEmailChanged);
|
||||
passwordController.removeListener(_onPasswordChanged);
|
||||
otpController.removeListener(_onOtpChanged);
|
||||
codeController.removeListener(_onOtpChanged);
|
||||
|
||||
emailController.dispose();
|
||||
passwordController.dispose();
|
||||
otpController.dispose();
|
||||
codeController.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import 'package:auth/src/features/login/domain/entities/login_response_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'login_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LoginViewState with _$LoginViewState {
|
||||
const LoginViewState._();
|
||||
|
||||
const factory LoginViewState({
|
||||
@Default('') String email,
|
||||
@Default('') String password,
|
||||
@@ -14,8 +17,9 @@ abstract class LoginViewState with _$LoginViewState {
|
||||
@Default(false) bool showErrors,
|
||||
@Default(false) bool isLoading,
|
||||
@Default('') String token,
|
||||
@Default('') String otpCode,
|
||||
@Default('') String otpError,
|
||||
@Default(false) bool isOtpLoading,
|
||||
@Default(<AvailableMethodEntity>[])
|
||||
List<AvailableMethodEntity> availableMethods,
|
||||
@Default('') String code,
|
||||
@Default('') String codeError,
|
||||
}) = _LoginViewState;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LoginViewState {
|
||||
|
||||
String get email; String get password; bool get passwordVisible; String get emailError; String get passwordError; String get errorMessage; bool get showErrors; bool get isLoading; String get token; String get otpCode; String get otpError; bool get isOtpLoading;
|
||||
String get email; String get password; bool get passwordVisible; String get emailError; String get passwordError; String get errorMessage; bool get showErrors; bool get isLoading; String get token; List<AvailableMethodEntity> get availableMethods; String get code; String get codeError;
|
||||
/// Create a copy of LoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LoginViewStateCopyWith<LoginViewState> get copyWith => _$LoginViewStateCopyWith
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.token, token) || other.token == token)&&(identical(other.otpCode, otpCode) || other.otpCode == otpCode)&&(identical(other.otpError, otpError) || other.otpError == otpError)&&(identical(other.isOtpLoading, isOtpLoading) || other.isOtpLoading == isOtpLoading));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,token,otpCode,otpError,isOtpLoading);
|
||||
int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,token,const DeepCollectionEquality().hash(availableMethods),code,codeError);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, token: $token, otpCode: $otpCode, otpError: $otpError, isOtpLoading: $isOtpLoading)';
|
||||
return 'LoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, token: $token, availableMethods: $availableMethods, code: $code, codeError: $codeError)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $LoginViewStateCopyWith<$Res> {
|
||||
factory $LoginViewStateCopyWith(LoginViewState value, $Res Function(LoginViewState) _then) = _$LoginViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, String otpCode, String otpError, bool isOtpLoading
|
||||
String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, List<AvailableMethodEntity> availableMethods, String code, String codeError
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class _$LoginViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? token = null,Object? otpCode = null,Object? otpError = null,Object? isOtpLoading = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? token = null,Object? availableMethods = null,Object? code = null,Object? codeError = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
@@ -73,10 +73,10 @@ as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage
|
||||
as String,showErrors: null == showErrors ? _self.showErrors : showErrors // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,otpCode: null == otpCode ? _self.otpCode : otpCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,otpError: null == otpError ? _self.otpError : otpError // ignore: cast_nullable_to_non_nullable
|
||||
as String,isOtpLoading: null == isOtpLoading ? _self.isOtpLoading : isOtpLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
as String,availableMethods: null == availableMethods ? _self.availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<AvailableMethodEntity>,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable
|
||||
as String,codeError: null == codeError ? _self.codeError : codeError // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -161,10 +161,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, String otpCode, String otpError, bool isOtpLoading)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, List<AvailableMethodEntity> availableMethods, String code, String codeError)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginViewState() when $default != null:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.token,_that.otpCode,_that.otpError,_that.isOtpLoading);case _:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.token,_that.availableMethods,_that.code,_that.codeError);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -182,10 +182,10 @@ return $default(_that.email,_that.password,_that.passwordVisible,_that.emailErro
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, String otpCode, String otpError, bool isOtpLoading) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, List<AvailableMethodEntity> availableMethods, String code, String codeError) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginViewState():
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.token,_that.otpCode,_that.otpError,_that.isOtpLoading);case _:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.token,_that.availableMethods,_that.code,_that.codeError);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -202,10 +202,10 @@ return $default(_that.email,_that.password,_that.passwordVisible,_that.emailErro
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, String otpCode, String otpError, bool isOtpLoading)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, List<AvailableMethodEntity> availableMethods, String code, String codeError)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoginViewState() when $default != null:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.token,_that.otpCode,_that.otpError,_that.isOtpLoading);case _:
|
||||
return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.token,_that.availableMethods,_that.code,_that.codeError);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -216,8 +216,8 @@ return $default(_that.email,_that.password,_that.passwordVisible,_that.emailErro
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LoginViewState implements LoginViewState {
|
||||
const _LoginViewState({this.email = '', this.password = '', this.passwordVisible = false, this.emailError = '', this.passwordError = '', this.errorMessage = '', this.showErrors = false, this.isLoading = false, this.token = '', this.otpCode = '', this.otpError = '', this.isOtpLoading = false});
|
||||
class _LoginViewState extends LoginViewState {
|
||||
const _LoginViewState({this.email = '', this.password = '', this.passwordVisible = false, this.emailError = '', this.passwordError = '', this.errorMessage = '', this.showErrors = false, this.isLoading = false, this.token = '', final List<AvailableMethodEntity> availableMethods = const <AvailableMethodEntity>[], this.code = '', this.codeError = ''}): _availableMethods = availableMethods,super._();
|
||||
|
||||
|
||||
@override@JsonKey() final String email;
|
||||
@@ -229,9 +229,15 @@ class _LoginViewState implements LoginViewState {
|
||||
@override@JsonKey() final bool showErrors;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final String token;
|
||||
@override@JsonKey() final String otpCode;
|
||||
@override@JsonKey() final String otpError;
|
||||
@override@JsonKey() final bool isOtpLoading;
|
||||
final List<AvailableMethodEntity> _availableMethods;
|
||||
@override@JsonKey() List<AvailableMethodEntity> get availableMethods {
|
||||
if (_availableMethods is EqualUnmodifiableListView) return _availableMethods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_availableMethods);
|
||||
}
|
||||
|
||||
@override@JsonKey() final String code;
|
||||
@override@JsonKey() final String codeError;
|
||||
|
||||
/// Create a copy of LoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -243,16 +249,16 @@ _$LoginViewStateCopyWith<_LoginViewState> get copyWith => __$LoginViewStateCopyW
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.token, token) || other.token == token)&&(identical(other.otpCode, otpCode) || other.otpCode == otpCode)&&(identical(other.otpError, otpError) || other.otpError == otpError)&&(identical(other.isOtpLoading, isOtpLoading) || other.isOtpLoading == isOtpLoading));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.token, token) || other.token == token)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,token,otpCode,otpError,isOtpLoading);
|
||||
int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,token,const DeepCollectionEquality().hash(_availableMethods),code,codeError);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, token: $token, otpCode: $otpCode, otpError: $otpError, isOtpLoading: $isOtpLoading)';
|
||||
return 'LoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, token: $token, availableMethods: $availableMethods, code: $code, codeError: $codeError)';
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +269,7 @@ abstract mixin class _$LoginViewStateCopyWith<$Res> implements $LoginViewStateCo
|
||||
factory _$LoginViewStateCopyWith(_LoginViewState value, $Res Function(_LoginViewState) _then) = __$LoginViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, String otpCode, String otpError, bool isOtpLoading
|
||||
String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, String token, List<AvailableMethodEntity> availableMethods, String code, String codeError
|
||||
});
|
||||
|
||||
|
||||
@@ -280,7 +286,7 @@ class __$LoginViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LoginViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? token = null,Object? otpCode = null,Object? otpError = null,Object? isOtpLoading = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? token = null,Object? availableMethods = null,Object? code = null,Object? codeError = null,}) {
|
||||
return _then(_LoginViewState(
|
||||
email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable
|
||||
as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable
|
||||
@@ -291,10 +297,10 @@ as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage
|
||||
as String,showErrors: null == showErrors ? _self.showErrors : showErrors // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,token: null == token ? _self.token : token // ignore: cast_nullable_to_non_nullable
|
||||
as String,otpCode: null == otpCode ? _self.otpCode : otpCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,otpError: null == otpError ? _self.otpError : otpError // ignore: cast_nullable_to_non_nullable
|
||||
as String,isOtpLoading: null == isOtpLoading ? _self.isOtpLoading : isOtpLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
as String,availableMethods: null == availableMethods ? _self._availableMethods : availableMethods // ignore: cast_nullable_to_non_nullable
|
||||
as List<AvailableMethodEntity>,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable
|
||||
as String,codeError: null == codeError ? _self.codeError : codeError // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ Dio buildDioClient({
|
||||
dio.interceptors.add(
|
||||
LogInterceptor(
|
||||
request: true,
|
||||
requestHeader: false,
|
||||
requestHeader: true,
|
||||
requestBody: true,
|
||||
responseHeader: true,
|
||||
responseBody: true,
|
||||
|
||||
Reference in New Issue
Block a user