import { apiServiceZdesk } from "../../utils/axios";
const defaultPath = '/ticket';
export async function getTicket(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(defaultPath, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicket');
}
export async function postTicketFilter(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(`${defaultPath}/filter`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketFilter');
}
export async function putTicket(service, payload) {
    const { data, status } = await apiServiceZdesk(service).put(defaultPath, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTicket');
}
export async function putTransferTicket(service, payload) {
    const { data, status } = await apiServiceZdesk(service).put(`${defaultPath}/transfer`, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTransferTicket');
}
export async function patchUpdateStatusTicket(service, payload) {
    const { data, status } = await apiServiceZdesk(service).patch(`${defaultPath}/status`, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchUpdateStatusTicket');
}
const defaultPathCustomField = '/ticket-custom-fields';
export async function postTicketCustomField(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(defaultPathCustomField, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketCustomField');
}
export async function getTicketCustomField(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(defaultPathCustomField, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketCustomField');
}
export async function patchTicketCustomField(service, payload) {
    const { data, status } = await apiServiceZdesk(service).patch(defaultPathCustomField, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketCustomField');
}
export async function putTicketCustomFieldBatchUpdate(service, payload) {
    const { data, status } = await apiServiceZdesk(service).put(`${defaultPathCustomField}/batch-update`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTicketCustomFieldBatchUpdate');
}
const defaultPathCustomFieldConfig = '/ticket-custom-field-configs';
export async function postTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(defaultPathCustomFieldConfig, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketCustomFieldConfigs');
}
export async function getTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(defaultPathCustomFieldConfig, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketCustomFieldConfigs');
}
export async function patchTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await apiServiceZdesk(service).patch(defaultPathCustomFieldConfig, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketCustomFieldConfigs');
}
export async function putTicketCustomFieldConfigsOrder(service, payload) {
    const { data, status } = await apiServiceZdesk(service).put(`${defaultPathCustomFieldConfig}/order`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTicketCustomFieldConfigsOrder');
}
export async function deleteTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await apiServiceZdesk(service).delete(defaultPathCustomFieldConfig, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketCustomFieldConfigs');
}
const defaultPathTicketComment = '/ticket-comment';
export async function getTicketComment(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(defaultPathTicketComment, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketComment');
}
export async function postTicketComment(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(defaultPathTicketComment, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketComment');
}
export async function patchTicketComment(service, payload) {
    const { data, status } = await apiServiceZdesk(service).patch(defaultPathTicketComment, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketComment');
}
export async function deleteTicketComment(service, payload) {
    const { data, status } = await apiServiceZdesk(service).delete(defaultPathTicketComment, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketComment');
}
const defaultPathTicketReply = '/ticket-reply-comment';
export async function postTicketCommentReply(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(defaultPathTicketReply, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketCommentReply');
}
export async function patchTicketCommentReply(service, payload) {
    const { data, status } = await apiServiceZdesk(service).patch(defaultPathTicketReply, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketCommentReply');
}
export async function deleteTicketCommentReply(service, payload) {
    const { data, status } = await apiServiceZdesk(service).delete(defaultPathTicketReply, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketCommentReply');
}
const defaultPathTicketCommentLog = '/ticket-comment-logs';
export async function getTicketCommentLog(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(defaultPathTicketCommentLog, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketCommentLog');
}
const defaultPathTicketActivities = '/ticket-activities';
export async function getTicketActivities(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(`${defaultPathTicketActivities}/info`, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketActivities');
}
const defaultPathTicketFollowing = '/ticket-following';
export async function deleteTicketFollowing(service, payload) {
    const { data, status } = await apiServiceZdesk(service).delete(defaultPathTicketFollowing, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketFollowing');
}
export async function createTicketFollowing(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(defaultPathTicketFollowing, { ...payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to createTicketFollowing');
}
const defaultPathTicketStatus = '/ticket-status';
export async function getTicketStatusSetting(service, payload) {
    const { data, status } = await apiServiceZdesk(service).get(defaultPathTicketStatus, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketStatusSetting');
}
export async function postTicketStatusSetting(service, payload) {
    const { data, status } = await apiServiceZdesk(service).post(defaultPathTicketStatus, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketStatusSetting');
}
export async function deleteTicketStatusSetting(service, payload) {
    const { data, status } = await apiServiceZdesk(service).delete(defaultPathTicketStatus, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketStatusSetting');
}
