export type GetApiTradesTransactionsArgs = {size?: number | undefined, page?: number | undefined, status?: string | undefined, address?: string | undefined, assetId?: string | undefined}; export type GetApiTradesTransactionsOptions = {baseUrl?: string | undefined, appId?: string | undefined, appSecret?: string | undefined, breetEnv?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetch Transactions * * GET /trades/transactions */ export const getApiTradesTransactions = async (args: GetApiTradesTransactionsArgs, options?: GetApiTradesTransactionsOptions) => { const {baseUrl = "https://api.breet.io/v1", fetch: fetchFn = fetch, appId, appSecret, breetEnv} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.size != null) query.append("size", String(args.size)) if (args.page != null) query.append("page", String(args.page)) if (args.status != null) query.append("status", String(args.status)) if (args.address != null) query.append("address", String(args.address)) if (args.assetId != null) query.append("assetId", String(args.assetId)) if (appId !== undefined) headers.set("x-app-id", appId) if (appSecret !== undefined) headers.set("x-app-secret", appSecret) if (breetEnv !== undefined) headers.set("X-Breet-Env", breetEnv) const url = `${baseUrl.replace(/\/+$/, '')}/trades/transactions${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 (await res.json()) as unknown };