export type GetApiApiTradesWeeklyStatsExchangeAddressPairNameArgs = {exchangeAddress: string, pairName: string, fromYear: number, fromWeek: number, toYear: number, toWeek: number}; export type GetApiApiTradesWeeklyStatsExchangeAddressPairNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get trade weekly stats * * GET /api/trades/weeklyStats/{exchangeAddress}/{pairName} */ export const getApiApiTradesWeeklyStatsExchangeAddressPairName = async (args: GetApiApiTradesWeeklyStatsExchangeAddressPairNameArgs, options: GetApiApiTradesWeeklyStatsExchangeAddressPairNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.fromYear != null) query.append("fromYear", String(args.fromYear)) if (args.fromWeek != null) query.append("fromWeek", String(args.fromWeek)) if (args.toYear != null) query.append("toYear", String(args.toYear)) if (args.toWeek != null) query.append("toWeek", String(args.toWeek)) const url = `${baseUrl.replace(/\/+$/, '')}/api/trades/weeklyStats/${encodeURIComponent(String(args.exchangeAddress))}/${encodeURIComponent(String(args.pairName))}${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 };