export type GetApiMacroEconomicSeriesKeyDerivedArgs = {key: string, metric?: string | undefined, from?: string | undefined, to?: string | undefined}; export type GetApiMacroEconomicSeriesKeyDerivedOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Chỉ số kho tự tính của một chuỗi (tăng trưởng so cùng kỳ / kỳ trước - hiện có cho xuất, nhập khẩu tháng của Hải quan) * * GET /macro-economic/series/{key}/derived */ export const getApiMacroEconomicSeriesKeyDerived = async (args: GetApiMacroEconomicSeriesKeyDerivedArgs, options?: GetApiMacroEconomicSeriesKeyDerivedOptions) => { const {baseUrl = "https://api.fireant.vn", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.metric != null) query.append("metric", String(args.metric)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/macro-economic/series/${encodeURIComponent(String(args.key))}/derived${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 };