export type UpdateApiInvoicesInvoiceIdApproveArgs = {invoiceId: number, approvalCode: string, comments: string, category: string}; export type UpdateApiInvoicesInvoiceIdApproveOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Allows approve non-MLI(Multilevel Invoice Approval) invoice * * PUT /invoices/{invoiceId}/approve */ export const updateApiInvoicesInvoiceIdApprove = async (args: UpdateApiInvoicesInvoiceIdApproveArgs, options?: UpdateApiInvoicesInvoiceIdApproveOptions) => { const {baseUrl = "https://sb2api.servicechannel.com/v3", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.approvalCode != null) query.append("approvalCode", String(args.approvalCode)) if (args.comments != null) query.append("comments", String(args.comments)) if (args.category != null) query.append("category", String(args.category)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/${encodeURIComponent(String(args.invoiceId))}/approve${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 };