export type SerializedDomainNftGalleryItemPost = {mint?: string | undefined, public?: boolean | undefined}; export type SerializedDomainNftGalleryPost = {symbol?: string | undefined, address?: string | undefined, public?: boolean | undefined, showAllItems?: boolean | undefined, order?: number | undefined, items?: Array | undefined}; export type SerializedDomainNftGalleriesPost = Array; export type CreateApiUserDomainNftsArgs = {domain: string, 'x-auth-domain': string, 'x-auth-expires': string, 'x-auth-signature': string, body: SerializedDomainNftGalleriesPost}; export type CreateApiUserDomainNftsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update NFT preferences for a domain * * POST /user/{domain}/nfts */ export const createApiUserDomainNfts = async (args: CreateApiUserDomainNftsArgs, options?: CreateApiUserDomainNftsOptions) => { 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(/\/+$/, '')}/user/${encodeURIComponent(String(args.domain))}/nfts${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 };