export type UpdateApiInvoicesInvoiceIdRejectArgs = {invoiceId: number, comments: string, isNotifyProvider?: boolean | undefined, additionalEmails?: string | undefined}; export type UpdateApiInvoicesInvoiceIdRejectOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Allows reject non-MLI(Multilevel Invoice Approval) invoice * * PUT /invoices/{invoiceId}/reject */ export const updateApiInvoicesInvoiceIdReject = async (args: UpdateApiInvoicesInvoiceIdRejectArgs, options?: UpdateApiInvoicesInvoiceIdRejectOptions) => { const {baseUrl = "https://sb2api.servicechannel.com/v3", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.comments != null) query.append("comments", String(args.comments)) if (args.isNotifyProvider != null) query.append("isNotifyProvider", String(args.isNotifyProvider)) if (args.additionalEmails != null) query.append("additionalEmails", String(args.additionalEmails)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/${encodeURIComponent(String(args.invoiceId))}/reject${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };