Created
November 21, 2022 10:40
-
-
Save definev/c5f6fa1f438a412a8532ead68ae8cd5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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