export type CreateApiCollectionsCollectionArgs = {id?: string | undefined, name?: string | undefined, description?: string | undefined, private?: string | undefined, items?: string | undefined, locale?: string | undefined}; export type CreateApiCollectionsCollectionOptions = {baseUrl?: string | undefined, BetaSeriesApiKey?: string | undefined, BetaSeriesToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create/Update a collection for the identified user [Premium feature] * * POST /collections/collection */ export const createApiCollectionsCollection = async (args: CreateApiCollectionsCollectionArgs, options?: CreateApiCollectionsCollectionOptions) => { const {baseUrl = "https://api.betaseries.com", fetch: fetchFn = fetch, BetaSeriesApiKey, BetaSeriesToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.id != null) query.append("id", String(args.id)) if (args.name != null) query.append("name", String(args.name)) if (args.description != null) query.append("description", String(args.description)) if (args.private != null) query.append("private", String(args.private)) if (args.items != null) query.append("items", String(args.items)) if (args.locale != null) query.append("locale", String(args.locale)) if (BetaSeriesApiKey !== undefined) headers.set("X-BetaSeries-Key", BetaSeriesApiKey) if (BetaSeriesToken !== undefined) headers.set("X-BetaSeries-Token", BetaSeriesToken) const url = `${baseUrl.replace(/\/+$/, '')}/collections/collection${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };