verify repo
This commit is contained in:
parent
13c55afe3c
commit
c40f96fc88
58
lib/application/auth/verify_form/verify_form_bloc.dart
Normal file
58
lib/application/auth/verify_form/verify_form_bloc.dart
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:injectable/injectable.dart';
|
||||||
|
|
||||||
|
import '../../../domain/auth/auth.dart';
|
||||||
|
|
||||||
|
part 'verify_form_event.dart';
|
||||||
|
part 'verify_form_state.dart';
|
||||||
|
part 'verify_form_bloc.freezed.dart';
|
||||||
|
|
||||||
|
@injectable
|
||||||
|
class VerifyFormBloc extends Bloc<VerifyFormEvent, VerifyFormState> {
|
||||||
|
final IAuthRepository _repository;
|
||||||
|
VerifyFormBloc(this._repository) : super(VerifyFormState.initial()) {
|
||||||
|
on<VerifyFormEvent>(_onVerifyFormEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onVerifyFormEvent(
|
||||||
|
VerifyFormEvent event,
|
||||||
|
Emitter<VerifyFormState> emit,
|
||||||
|
) {
|
||||||
|
return event.map(
|
||||||
|
registrationTokenChanged: (e) async {
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
registrationToken: e.registrationToken,
|
||||||
|
failureOrVerifyOption: none(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
otpCodeChanged: (e) async {
|
||||||
|
emit(state.copyWith(otpCode: e.otpCode, failureOrVerifyOption: none()));
|
||||||
|
},
|
||||||
|
submitted: (e) async {
|
||||||
|
Either<AuthFailure, Verify>? failureOrVerify;
|
||||||
|
emit(state.copyWith(isSubmitting: true, failureOrVerifyOption: none()));
|
||||||
|
|
||||||
|
final otpCodeValid = state.otpCode.isNotEmpty;
|
||||||
|
final registrationTokenValid = state.registrationToken.isNotEmpty;
|
||||||
|
|
||||||
|
if (registrationTokenValid && otpCodeValid) {
|
||||||
|
failureOrVerify = await _repository.verify(
|
||||||
|
registrationToken: state.registrationToken,
|
||||||
|
otpCode: state.otpCode,
|
||||||
|
);
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
isSubmitting: false,
|
||||||
|
failureOrVerifyOption: optionOf(failureOrVerify),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
750
lib/application/auth/verify_form/verify_form_bloc.freezed.dart
Normal file
750
lib/application/auth/verify_form/verify_form_bloc.freezed.dart
Normal file
@ -0,0 +1,750 @@
|
|||||||
|
// coverage:ignore-file
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// 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 'verify_form_bloc.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||||
|
);
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VerifyFormEvent {
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(String registrationToken)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(String otpCode) otpCodeChanged,
|
||||||
|
required TResult Function() submitted,
|
||||||
|
}) => throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult? Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult? Function()? submitted,
|
||||||
|
}) => throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult Function()? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) => throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_RegistrationTokenChanged value)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
|
||||||
|
required TResult Function(_Submitted value) submitted,
|
||||||
|
}) => throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RegistrationTokenChanged value)?
|
||||||
|
registrationTokenChanged,
|
||||||
|
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult? Function(_Submitted value)? submitted,
|
||||||
|
}) => throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
|
||||||
|
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult Function(_Submitted value)? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VerifyFormEventCopyWith<$Res> {
|
||||||
|
factory $VerifyFormEventCopyWith(
|
||||||
|
VerifyFormEvent value,
|
||||||
|
$Res Function(VerifyFormEvent) then,
|
||||||
|
) = _$VerifyFormEventCopyWithImpl<$Res, VerifyFormEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VerifyFormEventCopyWithImpl<$Res, $Val extends VerifyFormEvent>
|
||||||
|
implements $VerifyFormEventCopyWith<$Res> {
|
||||||
|
_$VerifyFormEventCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$RegistrationTokenChangedImplCopyWith<$Res> {
|
||||||
|
factory _$$RegistrationTokenChangedImplCopyWith(
|
||||||
|
_$RegistrationTokenChangedImpl value,
|
||||||
|
$Res Function(_$RegistrationTokenChangedImpl) then,
|
||||||
|
) = __$$RegistrationTokenChangedImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String registrationToken});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$RegistrationTokenChangedImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyFormEventCopyWithImpl<$Res, _$RegistrationTokenChangedImpl>
|
||||||
|
implements _$$RegistrationTokenChangedImplCopyWith<$Res> {
|
||||||
|
__$$RegistrationTokenChangedImplCopyWithImpl(
|
||||||
|
_$RegistrationTokenChangedImpl _value,
|
||||||
|
$Res Function(_$RegistrationTokenChangedImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({Object? registrationToken = null}) {
|
||||||
|
return _then(
|
||||||
|
_$RegistrationTokenChangedImpl(
|
||||||
|
null == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$RegistrationTokenChangedImpl implements _RegistrationTokenChanged {
|
||||||
|
const _$RegistrationTokenChangedImpl(this.registrationToken);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String registrationToken;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VerifyFormEvent.registrationTokenChanged(registrationToken: $registrationToken)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$RegistrationTokenChangedImpl &&
|
||||||
|
(identical(other.registrationToken, registrationToken) ||
|
||||||
|
other.registrationToken == registrationToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, registrationToken);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
|
||||||
|
get copyWith =>
|
||||||
|
__$$RegistrationTokenChangedImplCopyWithImpl<
|
||||||
|
_$RegistrationTokenChangedImpl
|
||||||
|
>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(String registrationToken)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(String otpCode) otpCodeChanged,
|
||||||
|
required TResult Function() submitted,
|
||||||
|
}) {
|
||||||
|
return registrationTokenChanged(registrationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult? Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult? Function()? submitted,
|
||||||
|
}) {
|
||||||
|
return registrationTokenChanged?.call(registrationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult Function()? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (registrationTokenChanged != null) {
|
||||||
|
return registrationTokenChanged(registrationToken);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_RegistrationTokenChanged value)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
|
||||||
|
required TResult Function(_Submitted value) submitted,
|
||||||
|
}) {
|
||||||
|
return registrationTokenChanged(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RegistrationTokenChanged value)?
|
||||||
|
registrationTokenChanged,
|
||||||
|
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult? Function(_Submitted value)? submitted,
|
||||||
|
}) {
|
||||||
|
return registrationTokenChanged?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
|
||||||
|
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult Function(_Submitted value)? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (registrationTokenChanged != null) {
|
||||||
|
return registrationTokenChanged(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _RegistrationTokenChanged implements VerifyFormEvent {
|
||||||
|
const factory _RegistrationTokenChanged(final String registrationToken) =
|
||||||
|
_$RegistrationTokenChangedImpl;
|
||||||
|
|
||||||
|
String get registrationToken;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
|
||||||
|
get copyWith => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$OtpCodeChangedImplCopyWith<$Res> {
|
||||||
|
factory _$$OtpCodeChangedImplCopyWith(
|
||||||
|
_$OtpCodeChangedImpl value,
|
||||||
|
$Res Function(_$OtpCodeChangedImpl) then,
|
||||||
|
) = __$$OtpCodeChangedImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String otpCode});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$OtpCodeChangedImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyFormEventCopyWithImpl<$Res, _$OtpCodeChangedImpl>
|
||||||
|
implements _$$OtpCodeChangedImplCopyWith<$Res> {
|
||||||
|
__$$OtpCodeChangedImplCopyWithImpl(
|
||||||
|
_$OtpCodeChangedImpl _value,
|
||||||
|
$Res Function(_$OtpCodeChangedImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({Object? otpCode = null}) {
|
||||||
|
return _then(
|
||||||
|
_$OtpCodeChangedImpl(
|
||||||
|
null == otpCode
|
||||||
|
? _value.otpCode
|
||||||
|
: otpCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$OtpCodeChangedImpl implements _OtpCodeChanged {
|
||||||
|
const _$OtpCodeChangedImpl(this.otpCode);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String otpCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VerifyFormEvent.otpCodeChanged(otpCode: $otpCode)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$OtpCodeChangedImpl &&
|
||||||
|
(identical(other.otpCode, otpCode) || other.otpCode == otpCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, otpCode);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$OtpCodeChangedImplCopyWith<_$OtpCodeChangedImpl> get copyWith =>
|
||||||
|
__$$OtpCodeChangedImplCopyWithImpl<_$OtpCodeChangedImpl>(
|
||||||
|
this,
|
||||||
|
_$identity,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(String registrationToken)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(String otpCode) otpCodeChanged,
|
||||||
|
required TResult Function() submitted,
|
||||||
|
}) {
|
||||||
|
return otpCodeChanged(otpCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult? Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult? Function()? submitted,
|
||||||
|
}) {
|
||||||
|
return otpCodeChanged?.call(otpCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult Function()? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (otpCodeChanged != null) {
|
||||||
|
return otpCodeChanged(otpCode);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_RegistrationTokenChanged value)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
|
||||||
|
required TResult Function(_Submitted value) submitted,
|
||||||
|
}) {
|
||||||
|
return otpCodeChanged(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RegistrationTokenChanged value)?
|
||||||
|
registrationTokenChanged,
|
||||||
|
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult? Function(_Submitted value)? submitted,
|
||||||
|
}) {
|
||||||
|
return otpCodeChanged?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
|
||||||
|
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult Function(_Submitted value)? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (otpCodeChanged != null) {
|
||||||
|
return otpCodeChanged(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _OtpCodeChanged implements VerifyFormEvent {
|
||||||
|
const factory _OtpCodeChanged(final String otpCode) = _$OtpCodeChangedImpl;
|
||||||
|
|
||||||
|
String get otpCode;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$OtpCodeChangedImplCopyWith<_$OtpCodeChangedImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$SubmittedImplCopyWith<$Res> {
|
||||||
|
factory _$$SubmittedImplCopyWith(
|
||||||
|
_$SubmittedImpl value,
|
||||||
|
$Res Function(_$SubmittedImpl) then,
|
||||||
|
) = __$$SubmittedImplCopyWithImpl<$Res>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$SubmittedImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyFormEventCopyWithImpl<$Res, _$SubmittedImpl>
|
||||||
|
implements _$$SubmittedImplCopyWith<$Res> {
|
||||||
|
__$$SubmittedImplCopyWithImpl(
|
||||||
|
_$SubmittedImpl _value,
|
||||||
|
$Res Function(_$SubmittedImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$SubmittedImpl implements _Submitted {
|
||||||
|
const _$SubmittedImpl();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VerifyFormEvent.submitted()';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(String registrationToken)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(String otpCode) otpCodeChanged,
|
||||||
|
required TResult Function() submitted,
|
||||||
|
}) {
|
||||||
|
return submitted();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult? Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult? Function()? submitted,
|
||||||
|
}) {
|
||||||
|
return submitted?.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(String registrationToken)? registrationTokenChanged,
|
||||||
|
TResult Function(String otpCode)? otpCodeChanged,
|
||||||
|
TResult Function()? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (submitted != null) {
|
||||||
|
return submitted();
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_RegistrationTokenChanged value)
|
||||||
|
registrationTokenChanged,
|
||||||
|
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
|
||||||
|
required TResult Function(_Submitted value) submitted,
|
||||||
|
}) {
|
||||||
|
return submitted(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RegistrationTokenChanged value)?
|
||||||
|
registrationTokenChanged,
|
||||||
|
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult? Function(_Submitted value)? submitted,
|
||||||
|
}) {
|
||||||
|
return submitted?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
|
||||||
|
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
|
||||||
|
TResult Function(_Submitted value)? submitted,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (submitted != null) {
|
||||||
|
return submitted(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Submitted implements VerifyFormEvent {
|
||||||
|
const factory _Submitted() = _$SubmittedImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VerifyFormState {
|
||||||
|
String get registrationToken => throw _privateConstructorUsedError;
|
||||||
|
String get otpCode => throw _privateConstructorUsedError;
|
||||||
|
Option<Either<AuthFailure, Verify>> get failureOrVerifyOption =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||||
|
bool get showErrorMessages => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
$VerifyFormStateCopyWith<VerifyFormState> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VerifyFormStateCopyWith<$Res> {
|
||||||
|
factory $VerifyFormStateCopyWith(
|
||||||
|
VerifyFormState value,
|
||||||
|
$Res Function(VerifyFormState) then,
|
||||||
|
) = _$VerifyFormStateCopyWithImpl<$Res, VerifyFormState>;
|
||||||
|
@useResult
|
||||||
|
$Res call({
|
||||||
|
String registrationToken,
|
||||||
|
String otpCode,
|
||||||
|
Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
|
||||||
|
bool isSubmitting,
|
||||||
|
bool showErrorMessages,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VerifyFormStateCopyWithImpl<$Res, $Val extends VerifyFormState>
|
||||||
|
implements $VerifyFormStateCopyWith<$Res> {
|
||||||
|
_$VerifyFormStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? registrationToken = null,
|
||||||
|
Object? otpCode = null,
|
||||||
|
Object? failureOrVerifyOption = null,
|
||||||
|
Object? isSubmitting = null,
|
||||||
|
Object? showErrorMessages = null,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_value.copyWith(
|
||||||
|
registrationToken: null == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
otpCode: null == otpCode
|
||||||
|
? _value.otpCode
|
||||||
|
: otpCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
failureOrVerifyOption: null == failureOrVerifyOption
|
||||||
|
? _value.failureOrVerifyOption
|
||||||
|
: failureOrVerifyOption // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Option<Either<AuthFailure, Verify>>,
|
||||||
|
isSubmitting: null == isSubmitting
|
||||||
|
? _value.isSubmitting
|
||||||
|
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
showErrorMessages: null == showErrorMessages
|
||||||
|
? _value.showErrorMessages
|
||||||
|
: showErrorMessages // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
)
|
||||||
|
as $Val,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VerifyFormStateImplCopyWith<$Res>
|
||||||
|
implements $VerifyFormStateCopyWith<$Res> {
|
||||||
|
factory _$$VerifyFormStateImplCopyWith(
|
||||||
|
_$VerifyFormStateImpl value,
|
||||||
|
$Res Function(_$VerifyFormStateImpl) then,
|
||||||
|
) = __$$VerifyFormStateImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({
|
||||||
|
String registrationToken,
|
||||||
|
String otpCode,
|
||||||
|
Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
|
||||||
|
bool isSubmitting,
|
||||||
|
bool showErrorMessages,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VerifyFormStateImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyFormStateCopyWithImpl<$Res, _$VerifyFormStateImpl>
|
||||||
|
implements _$$VerifyFormStateImplCopyWith<$Res> {
|
||||||
|
__$$VerifyFormStateImplCopyWithImpl(
|
||||||
|
_$VerifyFormStateImpl _value,
|
||||||
|
$Res Function(_$VerifyFormStateImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? registrationToken = null,
|
||||||
|
Object? otpCode = null,
|
||||||
|
Object? failureOrVerifyOption = null,
|
||||||
|
Object? isSubmitting = null,
|
||||||
|
Object? showErrorMessages = null,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_$VerifyFormStateImpl(
|
||||||
|
registrationToken: null == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
otpCode: null == otpCode
|
||||||
|
? _value.otpCode
|
||||||
|
: otpCode // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
failureOrVerifyOption: null == failureOrVerifyOption
|
||||||
|
? _value.failureOrVerifyOption
|
||||||
|
: failureOrVerifyOption // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Option<Either<AuthFailure, Verify>>,
|
||||||
|
isSubmitting: null == isSubmitting
|
||||||
|
? _value.isSubmitting
|
||||||
|
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
showErrorMessages: null == showErrorMessages
|
||||||
|
? _value.showErrorMessages
|
||||||
|
: showErrorMessages // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$VerifyFormStateImpl implements _VerifyFormState {
|
||||||
|
const _$VerifyFormStateImpl({
|
||||||
|
required this.registrationToken,
|
||||||
|
required this.otpCode,
|
||||||
|
required this.failureOrVerifyOption,
|
||||||
|
this.isSubmitting = false,
|
||||||
|
this.showErrorMessages = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String registrationToken;
|
||||||
|
@override
|
||||||
|
final String otpCode;
|
||||||
|
@override
|
||||||
|
final Option<Either<AuthFailure, Verify>> failureOrVerifyOption;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool isSubmitting;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
|
final bool showErrorMessages;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VerifyFormState(registrationToken: $registrationToken, otpCode: $otpCode, failureOrVerifyOption: $failureOrVerifyOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VerifyFormStateImpl &&
|
||||||
|
(identical(other.registrationToken, registrationToken) ||
|
||||||
|
other.registrationToken == registrationToken) &&
|
||||||
|
(identical(other.otpCode, otpCode) || other.otpCode == otpCode) &&
|
||||||
|
(identical(other.failureOrVerifyOption, failureOrVerifyOption) ||
|
||||||
|
other.failureOrVerifyOption == failureOrVerifyOption) &&
|
||||||
|
(identical(other.isSubmitting, isSubmitting) ||
|
||||||
|
other.isSubmitting == isSubmitting) &&
|
||||||
|
(identical(other.showErrorMessages, showErrorMessages) ||
|
||||||
|
other.showErrorMessages == showErrorMessages));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType,
|
||||||
|
registrationToken,
|
||||||
|
otpCode,
|
||||||
|
failureOrVerifyOption,
|
||||||
|
isSubmitting,
|
||||||
|
showErrorMessages,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VerifyFormStateImplCopyWith<_$VerifyFormStateImpl> get copyWith =>
|
||||||
|
__$$VerifyFormStateImplCopyWithImpl<_$VerifyFormStateImpl>(
|
||||||
|
this,
|
||||||
|
_$identity,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _VerifyFormState implements VerifyFormState {
|
||||||
|
const factory _VerifyFormState({
|
||||||
|
required final String registrationToken,
|
||||||
|
required final String otpCode,
|
||||||
|
required final Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
|
||||||
|
final bool isSubmitting,
|
||||||
|
final bool showErrorMessages,
|
||||||
|
}) = _$VerifyFormStateImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get registrationToken;
|
||||||
|
@override
|
||||||
|
String get otpCode;
|
||||||
|
@override
|
||||||
|
Option<Either<AuthFailure, Verify>> get failureOrVerifyOption;
|
||||||
|
@override
|
||||||
|
bool get isSubmitting;
|
||||||
|
@override
|
||||||
|
bool get showErrorMessages;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyFormState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$VerifyFormStateImplCopyWith<_$VerifyFormStateImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
11
lib/application/auth/verify_form/verify_form_event.dart
Normal file
11
lib/application/auth/verify_form/verify_form_event.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
part of 'verify_form_bloc.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class VerifyFormEvent with _$VerifyFormEvent {
|
||||||
|
const factory VerifyFormEvent.registrationTokenChanged(
|
||||||
|
String registrationToken,
|
||||||
|
) = _RegistrationTokenChanged;
|
||||||
|
const factory VerifyFormEvent.otpCodeChanged(String otpCode) =
|
||||||
|
_OtpCodeChanged;
|
||||||
|
const factory VerifyFormEvent.submitted() = _Submitted;
|
||||||
|
}
|
||||||
18
lib/application/auth/verify_form/verify_form_state.dart
Normal file
18
lib/application/auth/verify_form/verify_form_state.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
part of 'verify_form_bloc.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class VerifyFormState with _$VerifyFormState {
|
||||||
|
const factory VerifyFormState({
|
||||||
|
required String registrationToken,
|
||||||
|
required String otpCode,
|
||||||
|
required Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
|
||||||
|
@Default(false) bool isSubmitting,
|
||||||
|
@Default(false) bool showErrorMessages,
|
||||||
|
}) = _VerifyFormState;
|
||||||
|
|
||||||
|
factory VerifyFormState.initial() => VerifyFormState(
|
||||||
|
registrationToken: '',
|
||||||
|
otpCode: '',
|
||||||
|
failureOrVerifyOption: none(),
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
class ApiPath {
|
class ApiPath {
|
||||||
static String checkPhone = '/api/v1/customer-auth/check-phone';
|
static String checkPhone = '/api/v1/customer-auth/check-phone';
|
||||||
static String register = '/api/v1/customer-auth/register/start';
|
static String register = '/api/v1/customer-auth/register/start';
|
||||||
|
static String verify = '/api/v1/customer-auth/register/verify-otp';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ part 'auth.freezed.dart';
|
|||||||
|
|
||||||
part 'entities/check_phone_entity.dart';
|
part 'entities/check_phone_entity.dart';
|
||||||
part 'entities/register_entity.dart';
|
part 'entities/register_entity.dart';
|
||||||
|
part 'entities/verify_entity.dart';
|
||||||
part 'failures/auth_failure.dart';
|
part 'failures/auth_failure.dart';
|
||||||
part 'repositories/i_auth_repository.dart';
|
part 'repositories/i_auth_repository.dart';
|
||||||
|
|
||||||
|
|||||||
@ -424,6 +424,180 @@ abstract class _Register implements Register {
|
|||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$Verify {
|
||||||
|
String get status => throw _privateConstructorUsedError;
|
||||||
|
String get message => throw _privateConstructorUsedError;
|
||||||
|
String get registrationToken => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Create a copy of Verify
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
$VerifyCopyWith<Verify> get copyWith => throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VerifyCopyWith<$Res> {
|
||||||
|
factory $VerifyCopyWith(Verify value, $Res Function(Verify) then) =
|
||||||
|
_$VerifyCopyWithImpl<$Res, Verify>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String status, String message, String registrationToken});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VerifyCopyWithImpl<$Res, $Val extends Verify>
|
||||||
|
implements $VerifyCopyWith<$Res> {
|
||||||
|
_$VerifyCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of Verify
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? status = null,
|
||||||
|
Object? message = null,
|
||||||
|
Object? registrationToken = null,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_value.copyWith(
|
||||||
|
status: null == status
|
||||||
|
? _value.status
|
||||||
|
: status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
message: null == message
|
||||||
|
? _value.message
|
||||||
|
: message // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
registrationToken: null == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
)
|
||||||
|
as $Val,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VerifyImplCopyWith<$Res> implements $VerifyCopyWith<$Res> {
|
||||||
|
factory _$$VerifyImplCopyWith(
|
||||||
|
_$VerifyImpl value,
|
||||||
|
$Res Function(_$VerifyImpl) then,
|
||||||
|
) = __$$VerifyImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({String status, String message, String registrationToken});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VerifyImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyCopyWithImpl<$Res, _$VerifyImpl>
|
||||||
|
implements _$$VerifyImplCopyWith<$Res> {
|
||||||
|
__$$VerifyImplCopyWithImpl(
|
||||||
|
_$VerifyImpl _value,
|
||||||
|
$Res Function(_$VerifyImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of Verify
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? status = null,
|
||||||
|
Object? message = null,
|
||||||
|
Object? registrationToken = null,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_$VerifyImpl(
|
||||||
|
status: null == status
|
||||||
|
? _value.status
|
||||||
|
: status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
message: null == message
|
||||||
|
? _value.message
|
||||||
|
: message // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
registrationToken: null == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$VerifyImpl implements _Verify {
|
||||||
|
const _$VerifyImpl({
|
||||||
|
required this.status,
|
||||||
|
required this.message,
|
||||||
|
required this.registrationToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String status;
|
||||||
|
@override
|
||||||
|
final String message;
|
||||||
|
@override
|
||||||
|
final String registrationToken;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Verify(status: $status, message: $message, registrationToken: $registrationToken)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VerifyImpl &&
|
||||||
|
(identical(other.status, status) || other.status == status) &&
|
||||||
|
(identical(other.message, message) || other.message == message) &&
|
||||||
|
(identical(other.registrationToken, registrationToken) ||
|
||||||
|
other.registrationToken == registrationToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, status, message, registrationToken);
|
||||||
|
|
||||||
|
/// Create a copy of Verify
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VerifyImplCopyWith<_$VerifyImpl> get copyWith =>
|
||||||
|
__$$VerifyImplCopyWithImpl<_$VerifyImpl>(this, _$identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Verify implements Verify {
|
||||||
|
const factory _Verify({
|
||||||
|
required final String status,
|
||||||
|
required final String message,
|
||||||
|
required final String registrationToken,
|
||||||
|
}) = _$VerifyImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get status;
|
||||||
|
@override
|
||||||
|
String get message;
|
||||||
|
@override
|
||||||
|
String get registrationToken;
|
||||||
|
|
||||||
|
/// Create a copy of Verify
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$VerifyImplCopyWith<_$VerifyImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$AuthFailure {
|
mixin _$AuthFailure {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
|
|||||||
13
lib/domain/auth/entities/verify_entity.dart
Normal file
13
lib/domain/auth/entities/verify_entity.dart
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
part of '../auth.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class Verify with _$Verify {
|
||||||
|
const factory Verify({
|
||||||
|
required String status,
|
||||||
|
required String message,
|
||||||
|
required String registrationToken,
|
||||||
|
}) = _Verify;
|
||||||
|
|
||||||
|
factory Verify.empty() =>
|
||||||
|
const Verify(status: '', message: '', registrationToken: '');
|
||||||
|
}
|
||||||
@ -10,4 +10,9 @@ abstract class IAuthRepository {
|
|||||||
required String name,
|
required String name,
|
||||||
required DateTime birthDate,
|
required DateTime birthDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Future<Either<AuthFailure, Verify>> verify({
|
||||||
|
required String registrationToken,
|
||||||
|
required String otpCode,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,3 +7,4 @@ part 'auth_dtos.g.dart';
|
|||||||
|
|
||||||
part 'dto/check_phone_dto.dart';
|
part 'dto/check_phone_dto.dart';
|
||||||
part 'dto/register_dto.dart';
|
part 'dto/register_dto.dart';
|
||||||
|
part 'dto/verify_dto.dart';
|
||||||
|
|||||||
@ -859,3 +859,392 @@ abstract class _RegisterDataDto implements RegisterDataDto {
|
|||||||
_$$RegisterDataDtoImplCopyWith<_$RegisterDataDtoImpl> get copyWith =>
|
_$$RegisterDataDtoImplCopyWith<_$RegisterDataDtoImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VerifyDto _$VerifyDtoFromJson(Map<String, dynamic> json) {
|
||||||
|
return _VerifyDto.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VerifyDto {
|
||||||
|
@JsonKey(name: 'status')
|
||||||
|
String? get status => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: 'message')
|
||||||
|
String? get message => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(name: 'data')
|
||||||
|
VerifyDataDto? get data => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Serializes this VerifyDto to a JSON map.
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
$VerifyDtoCopyWith<VerifyDto> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VerifyDtoCopyWith<$Res> {
|
||||||
|
factory $VerifyDtoCopyWith(VerifyDto value, $Res Function(VerifyDto) then) =
|
||||||
|
_$VerifyDtoCopyWithImpl<$Res, VerifyDto>;
|
||||||
|
@useResult
|
||||||
|
$Res call({
|
||||||
|
@JsonKey(name: 'status') String? status,
|
||||||
|
@JsonKey(name: 'message') String? message,
|
||||||
|
@JsonKey(name: 'data') VerifyDataDto? data,
|
||||||
|
});
|
||||||
|
|
||||||
|
$VerifyDataDtoCopyWith<$Res>? get data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VerifyDtoCopyWithImpl<$Res, $Val extends VerifyDto>
|
||||||
|
implements $VerifyDtoCopyWith<$Res> {
|
||||||
|
_$VerifyDtoCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? status = freezed,
|
||||||
|
Object? message = freezed,
|
||||||
|
Object? data = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_value.copyWith(
|
||||||
|
status: freezed == status
|
||||||
|
? _value.status
|
||||||
|
: status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
message: freezed == message
|
||||||
|
? _value.message
|
||||||
|
: message // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
data: freezed == data
|
||||||
|
? _value.data
|
||||||
|
: data // ignore: cast_nullable_to_non_nullable
|
||||||
|
as VerifyDataDto?,
|
||||||
|
)
|
||||||
|
as $Val,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$VerifyDataDtoCopyWith<$Res>? get data {
|
||||||
|
if (_value.data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $VerifyDataDtoCopyWith<$Res>(_value.data!, (value) {
|
||||||
|
return _then(_value.copyWith(data: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VerifyDtoImplCopyWith<$Res>
|
||||||
|
implements $VerifyDtoCopyWith<$Res> {
|
||||||
|
factory _$$VerifyDtoImplCopyWith(
|
||||||
|
_$VerifyDtoImpl value,
|
||||||
|
$Res Function(_$VerifyDtoImpl) then,
|
||||||
|
) = __$$VerifyDtoImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({
|
||||||
|
@JsonKey(name: 'status') String? status,
|
||||||
|
@JsonKey(name: 'message') String? message,
|
||||||
|
@JsonKey(name: 'data') VerifyDataDto? data,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$VerifyDataDtoCopyWith<$Res>? get data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VerifyDtoImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyDtoCopyWithImpl<$Res, _$VerifyDtoImpl>
|
||||||
|
implements _$$VerifyDtoImplCopyWith<$Res> {
|
||||||
|
__$$VerifyDtoImplCopyWithImpl(
|
||||||
|
_$VerifyDtoImpl _value,
|
||||||
|
$Res Function(_$VerifyDtoImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? status = freezed,
|
||||||
|
Object? message = freezed,
|
||||||
|
Object? data = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(
|
||||||
|
_$VerifyDtoImpl(
|
||||||
|
status: freezed == status
|
||||||
|
? _value.status
|
||||||
|
: status // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
message: freezed == message
|
||||||
|
? _value.message
|
||||||
|
: message // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
data: freezed == data
|
||||||
|
? _value.data
|
||||||
|
: data // ignore: cast_nullable_to_non_nullable
|
||||||
|
as VerifyDataDto?,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$VerifyDtoImpl extends _VerifyDto {
|
||||||
|
const _$VerifyDtoImpl({
|
||||||
|
@JsonKey(name: 'status') this.status,
|
||||||
|
@JsonKey(name: 'message') this.message,
|
||||||
|
@JsonKey(name: 'data') this.data,
|
||||||
|
}) : super._();
|
||||||
|
|
||||||
|
factory _$VerifyDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$VerifyDtoImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'status')
|
||||||
|
final String? status;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'message')
|
||||||
|
final String? message;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'data')
|
||||||
|
final VerifyDataDto? data;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VerifyDto(status: $status, message: $message, data: $data)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VerifyDtoImpl &&
|
||||||
|
(identical(other.status, status) || other.status == status) &&
|
||||||
|
(identical(other.message, message) || other.message == message) &&
|
||||||
|
(identical(other.data, data) || other.data == data));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, status, message, data);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VerifyDtoImplCopyWith<_$VerifyDtoImpl> get copyWith =>
|
||||||
|
__$$VerifyDtoImplCopyWithImpl<_$VerifyDtoImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$VerifyDtoImplToJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _VerifyDto extends VerifyDto {
|
||||||
|
const factory _VerifyDto({
|
||||||
|
@JsonKey(name: 'status') final String? status,
|
||||||
|
@JsonKey(name: 'message') final String? message,
|
||||||
|
@JsonKey(name: 'data') final VerifyDataDto? data,
|
||||||
|
}) = _$VerifyDtoImpl;
|
||||||
|
const _VerifyDto._() : super._();
|
||||||
|
|
||||||
|
factory _VerifyDto.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$VerifyDtoImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'status')
|
||||||
|
String? get status;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'message')
|
||||||
|
String? get message;
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'data')
|
||||||
|
VerifyDataDto? get data;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$VerifyDtoImplCopyWith<_$VerifyDtoImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
VerifyDataDto _$VerifyDataDtoFromJson(Map<String, dynamic> json) {
|
||||||
|
return _VerifyDataDto.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$VerifyDataDto {
|
||||||
|
@JsonKey(name: 'registration_token')
|
||||||
|
String? get registrationToken => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Serializes this VerifyDataDto to a JSON map.
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDataDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
$VerifyDataDtoCopyWith<VerifyDataDto> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $VerifyDataDtoCopyWith<$Res> {
|
||||||
|
factory $VerifyDataDtoCopyWith(
|
||||||
|
VerifyDataDto value,
|
||||||
|
$Res Function(VerifyDataDto) then,
|
||||||
|
) = _$VerifyDataDtoCopyWithImpl<$Res, VerifyDataDto>;
|
||||||
|
@useResult
|
||||||
|
$Res call({@JsonKey(name: 'registration_token') String? registrationToken});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$VerifyDataDtoCopyWithImpl<$Res, $Val extends VerifyDataDto>
|
||||||
|
implements $VerifyDataDtoCopyWith<$Res> {
|
||||||
|
_$VerifyDataDtoCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDataDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({Object? registrationToken = freezed}) {
|
||||||
|
return _then(
|
||||||
|
_value.copyWith(
|
||||||
|
registrationToken: freezed == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
)
|
||||||
|
as $Val,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$VerifyDataDtoImplCopyWith<$Res>
|
||||||
|
implements $VerifyDataDtoCopyWith<$Res> {
|
||||||
|
factory _$$VerifyDataDtoImplCopyWith(
|
||||||
|
_$VerifyDataDtoImpl value,
|
||||||
|
$Res Function(_$VerifyDataDtoImpl) then,
|
||||||
|
) = __$$VerifyDataDtoImplCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({@JsonKey(name: 'registration_token') String? registrationToken});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$VerifyDataDtoImplCopyWithImpl<$Res>
|
||||||
|
extends _$VerifyDataDtoCopyWithImpl<$Res, _$VerifyDataDtoImpl>
|
||||||
|
implements _$$VerifyDataDtoImplCopyWith<$Res> {
|
||||||
|
__$$VerifyDataDtoImplCopyWithImpl(
|
||||||
|
_$VerifyDataDtoImpl _value,
|
||||||
|
$Res Function(_$VerifyDataDtoImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDataDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({Object? registrationToken = freezed}) {
|
||||||
|
return _then(
|
||||||
|
_$VerifyDataDtoImpl(
|
||||||
|
registrationToken: freezed == registrationToken
|
||||||
|
? _value.registrationToken
|
||||||
|
: registrationToken // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$VerifyDataDtoImpl implements _VerifyDataDto {
|
||||||
|
const _$VerifyDataDtoImpl({
|
||||||
|
@JsonKey(name: 'registration_token') this.registrationToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory _$VerifyDataDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$VerifyDataDtoImplFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'registration_token')
|
||||||
|
final String? registrationToken;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'VerifyDataDto(registrationToken: $registrationToken)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$VerifyDataDtoImpl &&
|
||||||
|
(identical(other.registrationToken, registrationToken) ||
|
||||||
|
other.registrationToken == registrationToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, registrationToken);
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDataDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$VerifyDataDtoImplCopyWith<_$VerifyDataDtoImpl> get copyWith =>
|
||||||
|
__$$VerifyDataDtoImplCopyWithImpl<_$VerifyDataDtoImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$VerifyDataDtoImplToJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _VerifyDataDto implements VerifyDataDto {
|
||||||
|
const factory _VerifyDataDto({
|
||||||
|
@JsonKey(name: 'registration_token') final String? registrationToken,
|
||||||
|
}) = _$VerifyDataDtoImpl;
|
||||||
|
|
||||||
|
factory _VerifyDataDto.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$VerifyDataDtoImpl.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: 'registration_token')
|
||||||
|
String? get registrationToken;
|
||||||
|
|
||||||
|
/// Create a copy of VerifyDataDto
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$VerifyDataDtoImplCopyWith<_$VerifyDataDtoImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@ -61,3 +61,27 @@ Map<String, dynamic> _$$RegisterDataDtoImplToJson(
|
|||||||
'otp_token': instance.otpToken,
|
'otp_token': instance.otpToken,
|
||||||
'expires_in': instance.expiresIn,
|
'expires_in': instance.expiresIn,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_$VerifyDtoImpl _$$VerifyDtoImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VerifyDtoImpl(
|
||||||
|
status: json['status'] as String?,
|
||||||
|
message: json['message'] as String?,
|
||||||
|
data: json['data'] == null
|
||||||
|
? null
|
||||||
|
: VerifyDataDto.fromJson(json['data'] as Map<String, dynamic>),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$VerifyDtoImplToJson(_$VerifyDtoImpl instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'status': instance.status,
|
||||||
|
'message': instance.message,
|
||||||
|
'data': instance.data,
|
||||||
|
};
|
||||||
|
|
||||||
|
_$VerifyDataDtoImpl _$$VerifyDataDtoImplFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VerifyDataDtoImpl(
|
||||||
|
registrationToken: json['registration_token'] as String?,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$VerifyDataDtoImplToJson(_$VerifyDataDtoImpl instance) =>
|
||||||
|
<String, dynamic>{'registration_token': instance.registrationToken};
|
||||||
|
|||||||
@ -96,4 +96,44 @@ class AuthRemoteDataProvider {
|
|||||||
return DC.error(AuthFailure.serverError(e));
|
return DC.error(AuthFailure.serverError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<DC<AuthFailure, VerifyDto>> verify({
|
||||||
|
required String registrationToken,
|
||||||
|
required String otpCode,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final response = await _apiClient.post(
|
||||||
|
ApiPath.verify,
|
||||||
|
data: {'registration_token': registrationToken, 'otp_code': otpCode},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.data['success'] == false) {
|
||||||
|
if ((response.data['errors'] as List).isNotEmpty) {
|
||||||
|
if (response.data['errors'][0]['code'] == "900") {
|
||||||
|
return DC.error(
|
||||||
|
AuthFailure.dynamicErrorMessage('Kode OTP Tidak Sesuai'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return DC.error(
|
||||||
|
AuthFailure.dynamicErrorMessage(
|
||||||
|
'Terjadi kesalahan coba lagi nanti',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return DC.error(
|
||||||
|
AuthFailure.dynamicErrorMessage(
|
||||||
|
'Terjadi kesalahan coba lagi nanti',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final dto = VerifyDto.fromJson(response.data['data']);
|
||||||
|
return DC.data(dto);
|
||||||
|
} on ApiFailure catch (e, s) {
|
||||||
|
log('verify', name: _logName, error: e, stackTrace: s);
|
||||||
|
return DC.error(AuthFailure.serverError(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
lib/infrastructure/auth/dto/verify_dto.dart
Normal file
32
lib/infrastructure/auth/dto/verify_dto.dart
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
part of '../auth_dtos.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class VerifyDto with _$VerifyDto {
|
||||||
|
const factory VerifyDto({
|
||||||
|
@JsonKey(name: 'status') String? status,
|
||||||
|
@JsonKey(name: 'message') String? message,
|
||||||
|
@JsonKey(name: 'data') VerifyDataDto? data,
|
||||||
|
}) = _VerifyDto;
|
||||||
|
|
||||||
|
factory VerifyDto.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VerifyDtoFromJson(json);
|
||||||
|
|
||||||
|
const VerifyDto._(); // biar bisa bikin method
|
||||||
|
|
||||||
|
/// mapping ke domain
|
||||||
|
Verify toDomain() => Verify(
|
||||||
|
status: status ?? '',
|
||||||
|
message: message ?? '',
|
||||||
|
registrationToken: data?.registrationToken ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class VerifyDataDto with _$VerifyDataDto {
|
||||||
|
const factory VerifyDataDto({
|
||||||
|
@JsonKey(name: 'registration_token') String? registrationToken,
|
||||||
|
}) = _VerifyDataDto;
|
||||||
|
|
||||||
|
factory VerifyDataDto.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$VerifyDataDtoFromJson(json);
|
||||||
|
}
|
||||||
@ -57,7 +57,31 @@ class AuthRepository implements IAuthRepository {
|
|||||||
|
|
||||||
return right(auth);
|
return right(auth);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
log('checkPhoneError', name: _logName, error: e, stackTrace: s);
|
log('registerError', name: _logName, error: e, stackTrace: s);
|
||||||
|
return left(const AuthFailure.unexpectedError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Either<AuthFailure, Verify>> verify({
|
||||||
|
required String registrationToken,
|
||||||
|
required String otpCode,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final result = await _remoteDataProvider.verify(
|
||||||
|
registrationToken: registrationToken,
|
||||||
|
otpCode: otpCode,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.hasError) {
|
||||||
|
return left(result.error!);
|
||||||
|
}
|
||||||
|
|
||||||
|
final auth = result.data!.toDomain();
|
||||||
|
|
||||||
|
return right(auth);
|
||||||
|
} catch (e, s) {
|
||||||
|
log('verifyError', name: _logName, error: e, stackTrace: s);
|
||||||
return left(const AuthFailure.unexpectedError());
|
return left(const AuthFailure.unexpectedError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import 'package:enaklo/application/auth/check_phone_form/check_phone_form_bloc.d
|
|||||||
as _i869;
|
as _i869;
|
||||||
import 'package:enaklo/application/auth/register_form/register_form_bloc.dart'
|
import 'package:enaklo/application/auth/register_form/register_form_bloc.dart'
|
||||||
as _i260;
|
as _i260;
|
||||||
|
import 'package:enaklo/application/auth/verify_form/verify_form_bloc.dart'
|
||||||
|
as _i521;
|
||||||
import 'package:enaklo/common/api/api_client.dart' as _i842;
|
import 'package:enaklo/common/api/api_client.dart' as _i842;
|
||||||
import 'package:enaklo/common/di/di_auto_route.dart' as _i619;
|
import 'package:enaklo/common/di/di_auto_route.dart' as _i619;
|
||||||
import 'package:enaklo/common/di/di_connectivity.dart' as _i644;
|
import 'package:enaklo/common/di/di_connectivity.dart' as _i644;
|
||||||
@ -73,6 +75,9 @@ extension GetItInjectableX on _i174.GetIt {
|
|||||||
gh.factory<_i260.RegisterFormBloc>(
|
gh.factory<_i260.RegisterFormBloc>(
|
||||||
() => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()),
|
() => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()),
|
||||||
);
|
);
|
||||||
|
gh.factory<_i521.VerifyFormBloc>(
|
||||||
|
() => _i521.VerifyFormBloc(gh<_i995.IAuthRepository>()),
|
||||||
|
);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user