const URL = "/one-api/mockup/masterdata/accounting/";

export async function getListing(prm) {
    try {
        var resp = await axios.post(URL + 'mdcategory/listcategory', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.message
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function gettype(token, prm) {
    try {
        var resp = await axios.post(URL + 'mdcategory/gettype', {
            token: token,
            search: prm
        });
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}

export async function deleteCategory(prm) {
    try {
        var resp = await axios.post(URL + 'mdcategory/deleteCategory', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: error.message
            };            
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function saveCategory(prm) {
    try {
        var resp = await axios.post(URL + 'mdcategory/addCategory', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: error.message
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function updateCategory(prm) {
    try {
        var resp = await axios.post(URL + 'mdcategory/editCategory', prm);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: error.message
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}