export type SaveDropItemMediaRequest = {media_tokens: Array}; export type CreateApiApiV2DropsSlugItemsMediaSaveArgs = {slug: string, body: SaveDropItemMediaRequest}; export type CreateApiApiV2DropsSlugItemsMediaSaveOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, WalletAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save drop item media * * POST /api/v2/drops/{slug}/items/media/save */ export const createApiApiV2DropsSlugItemsMediaSave = async (args: CreateApiApiV2DropsSlugItemsMediaSaveArgs, options?: CreateApiApiV2DropsSlugItemsMediaSaveOptions) => { const {baseUrl = "https://api.opensea.io", fetch: fetchFn = fetch, ApiKeyAuth, WalletAuth} = 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) if (WalletAuth !== undefined) headers.set('authorization', `Bearer ${WalletAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/drops/${encodeURIComponent(String(args.slug))}/items/media/save${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() };