export type SellerId = string; export type TicketId = string; export type GetApiV1ChannelTicketAttachmentArgs = {sellerId: SellerId, ticketId: TicketId, filename: string}; export type GetApiV1ChannelTicketAttachmentOptions = {baseUrl?: string | undefined, ChannelAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Attachment * * GET /v1/channel/ticket/attachment */ export const getApiV1ChannelTicketAttachment = async (args: GetApiV1ChannelTicketAttachmentArgs, options?: GetApiV1ChannelTicketAttachmentOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, ChannelAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.sellerId != null) query.append("sellerId", String(args.sellerId)) if (args.ticketId != null) query.append("ticketId", String(args.ticketId)) if (args.filename != null) query.append("filename", String(args.filename)) if (ChannelAuth !== undefined) headers.set('authorization', `Bearer ${ChannelAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/channel/ticket/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.text() };