export type GetApiConsumersTenantArgs = {tenant: string, emailAddress: string, accountType: 'registered', count: string}; export type GetApiConsumersTenantOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get consumers details * * GET /consumers/{tenant} */ export const getApiConsumersTenant = async (args: GetApiConsumersTenantArgs, options?: GetApiConsumersTenantOptions) => { const {baseUrl = "https://uk.api.just-eat.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.emailAddress != null) query.append("emailAddress", String(args.emailAddress)) if (args.accountType != null) query.append("accountType", String(args.accountType)) if (args.count != null) query.append("count", String(args.count)) const url = `${baseUrl.replace(/\/+$/, '')}/consumers/${encodeURIComponent(String(args.tenant))}${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 res.text() };