export type SerializedDomainFollowPost = {domain?: string | undefined}; export type DeleteApiFollowersDomainArgs = {domain: string, 'x-auth-domain': string, 'x-auth-expires': string, 'x-auth-signature': string, body: SerializedDomainFollowPost}; export type DeleteApiFollowersDomainOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Unfollows a domain * * DELETE /followers/{domain} */ export const deleteApiFollowersDomain = async (args: DeleteApiFollowersDomainArgs, options?: DeleteApiFollowersDomainOptions) => { const {baseUrl = "https://api.unstoppabledomains.com/profile", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-auth-domain'] != null) headers.set("x-auth-domain", String(args['x-auth-domain'])) if (args['x-auth-expires'] != null) headers.set("x-auth-expires", String(args['x-auth-expires'])) if (args['x-auth-signature'] != null) headers.set("x-auth-signature", String(args['x-auth-signature'])) const url = `${baseUrl.replace(/\/+$/, '')}/followers/${encodeURIComponent(String(args.domain))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", 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 };