
import { NativeModules, Platform } from "react-native";
import { APIResponse } from "./constants/APIResponse";

const { MPosLookupProxy } = NativeModules

export class MPosLookup {

    private readonly isWindows: boolean;

    constructor() {
        this.isWindows = Platform.OS === 'windows';
    }

    async getNetworkDevices(): Promise<string> {
        try {
            return await MPosLookupProxy.getNetworkDevices();
        } catch (e) {
            return "[]";
        }
    }

    async getBluetoothDevices(): Promise<string> {
        try {
            return await MPosLookupProxy.getBluetoothDevices();
        } catch (e) {
            return "[]";
        }
    }

    async getBLEDevices(): Promise<string> {
        try {
            return await MPosLookupProxy.getBLEDevices();
        } catch (e) {
            return "[]";
        }
    }

    async getUSBDevices(): Promise<string> {
        if (Platform.OS === 'android' || Platform.OS === 'ios') {
            try {
                return await MPosLookupProxy.getUSBDevices();
            } catch (e) {
                return "[]";
            }
        }
        return "[]";
    }
}