const URL = "/one-api/mockup/purchase/faktur/Fakturv4/";

export async function CreateFaktur(params) {
    try {
        var resp = await axios.post(URL + "CreateFaktur", params)
        if (resp.status !== 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }

        let data = resp.data
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function UpdateFaktur(params) {
    try {
        var resp = await axios.post(URL + "UpdateFaktur", params)
        if (resp.status !== 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }

        let data = resp.data
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function DeleteFaktur(params) {
    try {
        var resp = await axios.post(URL + "DeleteFaktur", params)
        if (resp.status !== 200) {
            return {
                status: "ERR",
                message: resp.statusText
            }
        }

        let data = resp.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function ApproveFaktur(params) {
    try {
        var resp = await axios.post(URL + "ApproveFaktur", params)
        if (resp.status !== 200) {
            return {
                status: "ERR",
                message: resp.statusText
            }
        }

        let data = resp.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function RejectFaktur(params) {
    try {
        let resp = await axios.post(URL + "RejectFaktur", params)
        if (resp.status !== 200) {
            return {
                status: 'ERR',
                message: resp.statusText
            }
        }

        let data = resp.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}

export async function VerifyFaktur(params) {
    try {
        let resp = await axios.post(URL + "VerifyFaktur", params)
        if (resp.status !== 200) {
            return {
                status: 'ERR',
                message: resp.statusText
            }
        }

        let data = resp.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        }
    }
}