export type UpdateApiPersistenceItemsItemnameArgs = {serviceId?: string | undefined, itemname: string, time: string, state: string}; export type UpdateApiPersistenceItemsItemnameOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stores item persistence data into the persistence service. * * PUT /persistence/items/{itemname} */ export const updateApiPersistenceItemsItemname = async (args: UpdateApiPersistenceItemsItemnameArgs, options: UpdateApiPersistenceItemsItemnameOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.serviceId != null) query.append("serviceId", String(args.serviceId)) if (args.time != null) query.append("time", String(args.time)) if (args.state != null) query.append("state", String(args.state)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/persistence/items/${encodeURIComponent(String(args.itemname))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };