Skip to content

Instantly share code, notes, and snippets.

@definev
Created November 21, 2022 10:40
Show Gist options
  • Select an option

  • Save definev/c5f6fa1f438a412a8532ead68ae8cd5b to your computer and use it in GitHub Desktop.

Select an option

Save definev/c5f6fa1f438a412a8532ead68ae8cd5b to your computer and use it in GitHub Desktop.
import 'package:goopay/src/_internal/ekyc/hapi_ekyc.dart';
EkycResult result(Map<String, dynamic> json) {
dynamic object = json['object'];
dynamic address = object['post_code'].firstWhere(
(element) => element.type == 'address',
orElse: () => object['post_code'][0],
);
if (object['id_fake_warning'] == 'yes') {
return EkycResult(
isSuccess: false,
data: null,
errorMessage: 'ID fake',
);
}
if (object['expire_warning'] == 'yes') {
return EkycResult(
isSuccess: false,
data: null,
errorMessage: 'ID expired',
);
}
if (object['back_expire_warning'] == 'yes') {
return EkycResult(
isSuccess: false,
data: null,
errorMessage: 'ID back expired',
);
}
dynamic addressObject =
object['card_type'].toUpperCase() == 'CĂN CƯỚC CÔNG DÂN'
? object['recent_location']!.split('\n').join(' ')
: object['recent_location_label']!.split('\n').join(' ');
return EkycResult(
isSuccess: true,
data: HapiEkycData(
name: object['name'],
dob: object['birth_day'],
province: address['city'][1],
district: address['district'][1],
ward: address['ward'][1],
citizenId: object['id'],
issueBy: object['issue_place']?.split('\n')?.join(' ') ?? '',
issueDate: object['issue_date'],
address: (addressObject == null) ? '' : addressObject.toString(),
gender: object['gender'],
prob: object['prob']?.toDouble() ?? 80.0,
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment