let instance;
const instanceKey = 'data_392994';
import { fetchData } from "../Utils/Fetch";

class AppData {

    _attribute_url;
    _category_url;
    _tag_url;
    _product_url;
    _process_id;

    constructor(key) {
        if (key !== instanceKey) {
            throw new Error('Cannot instantiate like this');
        }
    }

    async populate() {
        const response = await fetchData('index', 'GET');
        this._attribute_url = response?.data?.data?.attribute_url || null;
        this._category_url = response?.data?.data?.category_url || null;
        this._tag_url = response?.data?.data?.tag_url || null;
        this._product_url = response?.data?.data?.product_url || null;
        this._process_id = response?.data?.data?.process_id || null;

    }

    getRestUrl() {
        return `${window?.FuseCommerceSearch.rest_url}`;
    }

    static getInstance() {
        if (!instance) {
            instance = new AppData(instanceKey);
        }
        return instance;
    }
}
export default AppData;