export type GetManyRequest = {calendar_id?: number | undefined, rental_id?: number | undefined}; export type CreateApiIcsCalendarsSyncArgs = {owner_user_id?: number | undefined, body: GetManyRequest}; export type CreateApiIcsCalendarsSyncOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Trigger a job to sync all user eligible (last sync started at least 3 minutes ago) callendars. Optionally could be triggered for a specific user's calendar or user owned rental. * * POST /ics-calendars/sync * * Also accepts auth: API-Key */ export const createApiIcsCalendarsSync = async (args: CreateApiIcsCalendarsSyncArgs, options: CreateApiIcsCalendarsSyncOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.owner_user_id != null) query.append("owner_user_id", String(args.owner_user_id)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/ics-calendars/sync${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 };