export type UpdateApiAppPushSubscriptionArgs = {body: {endpoint?: string | undefined, unsubscribed?: boolean | undefined, key?: string | undefined, token?: string | undefined, encoding?: string | undefined}}; export type UpdateApiAppPushSubscriptionOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Push subscription * * PUT /app/push-subscription */ export const updateApiAppPushSubscription = async (args: UpdateApiAppPushSubscriptionArgs, options?: UpdateApiAppPushSubscriptionOptions) => { const {baseUrl = "https://api.lolz.team", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/app/push-subscription${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 };