export type GettyImagesServicesConnectPublicControllersDownloadDownloadFileType = 'eps' | 'jpg'; export type GettyImagesServicesConnectPublicModelsProductTypeForDownloads = 'easyaccess' | 'editorialsubscription' | 'imagepack' | 'premiumaccess' | 'royaltyfreesubscription' | 'creditpack' | 'aigen'; export type GettyImagesServicesConnectPublicModelsDownloadsPremiumAccessDownloadData = {download_notes?: (string | null) | undefined, project_code?: (string | null) | undefined}; export type CreateApiV3DownloadsImagesIdArgs = {'Accept-Language'?: string | undefined, id: string, auto_download?: boolean | undefined, file_type?: GettyImagesServicesConnectPublicControllersDownloadDownloadFileType | undefined, height?: string | undefined, product_id?: number | undefined, product_type?: GettyImagesServicesConnectPublicModelsProductTypeForDownloads | undefined, use_team_credits?: boolean | undefined, body: GettyImagesServicesConnectPublicModelsDownloadsPremiumAccessDownloadData}; export type CreateApiV3DownloadsImagesIdOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download an image * * POST /v3/downloads/images/{id} * * Also accepts auth: OAuth2 */ export const createApiV3DownloadsImagesId = async (args: CreateApiV3DownloadsImagesIdArgs, options: CreateApiV3DownloadsImagesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (args.auto_download != null) query.append("auto_download", String(args.auto_download)) if (args.file_type != null) query.append("file_type", String(args.file_type)) if (args.height != null) query.append("height", String(args.height)) if (args.product_id != null) query.append("product_id", String(args.product_id)) if (args.product_type != null) query.append("product_type", String(args.product_type)) if (args.use_team_credits != null) query.append("use_team_credits", String(args.use_team_credits)) if (ApiKey !== undefined) headers.set("Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v3/downloads/images/${encodeURIComponent(String(args.id))}${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 };