export type InvoiceishDraftLine = {invoiceishDraftLineId?: number | undefined, lastModifiedDate?: string | undefined, productId?: number | undefined, description?: string | undefined, unitPrice?: number | undefined, vatType?: string | undefined, quantity: number, discount?: number | undefined, comment?: string | undefined, incomeAccount?: string | undefined}; export type RoundingType = 'none' | 'round_half' | 'round_whole' | 'round_down_half' | 'round_down_whole'; export type Frequency = {interval: number, intervalUnit: 'DAY' | 'WEEK' | 'MONTH'}; export type InvoiceishDraftRequest = {type: 'invoice' | 'cash_invoice' | 'offer' | 'order_confirmation' | 'credit_note' | 'repeating_invoice', uuid?: string | undefined, issueDate?: string | undefined, daysUntilDueDate: number, invoiceText?: string | undefined, yourReference?: string | undefined, ourReference?: string | undefined, orderReference?: string | undefined, lines?: Array | undefined, currency?: string | undefined, bankAccountNumber?: string | undefined, iban?: string | undefined, bic?: string | undefined, paymentAccount?: string | undefined, customerId: number, contactPersonId?: number | undefined, projectId?: number | undefined, roundingType?: RoundingType | undefined, startDate?: string | undefined, endDate?: string | undefined, frequency?: Frequency | undefined}; export type CreateApiCompaniesCompanySlugOrderConfirmationsDraftsArgs = {body: InvoiceishDraftRequest}; export type CreateApiCompaniesCompanySlugOrderConfirmationsDraftsOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates an order confirmation draft. * * POST /companies/{companySlug}/orderConfirmations/drafts */ export const createApiCompaniesCompanySlugOrderConfirmationsDrafts = async (args: CreateApiCompaniesCompanySlugOrderConfirmationsDraftsArgs, options?: CreateApiCompaniesCompanySlugOrderConfirmationsDraftsOptions) => { const {baseUrl = "https://api.fiken.no/api/v2", fetch: fetchFn = fetch, fikenApiOauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (fikenApiOauth !== undefined) headers.set('authorization', `Bearer ${fikenApiOauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companySlug))}/orderConfirmations/drafts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };