export type CreateApiApiV1CommercialSalesDocumentsArgs = {body: {apply_retention_when_paid?: boolean | undefined, currency_conversion_rate?: number | undefined, currency_iso_code?: string | undefined, customer_address_detail?: string | undefined, customer_business_name?: string | undefined, customer_city?: string | undefined, customer_country?: string | undefined, customer_postcode?: string | undefined, customer_tax_registration_number?: string | undefined, date?: string | undefined, document_type?: string | undefined, due_date?: string | undefined, external_reference?: string | undefined, finalize?: boolean | undefined, lines?: Array> | undefined, notes?: string | undefined, operation_country?: string | undefined, payment_mechanism?: string | undefined, retention?: number | undefined, retention_type?: string | undefined, settlement_expression?: string | undefined, vat_included_prices?: boolean | undefined}}; export type CreateApiApiV1CommercialSalesDocumentsOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Criar Documento de Venda * * POST /api/v1/commercial_sales_documents */ export const createApiApiV1CommercialSalesDocuments = async (args: CreateApiApiV1CommercialSalesDocumentsArgs, options: CreateApiApiV1CommercialSalesDocumentsOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/commercial_sales_documents${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 };