export type JTLWawiRestContractsModelsV1InvoiceInvoiceWorkflowEvent = 1 | 3 | 6; export type JTLDataContractsKeysRechnungKey = string; export type CreateApiV2InvoicesInvoiceIdWorkflowWorkflowEventIdArgs = {'x-tenant-id': string, workflowEventId: JTLWawiRestContractsModelsV1InvoiceInvoiceWorkflowEvent, invoiceId: JTLDataContractsKeysRechnungKey, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined}; export type CreateApiV2InvoicesInvoiceIdWorkflowWorkflowEventIdOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Trigger Invoice Workflow * * POST /v2/invoices/{invoiceId}/workflow/{workflowEventId} * * Also accepts auth: oauth2-client-credentials */ export const createApiV2InvoicesInvoiceIdWorkflowWorkflowEventId = async (args: CreateApiV2InvoicesInvoiceIdWorkflowWorkflowEventIdArgs, options?: CreateApiV2InvoicesInvoiceIdWorkflowWorkflowEventIdOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, oauth2AuthorizationCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) if (args['x-runas'] != null) headers.set("x-runas", String(args['x-runas'])) if (args['x-companyid'] != null) headers.set("x-companyid", String(args['x-companyid'])) if (oauth2AuthorizationCode !== undefined) headers.set('authorization', `Bearer ${oauth2AuthorizationCode}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/invoices/${encodeURIComponent(String(args.invoiceId))}/workflow/${encodeURIComponent(String(args.workflowEventId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };