<script>
import {authenticatedRequest} from "@/components/session/authenticatedRequest.vue";
import {handleEconomicError} from "@/components/request/HandleEconomicError.vue";

/**
 * The invoices object
 */
export const invoices = {
  draft: {
    get: async (draftId) => {
      return authenticatedRequest(
          "/invoices/draft?id=" + draftId,
          "GET")
    },
    close: async (draftId) => {
      return authenticatedRequest(
          "/invoices/draft/close",
          "POST",
          {
            id: parseInt(draftId)
          })
    },
  },
  exportOrderToDraft: async (order_id) => {
    await authenticatedRequest('/economic/invoice/draft/export','post',{
      order_id: order_id
    }) .catch((error) => {
      handleEconomicError(error);
    });
  },
};

</script>