export type GetApiUuidVersionVersionArgs = {limit?: number | undefined, version: number, type?: unknown | undefined, text?: unknown | undefined}; export type GetApiUuidVersionVersionOptions = {baseUrl?: string | undefined, XFungeneratorsApiSecret?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate a random UUID (v4). * * GET /uuid/version/{version} */ export const getApiUuidVersionVersion = async (args: GetApiUuidVersionVersionArgs, options?: GetApiUuidVersionVersionOptions) => { const {baseUrl = "https://api.fungenerators.com", fetch: fetchFn = fetch, XFungeneratorsApiSecret} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.type != null) query.append("type", String(args.type)) if (args.text != null) query.append("text", String(args.text)) if (XFungeneratorsApiSecret !== undefined) headers.set("X-Fungenerators-Api-Secret", XFungeneratorsApiSecret) const url = `${baseUrl.replace(/\/+$/, '')}/uuid/version/${encodeURIComponent(String(args.version))}${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 (await res.json()) as unknown };