export type Id = number; export type LabelListParameters = string; export type CustomFields = Record | null; export type ServiceEntryLineItemType = 'ServiceEntryServiceTaskLineItem' | 'ServiceEntryLaborLineItem' | 'ServiceEntryPartLineItem' | 'ServiceEntryTaxLineItem' | 'ServiceEntryFeeLineItem' | 'ServiceEntryTireLineItem' | 'ServiceEntryFreeTextLineItem'; export type ServiceEntryLineItemAttributes = {id?: Id | undefined, service_task_id?: Id | undefined, type?: ServiceEntryLineItemType | undefined, description?: string | undefined, labor_cost?: number | undefined, parts_cost?: number | undefined, subtotal?: number | undefined, service_entry_line_item_id?: number | undefined, issue_ids?: Array | undefined, vmrs_reason_for_repair_id?: Id | undefined, vmrs_system_group_id?: Id | undefined, vmrs_system_id?: Id | undefined, vmrs_component_id?: Id | undefined, vmrs_assembly_id?: Id | undefined}; export type CommentsAttributes = {title?: string | undefined, comment?: string | undefined}; export type DiscountType = 'fixed' | 'percentage' | null; export type TaxType = 'fixed' | 'percentage' | null; export type PatchApiServiceEntriesIdArgs = {id: string, body: {completed_at?: string | undefined, started_at?: string | undefined, vehicle_id?: Id | undefined, vehicle_vin?: string | undefined, vendor_id?: Id | undefined, reference?: string | undefined, label_list?: LabelListParameters | undefined, general_notes?: string | undefined, vmrs_repair_priority_class_id?: Id | undefined, custom_fields?: CustomFields | undefined, meter_entry_attributes?: ({value?: number | undefined, void?: boolean | undefined}) | undefined, secondary_meter_entry_attributes?: ({value?: number | undefined, void?: boolean | undefined}) | undefined, service_entry_line_items_attributes?: Array | undefined, issue_ids?: Array | undefined, service_task_ids?: Array | undefined, comments_attributes?: Array | undefined, documents_attributes?: (Array<{name?: string | undefined, file_url?: string | undefined, file_mime_type?: string | undefined, file_name?: string | undefined, file_size?: number | undefined}>) | undefined, images_attributes?: (Array<{name?: string | undefined, file_url?: string | undefined, file_mime_type?: string | undefined, file_name?: string | undefined, file_size?: number | undefined}>) | undefined, labor_subtotal?: number | undefined, manual_total_amount?: boolean | undefined, manual_parts_or_labor_subtotal?: boolean | undefined, parts_subtotal?: number | undefined, subtotal?: number | undefined, discount?: number | undefined, discount_percentage?: number | undefined, discount_type?: DiscountType | undefined, tax_1?: number | undefined, tax_1_percentage?: number | undefined, tax_1_type?: TaxType | undefined, tax_2?: number | undefined, tax_2_percentage?: number | undefined, tax_2_type?: TaxType | undefined, total_amount?: number | undefined}}; export type PatchApiServiceEntriesIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, accountToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Service Entry * * PATCH /service_entries/{id} */ export const patchApiServiceEntriesId = async (args: PatchApiServiceEntriesIdArgs, options?: PatchApiServiceEntriesIdOptions) => { const {baseUrl = "https://secure.fleetio.com/api", fetch: fetchFn = fetch, apiKey, accountToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("Authorization", apiKey) if (accountToken !== undefined) headers.set("Account-Token", accountToken) const url = `${baseUrl.replace(/\/+$/, '')}/service_entries/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };