export type CreateApiV2RevenueCatCallbackAppidArgs = {appid: string, id: string}; export type CreateApiV2RevenueCatCallbackAppidOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * revenue_cat webhook callback * * POST /v2/revenue_cat/callback/{appid} */ export const createApiV2RevenueCatCallbackAppid = async (args: CreateApiV2RevenueCatCallbackAppidArgs, options: CreateApiV2RevenueCatCallbackAppidOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.id != null) query.append("id", String(args.id)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/revenue_cat/callback/${encodeURIComponent(String(args.appid))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };