identityVerification method

Future<Map?> identityVerification(
  1. String id_type,
  2. String bvn
)

Implementation

Future<Map?> identityVerification(String id_type, String bvn) async {
  /// [id_type] e.g bvn
  Map data = {'id_type': id_type, 'id_number': bvn};
  String? client_id = iAmA == "consultant"
      ? Params.consultant_client_id
      : Params.patient_client_id;

  /*Calling the API url */
  var jsonData;
  final response = await http.post(
      Uri.parse(Params.base_url + "/accounts/identity/verify"),
      body: data,
      headers: {"Client-ID": "$client_id"});

  if (debug) {
    print('Status Code = ' +
        response.statusCode.toString() +
        ". Response: " +
        response.body);
  }

  /*If the response is 200 or 201 (success) then the response will be decoded */
  if (response.statusCode == 200 || response.statusCode == 201) {
    jsonData = json.decode(response.body);
    return {
      "id": jsonData["id"],
      "firstName": jsonData["firstName"],
      "lastName": jsonData["lastName"],
      "middleName": jsonData["middleName"],
      "dateOfBirth": jsonData["dateOfBirth"],
      "phoneNumber": jsonData["phoneNumber"],
      "otp": jsonData["otp"],
      "image": jsonData["image"],
      "isFirstNameMatch": jsonData["isFirstNameMatch"],
      "isLastNameMatch": jsonData["isLastNameMatch"],
      "isMiddleNameMatch": jsonData["isMiddleNameMatch"],
      "isDateOfBirthMatch": jsonData["isDateOfBirthMatch"],
      "isPhoneNumberMatch": jsonData["isPhoneNumberMatch"],
      "verificationRef": jsonData["verificationRef"]
    };
  } else {
    if (debug) print("Error Requesting API");
    return null;
  }
}