verify repo

This commit is contained in:
efrilm
2025-09-18 06:38:50 +07:00
parent 13c55afe3c
commit c40f96fc88
16 changed files with 1547 additions and 1 deletions
@@ -96,4 +96,44 @@ class AuthRemoteDataProvider {
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));
}
}
}