import { SmartechBaseProps } from "./smartechBaseProps";

const TAG = "SmartechBaseExpoPlugin";

export const validateSmartechProps = (props: SmartechBaseProps) => {

    // iOS
    if (typeof props.ios.appId === 'undefined') {
        throw new Error(`${TAG} iOS config property appId is required.`);
    }

    if (typeof props.ios.groupIdentifier === 'undefined') {
        throw new Error(`${TAG} iOS config property groupIdentifier is required.`);
    }

    if (typeof props.ios.autoFetchLocation === 'undefined') {
        throw new Error(`${TAG} iOS config property autoFetchLocation is required.`);
    }

    if (typeof props.ios.useAdvID === 'undefined') {
        throw new Error(`${TAG} iOS config property useAdvID is required.`);
    }

    if (typeof props.ios.isLogEnabled === 'undefined') {
        throw new Error(`${TAG} iOS config property areLogsEnabled is required.`);
    }

    // Android
    if (!Array.isArray(props.android.smartechMetaData)) {
        throw new Error(`${TAG} Android config property smartechMetaData is required.`);
    }

    if (typeof props.android.SMARTECH_BASE_SDK_VERSION === 'undefined') {
        throw new Error(`${TAG} Android config property SMARTECH_BASE_SDK_VERSION is required.`);
    }

    if (typeof props.android.isKotlinProject === 'undefined') {
        throw new Error(`${TAG} Android config property isKotlin is required.`);
    }
    
    if (typeof props.android.isLogEnabled === 'undefined') {
        throw new Error(`${TAG} Android config property areLogsEnabled is required.`);
    }
}

