export type GetApiUsersIdSalesDownloadArgs = {id: string, user_id?: string | undefined, 'Encoded-Data-Message'?: string | undefined, 'Encoded-Data-Signature'?: string | undefined}; export type GetApiUsersIdSalesDownloadOptions = {baseUrl: string, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Downloads the sales the user has made as a CSV file * * GET /users/{id}/sales/download */ export const getApiUsersIdSalesDownload = async (args: GetApiUsersIdSalesDownloadArgs, options: GetApiUsersIdSalesDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args['Encoded-Data-Message'] != null) headers.set("Encoded-Data-Message", String(args['Encoded-Data-Message'])) if (args['Encoded-Data-Signature'] != null) headers.set("Encoded-Data-Signature", String(args['Encoded-Data-Signature'])) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.id))}/sales/download${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 undefined };