export type Id = number; export type CreateApiAxleConfigsArgs = {body: {vehicle_id: Id, axle_config_template_id: number, with_installed_tires?: boolean | undefined, axles_count?: number | undefined}}; export type CreateApiAxleConfigsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, accountToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Axle Configuration * * POST /axle_configs */ export const createApiAxleConfigs = async (args: CreateApiAxleConfigsArgs, options?: CreateApiAxleConfigsOptions) => { 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(/\/+$/, '')}/axle_configs${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 };