package com.regula.documentreader;

import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableArray;
import com.regula.documentreader.api.DocumentReader;
import com.regula.documentreader.api.params.ProcessParam;
import com.regula.documentreader.api.params.RfidScenario;
import com.regula.documentreader.api.params.DataGroups;

public class RfidScenarioAdapter {

    public static void setRfidScenario(RfidScenario rfidScenario, ReadableMap opts) {
        if(rfidScenario == null){
            rfidScenario = new RfidScenario();
        }
        if (opts.hasKey("signManagementAction")) {
            rfidScenario.signManagementAction = opts.getInt("signManagementAction");
        }
        if (opts.hasKey("readingBuffer")) {
            rfidScenario.readingBuffer = opts.getInt("readingBuffer");
        }
        if (opts.hasKey("onlineTAToSignDataType")) {
            rfidScenario.onlineTAToSignDataType = opts.getInt("onlineTAToSignDataType");
        }
        if (opts.hasKey("onlineTA")) {
            rfidScenario.onlineTA = opts.getBoolean("onlineTA");
        }
        if (opts.hasKey("writeEid")) {
            rfidScenario.writeEid = opts.getBoolean("writeEid");
        }
        if (opts.hasKey("profilerType")) {
            rfidScenario.profilerType = opts.getInt("profilerType");
        }
        if (opts.hasKey("authProcType")) {
            rfidScenario.authProcType = opts.getInt("authProcType");
        }
        if (opts.hasKey("baseSMProcedure")) {
            rfidScenario.baseSMProcedure = opts.getInt("baseSMProcedure");
        }
        if (opts.hasKey("pacePasswordType")) {
            rfidScenario.pacePasswordType = opts.getInt("pacePasswordType");
        }
        if (opts.hasKey("terminalType")) {
            rfidScenario.terminalType = opts.getInt("terminalType");
        }
        if (opts.hasKey("universalAccessRights")) {
            rfidScenario.universalAccessRights = opts.getBoolean("universalAccessRights");
        }
        if (opts.hasKey("authorizedRestrictedIdentification")) {
            rfidScenario.authorizedRestrictedIdentification = opts.getBoolean("authorizedRestrictedIdentification");
        }
        if (opts.hasKey("auxVerificationCommunityID")) {
            rfidScenario.auxVerificationCommunityID = opts.getBoolean("auxVerificationCommunityID");
        }
        if (opts.hasKey("auxVerificationDateOfBirth")) {
            rfidScenario.auxVerificationDateOfBirth = opts.getBoolean("auxVerificationDateOfBirth");
        }
        if (opts.hasKey("skipAA")) {
            rfidScenario.skipAA = opts.getBoolean("skipAA");
        }
        if (opts.hasKey("strictProcessing")) {
            rfidScenario.strictProcessing = opts.getBoolean("strictProcessing");
        }
        if (opts.hasKey("pkdDSCertPriority")) {
            rfidScenario.pkdDSCertPriority = opts.getBoolean("pkdDSCertPriority");
        }
        if (opts.hasKey("pkdUseExternalCSCA")) {
            rfidScenario.pkdUseExternalCSCA = opts.getBoolean("pkdUseExternalCSCA");
        }
        if (opts.hasKey("trustedPKD")) {
            rfidScenario.trustedPKD = opts.getBoolean("trustedPKD");
        }
        if (opts.hasKey("passiveAuth")) {
            rfidScenario.passiveAuth = opts.getBoolean("passiveAuth");
        }
        if (opts.hasKey("paceStaticBinding")) {
            rfidScenario.paceStaticBinding = opts.getBoolean("paceStaticBinding");
        }
        if (opts.hasKey("password")) {
            rfidScenario.password = opts.getString("password");
        }
        if (opts.hasKey("useSFI")) {
            rfidScenario.useSFI = opts.getBoolean("useSFI");
        }
        if (opts.hasKey("pkdPA")) {
            rfidScenario.pkdPA = opts.getString("pkdPA");
        }
        if (opts.hasKey("pkdEAC")) {
            rfidScenario.pkdEAC = opts.getString("pkdEAC");
        }
        if (opts.hasKey("readEPassport")) {
            rfidScenario.readEPassport = opts.getBoolean("readEPassport");
        }
        if (opts.hasKey("readEID")) {
            rfidScenario.readEID = opts.getBoolean("readEID");
        }
        if (opts.hasKey("readEDL")) {
            rfidScenario.readEDL = opts.getBoolean("readEDL");
        }
        if (opts.hasKey("dataGroups")) {
            setDataGroups(rfidScenario.dataGroups, opts.getMap("dataGroups"));
        }
        if (opts.hasKey("mrz")) {
            rfidScenario.mrz = opts.getString("mrz");
        }
        if (opts.hasKey("eSignPINDefault")) {
            rfidScenario.eSignPINDefault = opts.getString("eSignPINDefault");
        }
        if (opts.hasKey("eSignPINNewValue")) {
            rfidScenario.eSignPINNewValue = opts.getString("eSignPINNewValue");
        }
        if (opts.hasKey("authorizedSTSignature")) {
            rfidScenario.authorizedSTSignature = opts.getBoolean("authorizedSTSignature");
        }
        if (opts.hasKey("authorizedSTQSignature")) {
            rfidScenario.authorizedSTQSignature = opts.getBoolean("authorizedSTQSignature");
        }
        if (opts.hasKey("authorizedWriteDG17")) {
            rfidScenario.authorizedWriteDG17 = opts.getBoolean("authorizedWriteDG17");
        }
        if (opts.hasKey("authorizedWriteDG18")) {
            rfidScenario.authorizedWriteDG18 = opts.getBoolean("authorizedWriteDG18");
        }
        if (opts.hasKey("authorizedWriteDG19")) {
            rfidScenario.authorizedWriteDG19 = opts.getBoolean("authorizedWriteDG19");
        }
        if (opts.hasKey("authorizedWriteDG20")) {
            rfidScenario.authorizedWriteDG20 = opts.getBoolean("authorizedWriteDG20");
        }
        if (opts.hasKey("authorizedWriteDG21")) {
            rfidScenario.authorizedWriteDG21 = opts.getBoolean("authorizedWriteDG21");
        }
        if (opts.hasKey("authorizedVerifyAge")) {
            rfidScenario.authorizedVerifyAge = opts.getBoolean("authorizedVerifyAge");
        }
        if (opts.hasKey("authorizedVerifyCommunityID")) {
            rfidScenario.authorizedVerifyCommunityID = opts.getBoolean("authorizedVerifyCommunityID");
        }
        if (opts.hasKey("authorizedPrivilegedTerminal")) {
            rfidScenario.authorizedPrivilegedTerminal = opts.getBoolean("authorizedPrivilegedTerminal");
        }
        if (opts.hasKey("authorizedCANAllowed")) {
            rfidScenario.authorizedCANAllowed = opts.getBoolean("authorizedCANAllowed");
        }
        if (opts.hasKey("authorizedPINManagment")) {
            rfidScenario.authorizedPINManagment = opts.getBoolean("authorizedPINManagment");
        }
        if (opts.hasKey("authorizedInstallCert")) {
            rfidScenario.authorizedInstallCert = opts.getBoolean("authorizedInstallCert");
        }
        if (opts.hasKey("authorizedInstallQCert")) {
            rfidScenario.authorizedInstallQCert = opts.getBoolean("authorizedInstallQCert");
        }
    }

