export type UpdateApiCitiesCityIdArgs = {cityId: number, Authorization: string, body: {name: string, latitude: number, longitude: number, population: number, countryCode: string, regionCode: string}}; export type UpdateApiCitiesCityIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a specific city * * PUT /cities/{cityId} */ export const updateApiCitiesCityId = async (args: UpdateApiCitiesCityIdArgs, options?: UpdateApiCitiesCityIdOptions) => { const {baseUrl = "http://127.0.0.1:8443", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/cities/${encodeURIComponent(String(args.cityId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };