export type GetApiFeaturedArgs = {country?: ('SG' | 'US' | 'VN' | 'TH' | 'MY') | undefined, country_code?: ('SG' | 'US' | 'VN' | 'TH' | 'MY') | undefined, currency?: string | undefined, limit?: number | undefined, offset?: number | undefined, compact?: boolean | undefined}; export type GetApiFeaturedOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get featured products (newest active products) * * GET /featured */ export const getApiFeatured = async (args: GetApiFeaturedArgs, options?: GetApiFeaturedOptions) => { const {baseUrl = "https://api.buywhere.ai/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.country != null) query.append("country", String(args.country)) if (args.country_code != null) query.append("country_code", String(args.country_code)) if (args.currency != null) query.append("currency", String(args.currency)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.compact != null) query.append("compact", String(args.compact)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/featured${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 };