    public static void setDataGroups(DataGroups dataGroups, ReadableMap opts) {
        if (opts.hasKey("dG1")) {
            dataGroups.dG1 = opts.getBoolean("dG1");
        }
        if (opts.hasKey("dG2")) {
            dataGroups.dG2 = opts.getBoolean("dG2");
        }
        if (opts.hasKey("dG3")) {
            dataGroups.dG3 = opts.getBoolean("dG3");
        }
        if (opts.hasKey("dG4")) {
            dataGroups.dG4 = opts.getBoolean("dG4");
        }
        if (opts.hasKey("dG5")) {
            dataGroups.dG5 = opts.getBoolean("dG5");
        }
        if (opts.hasKey("dG6")) {
            dataGroups.dG6 = opts.getBoolean("dG6");
        }
        if (opts.hasKey("dG7")) {
            dataGroups.dG7 = opts.getBoolean("dG7");
        }
        if (opts.hasKey("dG8")) {
            dataGroups.dG8 = opts.getBoolean("dG8");
        }
        if (opts.hasKey("dG9")) {
            dataGroups.dG9 = opts.getBoolean("dG9");
        }
        if (opts.hasKey("dG10")) {
            dataGroups.dG10 = opts.getBoolean("dG10");
        }
        if (opts.hasKey("dG11")) {
            dataGroups.dG11 = opts.getBoolean("dG11");
        }
        if (opts.hasKey("dG12")) {
            dataGroups.dG12 = opts.getBoolean("dG12");
        }
        if (opts.hasKey("dG13")) {
            dataGroups.dG13 = opts.getBoolean("dG13");
        }
        if (opts.hasKey("dG14")) {
            dataGroups.dG14 = opts.getBoolean("dG14");
        }
        if (opts.hasKey("dG15")) {
            dataGroups.dG15 = opts.getBoolean("dG15");
        }
        if (opts.hasKey("dG16")) {
            dataGroups.dG16 = opts.getBoolean("dG16");
        }
    }

}