export type GetApiRentalsArgs = {near?: string | undefined, radius?: number | undefined, from?: string | undefined, to?: string | undefined, created_from?: string | undefined, created_to?: string | undefined, sleeps?: number | undefined, sleeps_adults?: number | undefined, sleeps_kids?: number | undefined, seatbelts?: number | undefined, type?: string | undefined, price_min?: number | undefined, price_max?: number | undefined, year_min?: number | undefined, year_max?: number | undefined, order?: string | undefined, owner_id?: number | undefined, limit?: number | undefined, unlimited?: string | undefined, offset?: number | undefined, status?: string | undefined, bounds_NE?: string | undefined, bounds_SW?: string | undefined, insurance_state?: string | undefined, exclude?: string | undefined, location_id?: number | undefined, location_ids?: string | undefined, hidden?: string | undefined, include_variable_fees?: string | undefined, ids?: string | undefined, address?: string | undefined, parent_id?: number | undefined, include_children?: string | undefined, locale?: string | undefined, presentment_currency?: string | undefined, rental_category?: string | undefined}; export type GetApiRentalsOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Read many rentals * GetFleetVehicle retrieves vehicle data from the Fleet service for a rental. * This includes real-time information like odometer reading, connection status, and other attributes. * The frontend can use this data to update mileage fields or display vehicle status. * * GET /rentals * * Also accepts auth: API-Key */ export const getApiRentals = async (args: GetApiRentalsArgs, options: GetApiRentalsOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.near != null) query.append("near", String(args.near)) if (args.radius != null) query.append("radius", String(args.radius)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.created_from != null) query.append("created_from", String(args.created_from)) if (args.created_to != null) query.append("created_to", String(args.created_to)) if (args.sleeps != null) query.append("sleeps", String(args.sleeps)) if (args.sleeps_adults != null) query.append("sleeps_adults", String(args.sleeps_adults)) if (args.sleeps_kids != null) query.append("sleeps_kids", String(args.sleeps_kids)) if (args.seatbelts != null) query.append("seatbelts", String(args.seatbelts)) if (args.type != null) query.append("type", String(args.type)) if (args.price_min != null) query.append("price_min", String(args.price_min)) if (args.price_max != null) query.append("price_max", String(args.price_max)) if (args.year_min != null) query.append("year_min", String(args.year_min)) if (args.year_max != null) query.append("year_max", String(args.year_max)) if (args.order != null) query.append("order", String(args.order)) if (args.owner_id != null) query.append("owner_id", String(args.owner_id)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.unlimited != null) query.append("unlimited", String(args.unlimited)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.status != null) query.append("status", String(args.status)) if (args.bounds_NE != null) query.append("bounds_NE", String(args.bounds_NE)) if (args.bounds_SW != null) query.append("bounds_SW", String(args.bounds_SW)) if (args.insurance_state != null) query.append("insurance_state", String(args.insurance_state)) if (args.exclude != null) query.append("exclude", String(args.exclude)) if (args.location_id != null) query.append("location_id", String(args.location_id)) if (args.location_ids != null) query.append("location_ids", String(args.location_ids)) if (args.hidden != null) query.append("hidden", String(args.hidden)) if (args.include_variable_fees != null) query.append("include_variable_fees", String(args.include_variable_fees)) if (args.ids != null) query.append("ids", String(args.ids)) if (args.address != null) query.append("address", String(args.address)) if (args.parent_id != null) query.append("parent_id", String(args.parent_id)) if (args.include_children != null) query.append("include_children", String(args.include_children)) if (args.locale != null) query.append("locale", String(args.locale)) if (args.presentment_currency != null) query.append("presentment_currency", String(args.presentment_currency)) if (args.rental_category != null) query.append("rental_category", String(args.rental_category)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/rentals${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };