export type GetApiVendorQuestionnaireAttachmentArgs = {attachment_ids?: Array | undefined, zip?: boolean | undefined}; export type GetApiVendorQuestionnaireAttachmentOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve (one or more) vendor questionnaire attachments by id * * GET /vendor/questionnaire/attachment */ export const getApiVendorQuestionnaireAttachment = async (args: GetApiVendorQuestionnaireAttachmentArgs, options?: GetApiVendorQuestionnaireAttachmentOptions) => { const {baseUrl = "https://cyber-risk.upguard.com/api/public", fetch: fetchFn = fetch, APIKeyInHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/jpeg") for (const item of args.attachment_ids ?? []) query.append("attachment_ids", String(item)) if (args.zip != null) query.append("zip", String(args.zip)) if (APIKeyInHeader !== undefined) headers.set("Authorization", APIKeyInHeader) const url = `${baseUrl.replace(/\/+$/, '')}/vendor/questionnaire/attachment${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };