export type ReclaimAccessDto = {email: string}; export type CreateApiV1TrustAccessFriendlyUrlReclaimArgs = {friendlyUrl: string, query?: string | undefined, body: ReclaimAccessDto}; export type CreateApiV1TrustAccessFriendlyUrlReclaimOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reclaim Trust Access link * * POST /v1/trust-access/{friendlyUrl}/reclaim */ export const createApiV1TrustAccessFriendlyUrlReclaim = async (args: CreateApiV1TrustAccessFriendlyUrlReclaimArgs, options?: CreateApiV1TrustAccessFriendlyUrlReclaimOptions) => { const {baseUrl = "https://api.betayum.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.query != null) query.append("query", String(args.query)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/trust-access/${encodeURIComponent(String(args.friendlyUrl))}/reclaim${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 };