feat: Enhance attire verification status system with more granular states and update related UI and data handling.
This commit is contained in:
@@ -1,3 +1,43 @@
|
||||
/// Represents the possible statuses of a verification job.
|
||||
enum VerificationStatus {
|
||||
/// Job is created and waiting to be processed.
|
||||
pending('PENDING'),
|
||||
|
||||
/// Job is currently being processed by machine or human.
|
||||
processing('PROCESSING'),
|
||||
|
||||
/// Machine verification passed automatically.
|
||||
autoPass('AUTO_PASS'),
|
||||
|
||||
/// Machine verification failed automatically.
|
||||
autoFail('AUTO_FAIL'),
|
||||
|
||||
/// Machine results are inconclusive and require human review.
|
||||
needsReview('NEEDS_REVIEW'),
|
||||
|
||||
/// Human reviewer approved the verification.
|
||||
approved('APPROVED'),
|
||||
|
||||
/// Human reviewer rejected the verification.
|
||||
rejected('REJECTED'),
|
||||
|
||||
/// An error occurred during processing.
|
||||
error('ERROR');
|
||||
|
||||
const VerificationStatus(this.value);
|
||||
|
||||
/// The string value expected by the Core API.
|
||||
final String value;
|
||||
|
||||
/// Creates a [VerificationStatus] from a string.
|
||||
static VerificationStatus fromString(String value) {
|
||||
return VerificationStatus.values.firstWhere(
|
||||
(VerificationStatus e) => e.value == value,
|
||||
orElse: () => VerificationStatus.error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Response model for verification operations.
|
||||
class VerificationResponse {
|
||||
/// Creates a [VerificationResponse].
|
||||
@@ -13,7 +53,7 @@ class VerificationResponse {
|
||||
factory VerificationResponse.fromJson(Map<String, dynamic> json) {
|
||||
return VerificationResponse(
|
||||
verificationId: json['verificationId'] as String,
|
||||
status: json['status'] as String,
|
||||
status: VerificationStatus.fromString(json['status'] as String),
|
||||
type: json['type'] as String?,
|
||||
review: json['review'] != null
|
||||
? json['review'] as Map<String, dynamic>
|
||||
@@ -25,8 +65,8 @@ class VerificationResponse {
|
||||
/// The unique ID of the verification job.
|
||||
final String verificationId;
|
||||
|
||||
/// Current status (e.g., PENDING, PROCESSING, SUCCESS, FAILED, NEEDS_REVIEW).
|
||||
final String status;
|
||||
/// Current status of the verification.
|
||||
final VerificationStatus status;
|
||||
|
||||
/// The type of verification (e.g., attire, government_id).
|
||||
final String? type;
|
||||
@@ -41,7 +81,7 @@ class VerificationResponse {
|
||||
Map<String, dynamic> toJson() {
|
||||
return <String, dynamic>{
|
||||
'verificationId': verificationId,
|
||||
'status': status,
|
||||
'status': status.value,
|
||||
'type': type,
|
||||
'review': review,
|
||||
'requestId': requestId,
|
||||
|
||||
Reference in New Issue
Block a user