export type GetApiMethodGetParameterValuesArgs = {DatasetName: string, parametername: string, ResultFormat?: ('JSON' | 'XML') | undefined}; export type GetApiMethodGetParameterValuesOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * List valid values for a parameter * * GET /?Method=GetParameterValues */ export const getApiMethodGetParameterValues = async (args: GetApiMethodGetParameterValuesArgs, options?: GetApiMethodGetParameterValuesOptions) => { const {baseUrl = "https://apps.bea.gov/api/data", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.DatasetName != null) query.append("DatasetName", String(args.DatasetName)) if (args.parametername != null) query.append("parametername", String(args.parametername)) if (args.ResultFormat != null) query.append("ResultFormat", String(args.ResultFormat)) if (ApiKey !== undefined) query.set("UserID", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/?Method=GetParameterValues${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 };