export type LocationV2 = {Latitude: number, Longitude: number}; export type DriverLocation = {TimeStamp?: string | undefined, OrderId?: string | undefined, Location?: LocationV2 | undefined}; export type UpdateApiDriverLocationArgs = {body: DriverLocation}; export type UpdateApiDriverLocationOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Driver Location * * PUT /driver-location */ export const updateApiDriverLocation = async (args: UpdateApiDriverLocationArgs, options?: UpdateApiDriverLocationOptions) => { const {baseUrl = "https://uk.api.just-eat.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/driver-location${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };