export type DayOfWeek = 'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday'; export type UpdateAccessHourModel = {dayOfWeek?: DayOfWeek | undefined, start: string, stop: string}; export type UpdateApiV1ContactsContactIdAccessHoursArgs = {'Customer-Id': number, contactId: number, body: Array}; export type UpdateApiV1ContactsContactIdAccessHoursOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a site access hours * * PUT /v1/contacts/{contactId}/accessHours */ export const updateApiV1ContactsContactIdAccessHours = async (args: UpdateApiV1ContactsContactIdAccessHoursArgs, options?: UpdateApiV1ContactsContactIdAccessHoursOptions) => { const {baseUrl = "https://api.bigchange.com", fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Customer-Id'] != null) headers.set("Customer-Id", String(args['Customer-Id'])) if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/contacts/${encodeURIComponent(String(args.contactId))}/accessHours${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 };