11package com .regula .documentreader ;
22
3+ import static com .regula .documentreader .api .completions .IRfidNotificationCompletion .RFID_EXTRA_ERROR_CODE ;
4+
35import android .content .Context ;
46import android .graphics .Bitmap ;
57import android .graphics .BitmapFactory ;
68import android .graphics .Rect ;
9+ import android .os .Bundle ;
710import android .util .Base64 ;
811
912import com .regula .documentreader .api .enums .DocReaderAction ;
1013import com .regula .documentreader .api .enums .PDF417Info ;
1114import com .regula .documentreader .api .enums .eGraphicFieldType ;
1215import com .regula .documentreader .api .enums .eRPRM_Lights ;
1316import com .regula .documentreader .api .errors .DocumentReaderException ;
17+ import com .regula .documentreader .api .internal .core .CoreDetailedScenario ;
1418import com .regula .documentreader .api .params .FaceMetaData ;
1519import com .regula .documentreader .api .params .rfid .authorization .PAAttribute ;
1620import com .regula .documentreader .api .params .rfid .authorization .PAResourcesIssuer ;
1721import com .regula .documentreader .api .params .rfid .authorization .TAChallenge ;
1822import com .regula .documentreader .api .results .Bounds ;
23+ import com .regula .documentreader .api .results .BytesData ;
1924import com .regula .documentreader .api .results .Coordinate ;
2025import com .regula .documentreader .api .results .DocReaderFieldRect ;
2126import com .regula .documentreader .api .results .DocumentReaderBarcodeField ;
2530import com .regula .documentreader .api .results .DocumentReaderGraphicResult ;
2631import com .regula .documentreader .api .results .DocumentReaderNotification ;
2732import com .regula .documentreader .api .results .DocumentReaderResults ;
33+ import com .regula .documentreader .api .results .DocumentReaderResultsStatus ;
2834import com .regula .documentreader .api .results .DocumentReaderScenario ;
29- import com .regula .documentreader .api .results .DocumentReaderScenarioFull ;
3035import com .regula .documentreader .api .results .DocumentReaderTextField ;
3136import com .regula .documentreader .api .results .DocumentReaderTextResult ;
3237import com .regula .documentreader .api .results .DocumentReaderValue ;
3338import com .regula .documentreader .api .results .ElementPosition ;
3439import com .regula .documentreader .api .results .ImageQuality ;
3540import com .regula .documentreader .api .results .ImageQualityGroup ;
41+ import com .regula .documentreader .api .results .VDSNCData ;
3642import com .regula .documentreader .api .results .authenticity .DocumentReaderAuthenticityCheck ;
3743import com .regula .documentreader .api .results .authenticity .DocumentReaderAuthenticityElement ;
3844import com .regula .documentreader .api .results .authenticity .DocumentReaderAuthenticityResult ;
@@ -294,6 +300,18 @@ static JSONObject generateCompletion(int action, DocumentReaderResults results,
294300 return result ;
295301 }
296302
303+ static JSONObject generateRfidNotificationCompletion (int notification , Bundle value ) {
304+ JSONObject result = new JSONObject ();
305+ try {
306+ result .put ("notification" , notification );
307+ if (value != null )
308+ result .put ("value" , value .get (RFID_EXTRA_ERROR_CODE ));
309+ } catch (JSONException ignored ) {
310+ }
311+
312+ return result ;
313+ }
314+
297315 static JSONObject generatePACertificateCompletion (byte [] serialNumber , PAResourcesIssuer issuer ) {
298316 JSONObject result = new JSONObject ();
299317 try {
@@ -335,8 +353,6 @@ static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
335353 JSONObject result = new JSONObject ();
336354 if (input == null ) return result ;
337355 try {
338- result .put ("uvTorch" , input .uvTorch );
339- result .put ("seriesProcessMode" , input .seriesProcessMode );
340356 result .put ("name" , input .name );
341357 result .put ("caption" , input .caption );
342358 result .put ("description" , input .description );
@@ -346,7 +362,7 @@ static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
346362 return result ;
347363 }
348364
349- static JSONObject generateDocumentReaderScenarioFull ( DocumentReaderScenarioFull input ) {
365+ static JSONObject generateCoreDetailedScenario ( CoreDetailedScenario input ) {
350366 JSONObject result = new JSONObject ();
351367 if (input == null ) return result ;
352368 try {
@@ -1039,6 +1055,92 @@ static JSONObject generateTAChallenge(TAChallenge input) {
10391055 return result ;
10401056 }
10411057
1058+ static JSONObject generateDocumentReaderResultsStatus (DocumentReaderResultsStatus input ) {
1059+ JSONObject result = new JSONObject ();
1060+ if (input == null ) return result ;
1061+ try {
1062+ result .put ("overallStatus" , input .getOverallStatus ());
1063+ result .put ("optical" , input .getOptical ());
1064+ result .put ("detailsOptical" , generateDetailsOptical (input .getDetailsOptical ()));
1065+ result .put ("rfid" , input .getRfid ());
1066+ result .put ("detailsRFID" , generateDetailsRFID (input .getDetailsRFID ()));
1067+ result .put ("portrait" , input .getPortrait ());
1068+ result .put ("stopList" , input .getStopList ());
1069+ } catch (JSONException e ) {
1070+ e .printStackTrace ();
1071+ }
1072+ return result ;
1073+ }
1074+
1075+ static JSONObject generateDetailsOptical (DocumentReaderResultsStatus .DetailsOptical input ) {
1076+ JSONObject result = new JSONObject ();
1077+ if (input == null ) return result ;
1078+ try {
1079+ result .put ("overallStatus" , input .getOverallStatus ());
1080+ result .put ("mrz" , input .getMrz ());
1081+ result .put ("text" , input .getText ());
1082+ result .put ("docType" , input .getDocType ());
1083+ result .put ("security" , input .getSecurity ());
1084+ result .put ("imageQA" , input .getImageQA ());
1085+ result .put ("expiry" , input .getExpiry ());
1086+ result .put ("vds" , input .getVds ());
1087+ result .put ("pagesCount" , input .getPagesCount ());
1088+ } catch (JSONException e ) {
1089+ e .printStackTrace ();
1090+ }
1091+ return result ;
1092+ }
1093+
1094+ static JSONObject generateDetailsRFID (DocumentReaderResultsStatus .DetailsRFID input ) {
1095+ JSONObject result = new JSONObject ();
1096+ if (input == null ) return result ;
1097+ try {
1098+ result .put ("pa" , input .getPA ());
1099+ result .put ("ca" , input .getCA ());
1100+ result .put ("aa" , input .getAA ());
1101+ result .put ("ta" , input .getTA ());
1102+ result .put ("bac" , input .getBAC ());
1103+ result .put ("pace" , input .getPACE ());
1104+ result .put ("overallStatus" , input .getOverallStatus ());
1105+ } catch (JSONException e ) {
1106+ e .printStackTrace ();
1107+ }
1108+ return result ;
1109+ }
1110+
1111+ static JSONObject generateVDSNCData (VDSNCData input ) {
1112+ JSONObject result = new JSONObject ();
1113+ if (input == null ) return result ;
1114+ try {
1115+ result .put ("type" , input .getType ());
1116+ result .put ("version" , input .getVersion ());
1117+ result .put ("issuingCountry" , input .getIssuingCountry ());
1118+ result .put ("message" , input .getMessage ());
1119+ result .put ("signatureAlgorithm" , input .getSignatureAlg ());
1120+ result .put ("signature" , generateBytesData (input .getSignature ()));
1121+ result .put ("certificate" , generateBytesData (input .getCertificate ()));
1122+ result .put ("certificateChain" , generateList (input .getCertificateChain (), JSONConstructor ::generateCertificateChain ));
1123+ result .put ("notifications" , generateLongArray (input .getNotifications ()));
1124+ } catch (JSONException e ) {
1125+ e .printStackTrace ();
1126+ }
1127+ return result ;
1128+ }
1129+
1130+ static JSONObject generateBytesData (BytesData input ) {
1131+ JSONObject result = new JSONObject ();
1132+ if (input == null ) return result ;
1133+ try {
1134+ result .put ("data" , input .getData ());
1135+ result .put ("length" , input .getLength ());
1136+ result .put ("status" , input .getStatus ());
1137+ result .put ("type" , input .getType ());
1138+ } catch (JSONException e ) {
1139+ e .printStackTrace ();
1140+ }
1141+ return result ;
1142+ }
1143+
10421144 static JSONObject generateDocumentReaderResults (DocumentReaderResults input , Context context ) {
10431145 JSONObject result = new JSONObject ();
10441146 if (input == null ) return result ;
@@ -1063,6 +1165,8 @@ static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Con
10631165 result .put ("authenticityResult" , generateDocumentReaderAuthenticityResult (input .authenticityResult , context ));
10641166 result .put ("barcodeResult" , generateDocumentReaderBarcodeResult (input .barcodeResult ));
10651167 result .put ("documentType" , generateList (input .documentType , JSONConstructor ::generateDocumentReaderDocumentType ));
1168+ result .put ("status" , generateDocumentReaderResultsStatus (input .status ));
1169+ result .put ("vdsncData" , generateVDSNCData (input .vdsncData ));
10661170 } catch (JSONException e ) {
10671171 e .printStackTrace ();
10681172 }
@@ -1074,10 +1178,6 @@ static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Con
10741178 static DocumentReaderScenario DocumentReaderScenarioFromJSON (JSONObject input ) {
10751179 try {
10761180 DocumentReaderScenario result = new DocumentReaderScenario ();
1077- if (input .has ("uvTorch" ))
1078- result .uvTorch = input .getBoolean ("uvTorch" );
1079- if (input .has ("seriesProcessMode" ))
1080- result .seriesProcessMode = input .getBoolean ("seriesProcessMode" );
10811181 if (input .has ("name" ))
10821182 result .name = input .getString ("name" );
10831183 if (input .has ("caption" ))
@@ -1091,9 +1191,9 @@ static DocumentReaderScenario DocumentReaderScenarioFromJSON(JSONObject input) {
10911191 return null ;
10921192 }
10931193
1094- static DocumentReaderScenarioFull DocumentReaderScenarioFullFromJSON (JSONObject input ) {
1194+ static CoreDetailedScenario CoreDetailedScenarioFromJSON (JSONObject input ) {
10951195 try {
1096- DocumentReaderScenarioFull result = new DocumentReaderScenarioFull ();
1196+ CoreDetailedScenario result = new CoreDetailedScenario ();
10971197 if (input .has ("uvTorch" ))
10981198 result .uvTorch = input .getBoolean ("uvTorch" );
10991199 if (input .has ("frameOrientation" ))
0 commit comments