package kz.com.aman.kassa.bank;

import kz.com.aman.kassa.BuildConfig;
import ru.m4bank.mpos.service.commons.utils.VirtualDeviceUtils;
import ru.m4bank.mpos.service.data.dynamic.objects.DeviceType;

public class DeviceTypeDefiner {
    public DeviceType define() {
        if (VirtualDeviceUtils.isDevice()) {
            return DeviceType.SMART_POS;
        }

        String[] supportedDevices = BuildConfig.SUPPORTED_DEVICES;
        if (containsIgnoreCase(supportedDevices, "SoftPos")) {
            return DeviceType.SOFT_POS;
        }

        return DeviceType.PHONE;
    }

    private boolean containsIgnoreCase(String[] array, String checkValue) {
        for (String arrayValue : array) {
            if (arrayValue.equalsIgnoreCase(checkValue)) {
                return true;
            }
        }
        return false;
    }
}
