export type CrossChainPaymentToken = {chain: string, token_address: string}; export type SweepCollectionRequest = {buyer: string, collection_slug: string, max_items: number, max_price_per_item: string, payment: CrossChainPaymentToken, recipient?: (string | null) | undefined}; export type CreateApiApiV2ListingsSweepArgs = {body: SweepCollectionRequest}; export type CreateApiApiV2ListingsSweepOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sweep buy items from a collection * * POST /api/v2/listings/sweep */ export const createApiApiV2ListingsSweep = async (args: CreateApiApiV2ListingsSweepArgs, options?: CreateApiApiV2ListingsSweepOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/listings/sweep${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 res.blob() };