mapData method

  1. @override
Future<Either<VerificationFailure, Map<String, dynamic>>> mapData(
  1. Map<String, dynamic> idInfo,
  2. String faceMatch,
  3. String document,
  4. String nationality,
  5. String faceImage,
  6. String idFrontImage,
  7. String idBackImage,
  8. String idSideImage,
  9. String apiKey,
  10. String verificationSessionId,
  11. String accessToken,
)
override

Implementation

@override
Future<Either<VerificationFailure, Map<String, dynamic>>> mapData(
    Map<String, dynamic> idInfo,
    String faceMatch,
    String document,
    String nationality,
    String faceImage,
    String idFrontImage,
    String idBackImage,
    String idSideImage,
    String apiKey,
    String verificationSessionId,
    String accessToken,) async {
  try {
    Map<String, dynamic> result = Map<String, dynamic>.from(idInfo);

    var transaltedNationality = await translate(
        checkNull(idInfo["nationalityFull"]), apiKey, accessToken);

    result["frontImages"] = idFrontImage;
    result["backImages"] = idBackImage;
    result["sideImages"] = idSideImage;
    result["selfieImages"] = faceImage;
    result["faceMatch"] = faceMatch.toString();
    result["document"] = document.toString();
    result["nationality"] = nationality.toString();
    result["documentNumber"] = checkNull(idInfo["documentNumber"]);
    result["firstName"] = checkNull(idInfo["firstName"]);
    result["middleName"] = checkNull(idInfo["middleName"]);
    result["lastName"] = checkNull(idInfo["lastName"]);
    result["fullName"] = checkNull(idInfo["fullName"]);
    result["gender"] = checkNull(idInfo["sex"]);
    result["dob"] = checkNull(idInfo["dob"].toString());
    result["dob_day"] = checkNull(idInfo["dobDay"].toString());
    result["dob_month"] = checkNull(idInfo["dobMonth"].toString());
    result["dob_year"] = checkNull(idInfo["dobYear"].toString());
    result["expiry"] = checkNull(idInfo["expiry"].toString());
    result["expiry_day"] = checkNull(idInfo["expiryDay"].toString());
    result["expiry_month"] = checkNull(idInfo["expiryMonth"].toString());
    result["expiry_year"] = checkNull(idInfo["expiryYear"].toString());
    result["address1"] = checkNull(idInfo['address1']);
    result["addressEn"] = checkNull(idInfo["addressEn"]);
    result["addressJa"] = checkNull(idInfo["addressJa"]);
    result["address1Ja"] = checkNull(idInfo["address1Ja"]);
    result["address2Ja"] = checkNull(idInfo["address2Ja"]);
    result["address3Ja"] = checkNull(idInfo["address3Ja"]);
    result["address1En"] = checkNull(idInfo["address1En"]);
    result["address2En"] = checkNull(idInfo["address2En"]);
    result["address3En"] = checkNull(idInfo["address3En"]);
    result["postalCode"] = checkNull(idInfo["postalCode"].toString());
    result["age"] = checkNull(idInfo["age"].toString());
    result["documentType"] = checkNull(idInfo["documentType"]);
    result["documentSide"] = checkNull(idInfo["documentSide"]);
    result["issueAuthority"] = checkNull(idInfo["issueAuthority"]);
    result["issuerOrg_full"] = checkNull(idInfo["issuerOrgFull"]);
    result["issuerOrg_iso2"] = checkNull(idInfo["issuerOrgIso2"]);
    result["issuerOrg_iso3"] = checkNull(idInfo["issuerOrgIso3"]);
    result["nationality_full"] = transaltedNationality;
    result["nationality_iso2"] = checkNull(idInfo["nationalityIso2"]);
    result["nationality_iso3"] = checkNull(idInfo["nationalityIso3"]);
    result["internalId"] = checkNull(idInfo["internalId"].toString());
    result["issued"] = checkNull(idInfo["issued"].toString());
    result["issued_day"] = checkNull(idInfo["issuedDay"].toString());
    result["issued_month"] = checkNull(idInfo["issuedMonth"].toString());
    result["issued_year"] = checkNull(idInfo["issuedYear"].toString());
    result["daysFromIssue"] = checkNull(idInfo["daysFromIssue"].toString());
    result["documentIdentificationId"] = verificationSessionId;

    if (kDebugMode) {
      print(result);
    }

    return right({"code": "1", "message": "success", "data": result});
  } catch (error) {
    if (kDebugMode) {
      print(error);
    }
    return left(const VerificationFailure.serverError(
        "Something went wrong, try again!"));
  }
}