export type GetApiPurchaseOrdersPurchaseOrderIDAttachmentsAttachmentIDArgs = {PurchaseOrderID: string, AttachmentID: string, contentType: string}; export type GetApiPurchaseOrdersPurchaseOrderIDAttachmentsAttachmentIDOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieves specific attachment for a specific purchase order using a unique attachment Id * * GET /PurchaseOrders/{PurchaseOrderID}/Attachments/{AttachmentID} */ export const getApiPurchaseOrdersPurchaseOrderIDAttachmentsAttachmentID = async (args: GetApiPurchaseOrdersPurchaseOrderIDAttachmentsAttachmentIDArgs, options?: GetApiPurchaseOrdersPurchaseOrderIDAttachmentsAttachmentIDOptions) => { const {baseUrl = "https://api.xero.com/api.xro/2.0", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.contentType != null) headers.set("contentType", String(args.contentType)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/PurchaseOrders/${encodeURIComponent(String(args.PurchaseOrderID))}/Attachments/${encodeURIComponent(String(args.AttachmentID))}${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() };