export type GetApiAccountsAccountIdMessagesArgs = {account_id: number, before?: string | undefined, after?: string | undefined, limit?: number | undefined}; export type GetApiAccountsAccountIdMessagesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List an account's messages * * GET /accounts/{account_id}/messages */ export const getApiAccountsAccountIdMessages = async (args: GetApiAccountsAccountIdMessagesArgs, options?: GetApiAccountsAccountIdMessagesOptions) => { const {baseUrl = "https://api.salesflare.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.before != null) query.append("before", String(args.before)) if (args.after != null) query.append("after", String(args.after)) if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/accounts/${encodeURIComponent(String(args.account_id))}/messages${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() };