import {z} from 'zod' export type GetApiApiV1LiveTrackingGuildIlvlHistoryBatchArgs = {access_key?: string | undefined, raid: 'the-unbinding-of-kithix' | 'the-venomous-abyss' | 'the-tidebound-grotto' | 'sporefall' | 'tier-mn-1' | 'manaforge-omega' | 'liberation-of-undermine' | 'nerubar-palace' | 'blackrock-depths' | 'awakened-amirdrassil-the-dreams-hope' | 'awakened-aberrus-the-shadowed-crucible' | 'awakened-vault-of-the-incarnates' | 'amirdrassil-the-dreams-hope' | 'aberrus-the-shadowed-crucible' | 'vault-of-the-incarnates' | 'fated-sepulcher-of-the-first-ones' | 'fated-sanctum-of-domination' | 'fated-castle-nathria' | 'sepulcher-of-the-first-ones' | 'sanctum-of-domination' | 'castle-nathria' | 'nyalotha-the-waking-city' | 'the-eternal-palace' | 'crucible-of-storms' | 'battle-of-dazaralor' | 'uldir' | 'antorus-the-burning-throne' | 'tomb-of-sargeras' | 'the-nighthold' | 'trial-of-valor' | 'the-emerald-nightmare' | 'latest', top_n?: number | undefined, difficulty?: ('mythic' | 'heroic' | 'normal' | 'latest') | undefined, include_pulls?: boolean | undefined, pulls_difficulty?: string | undefined, pulls_scope?: ('cohort' | 'all') | undefined, bucket?: ('15min' | 'hour' | '6hour' | 'day') | undefined, scope?: ('all' | 'mains') | undefined, min_date?: string | undefined, max_date?: string | undefined, guilds: string}; export type GetApiApiV1LiveTrackingGuildIlvlHistoryBatchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const model9 = z.object({}); export const guilds2 = z.array(model9); export const model10 = z.object({guild: z.string(), error: z.string()}); export const errors = z.array(model10); export const viewGuildIlvlHistoryBatchResponse = z.object({guilds: guilds2, errors: errors}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Retrieve item level history for up to 10 guilds in one comparison request. * * GET /api/v1/live-tracking/guild/ilvl-history/batch */ export const getApiApiV1LiveTrackingGuildIlvlHistoryBatch = async (args: GetApiApiV1LiveTrackingGuildIlvlHistoryBatchArgs, options?: GetApiApiV1LiveTrackingGuildIlvlHistoryBatchOptions) => { const {baseUrl = "http://raider.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.access_key != null) query.append("access_key", String(args.access_key)) if (args.raid != null) query.append("raid", String(args.raid)) if (args.top_n != null) query.append("top_n", String(args.top_n)) if (args.difficulty != null) query.append("difficulty", String(args.difficulty)) if (args.include_pulls != null) query.append("include_pulls", String(args.include_pulls)) if (args.pulls_difficulty != null) query.append("pulls_difficulty", String(args.pulls_difficulty)) if (args.pulls_scope != null) query.append("pulls_scope", String(args.pulls_scope)) if (args.bucket != null) query.append("bucket", String(args.bucket)) if (args.scope != null) query.append("scope", String(args.scope)) if (args.min_date != null) query.append("min_date", String(args.min_date)) if (args.max_date != null) query.append("max_date", String(args.max_date)) if (args.guilds != null) query.append("guilds", String(args.guilds)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/live-tracking/guild/ilvl-history/batch${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 validateResponse(viewGuildIlvlHistoryBatchResponse, await res.json()) };