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

export const OrderDataService = {
    GetList: async function (queryData) {
        return (await ApiHelper.sendRequest('/api/Order/GetList', "POST", queryData)).data;
    },
    GetInquiryList: async function (queryData) {
        return (await ApiHelper.sendRequest('/api/Order/GetInquiryList', "POST", queryData)).data;
    },
    GetDetailList: async function (queryData) {
        return (await ApiHelper.sendRequest('/api/Order/GetDetailList', "POST", queryData)).data;
    },
    Get: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/Get?id=${id}`, "GET");
    },
    Update: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/Update', 'PATCH', data);
    },
    TransToOrder: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/TransToOrder?id=${id}`, 'PATCH');
    },
    TransToInquiry: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/TransToInquiry?id=${id}`, 'GET');
    },
    TransToShip: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/TransToShip?id=${id}`, 'GET');
    },
    TransToRenew: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/TransToRenew?id=${id}`, 'GET');
    },
    PauseOrder: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/PauseOrder?id=${id}`, 'GET');
    },
    RestoreOrder: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/RestoreOrder?id=${id}`, 'GET');
    },
    ClosedOrder: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/ClosedOrder?id=${id}`, 'GET');
    },
    Delete: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/Delete?id=${id}`, "DELETE");
    },
    Calculate: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/Calculate', "POST", data);
    },
    GetMain: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/GetMain?id=${id}`, "GET");
    },
    GetDetail: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/GetDetail?id=${id}`, "GET");
    },
    CreateDetail: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/CreateDetail', 'POST', data);
    },
    UpdateDetail: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/UpdateDetail', 'PATCH', data);
    },
    DeleteDetail: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/DeleteDetail?id=${id}`, "DELETE");
    },
    UpdateDetailDate: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/UpdateDetailDate', 'PATCH', data);
    },
    GetReceiptList: async function (orderId) {
        return (await ApiHelper.sendRequest(`/api/Order/GetReceiptList?orderId=${orderId}`, "GET")).data;
    },
    GetPaymentRecordList: async function (orderId) {
        return (await ApiHelper.sendRequest(`/api/Order/GetPaymentRecordList?orderId=${orderId}`, "GET")).data;
    },
    GetContractList: async function (orderId) {
        return (await ApiHelper.sendRequest(`/api/Order/GetContractList?orderId=${orderId}`, "GET")).data;
    },
    UploadImage: async function (formData) {
        return await ApiHelper.sendRequest('/api/Order/UploadImage', "POST", formData, null, { headers: { 'Content-Type': null } });
    },
    DeleteReceipt: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/DeleteReceipt?id=${id}`, "DELETE");
    },
    DeleteContract: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/DeleteContract?id=${id}`, "DELETE");
    },
    GetPaymentRecord: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/GetPaymentRecord?id=${id}`, "GET");
    },
    CreatePaymentRecord: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/CreatePaymentRecord', 'POST', data);
    },
    UpdatePaymentRecord: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/UpdatePaymentRecord', 'PATCH', data);
    },
    DeletePaymentRecord: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/DeletePaymentRecord?id=${id}`, "DELETE");
    },
    GetMarketList: async function () {
        return (await ApiHelper.sendRequest('/api/Order/GetMarketList', "GET")).data;
    },
    GetMarketStoreList: async function (marketId) {
        return (await ApiHelper.sendRequest(`/api/Order/GetMarketStoreList?marketId=${marketId}`, "GET")).data;
    },
    GetOther: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/GetOther?id=${id}`, "GET");
    },
    CreateOther: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/CreateOther', 'POST', data);
    },
    UpdateOther: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/UpdateOther', 'PATCH', data);
    },
    DeleteOther: async function (id) {
        return await ApiHelper.sendRequest(`/api/Order/DeleteOther?id=${id}`, "DELETE");
    },
    GetPrint: async function (orderId) {
        return await ApiHelper.sendRequest(`/api/Order/GetPrint?orderId=${orderId}`, "GET");
    },
    AppendDetail: async function (data) {
        return await ApiHelper.sendRequest('/api/Order/AppendDetail', 'POST', data);
    },
    GetProduct: async function (pid, oid) {
        return await ApiHelper.sendRequest(`/api/Order/GetProduct?pid=${pid}&oid=${oid}`, "GET");
    },
    GetPaymentStatus: async function () {
        return (await ApiHelper.sendRequest('/api/Order/GetPaymentStatus', "GET")).data;
    }
}