export type CreateApiV2ImagesCollectionsIdItemsArgs = {id: string, body: {items: Array<{added_time?: string | undefined, id: string, media_type?: string | undefined}>}}; export type CreateApiV2ImagesCollectionsIdItemsOptions = {baseUrl?: string | undefined, customerAccessCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add images to collections * * POST /v2/images/collections/{id}/items */ export const createApiV2ImagesCollectionsIdItems = async (args: CreateApiV2ImagesCollectionsIdItemsArgs, options?: CreateApiV2ImagesCollectionsIdItemsOptions) => { const {baseUrl = "https://api.shutterstock.com", fetch: fetchFn = fetch, customerAccessCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (customerAccessCode !== undefined) headers.set('authorization', `Bearer ${customerAccessCode}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/images/collections/${encodeURIComponent(String(args.id))}/items${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 };