import { ApiHelper } from '/js/util/api.js';
import { UJ } from '/js/util/uj.js';

export const OemDataService = {
    GetMarketAndCategoryAndFreightType: async function () {
        return (await ApiHelper.sendRequest('/api/Oem/GetMarketAndCategoryAndFreightType', "GET")).data;
    },
    GetProductCategory: async function (marketId, parentId) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetProductCategory?marketId=${marketId}&parentId=${parentId}`, "GET")).data;
    },
    GetOemMarketList: async function () {
        return (await ApiHelper.sendRequest('/api/Oem/GetOemMarketList', "GET")).data;
    },
    GetProduct: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetProduct?id=${id}`, "GET"));
    },
    IsAuthModifyOrder: async function () {
        return (await ApiHelper.sendRequest('/api/Oem/IsAuthModifyOrder', "GET")).data;
    },
    IsAuthModifyProduct: async function () {
        return (await ApiHelper.sendRequest('/api/Oem/IsAuthModifyProduct', "GET")).data;
    },
    IsAuthModifyStock: async function () {
        return (await ApiHelper.sendRequest('/api/Oem/IsAuthModifyStock', "GET")).data;
    },
    IsAuthModifyStockRepairing: async function () {
        return (await ApiHelper.sendRequest('/api/Oem/IsAuthModifyStockRepairing', "GET")).data;
    },
    GetByBarcode: async function (barcode) {
        return await ApiHelper.sendRequest(`/api/Oem/GetByBarcode?barcode=${barcode}`, "GET");
    },
    GetOrder: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetOrder?id=${id}`, "GET"));
    },
    GetRecycleOrder: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetRecycleOrder?id=${id}`, "GET"));
    },
    GetPackingByOrderId: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetPackingByOrderId?id=${id}`, "GET")).data;
    },
    CreateRecycle: async function (data) {
        return await ApiHelper.sendRequest('/api/Oem/CreateRecycle', "POST", data);
    },
    GetRecycle: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetRecycle?id=${id}`, "GET"));
    },
    UpdateRecycle: async function (data) {
        return await ApiHelper.sendRequest('/api/Oem/UpdateRecycle', 'PATCH', data);
    },
    HandleRecycleFreightage: async function (data) {
        return await ApiHelper.sendRequest('/api/Oem/HandleRecycleFreightage', "POST", data);
    },
    DeleteRecycle: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/DeleteRecycle?id=${id}`, "DELETE"));
    },
    GetStockItrm: async function (id) {
        return (await ApiHelper.sendRequest(`/api/Oem/GetStockItrm?id=${id}`, "GET"));
    },
    GetStockHistory: async function (queryData) {
        let api = '/api/Oem/GetStockHistory';
        api = UJ.BindQueryString(api, queryData);
        return (await ApiHelper.sendRequest(api, "GET"));
    },
    GetPendingStock: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetPendingStock', "POST", queryData);
    },
    ConfirmStock: async function (stockId) {
        return (await ApiHelper.sendRequest(`/api/Oem/ConfirmStock?stockId=${stockId}`, "GET"));
    },
    GetShipmentBill: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetShipmentBill', "POST", queryData);
    },
    GetCleanBill: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetCleanBill', "POST", queryData);
    },
    GetRepairBill: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetRepairBill', "POST", queryData);
    },
    UpdateVerified: async function (data) {
        return await ApiHelper.sendRequest('/api/Oem/UpdateVerified', 'PATCH', data);
    },
    RestoreVerified: async function (data) {
        return await ApiHelper.sendRequest('/api/Oem/RestoreVerified', 'PATCH', data);
    },
    GetShipmentBillInvoice: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetShipmentBillInvoice', "POST", queryData);
    },
    GetCleanBillInvoice: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetCleanBillInvoice', "POST", queryData);
    },
    GetRepairBillInvoice: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetRepairBillInvoice', "POST", queryData);
    },
    ExportBill: async function (exportData) {
        return await ApiHelper.sendRequest('/api/Oem/ExportBill', "POST", exportData);
    },
    //輔具清消維修記錄
    GetRepairHistory: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetRepairHistory', "POST", queryData);
    },
    ExportStock: async function (exportData) {
        return await ApiHelper.sendRequest('/api/Oem/ExportStock', "POST", exportData);
    },
    //輔具清消維修統計
    GetMaintenance: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetMaintenance', "POST", queryData);
    },
    ExportMaintenance: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/ExportMaintenance', "POST", queryData);
    },
    GetStockEventLogs: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetStockEventLogs', "POST", queryData);
    },
    GetOrderAddress: async function (queryData) {
        return await ApiHelper.sendRequest('/api/Oem/GetOrderAddress', "POST", queryData);
    }
}