export type CreateApiV2MemoryUsersSetArgs = {'x-hash-ttl'?: number | undefined, body: {userReferenceId: string, botId: string, values: {[key: string]: {value: unknown, ttl?: number | undefined, contentType?: string | undefined}}}}; export type CreateApiV2MemoryUsersSetOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save records * * POST /v2/memory/users/set */ export const createApiV2MemoryUsersSet = async (args: CreateApiV2MemoryUsersSetArgs, options?: CreateApiV2MemoryUsersSetOptions) => { const {baseUrl = "https://api.jelou.ai", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-hash-ttl'] != null) headers.set("x-hash-ttl", String(args['x-hash-ttl'])) if (apiKey !== undefined) headers.set("x-api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/memory/users/set${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };