export type CreateApiMgGenagentV1EngageArgs = {body: {namespace: 'amazonconnect', guid: string, language?: 'en-US' | undefined, inputVariables?: Record | undefined, amazonConnectParams?: ({streamArn?: string | undefined}) | undefined, customerId: string}}; export type CreateApiMgGenagentV1EngageOptions = {baseUrl?: string | undefined, APIID?: string | undefined, APISecret?: string | undefined, fetch?: typeof fetch | undefined}; /** * Engage Genagent in a conversation. * * POST /mg-genagent/v1/engage */ export const createApiMgGenagentV1Engage = async (args: CreateApiMgGenagentV1EngageArgs, options?: CreateApiMgGenagentV1EngageOptions) => { const {baseUrl = "https://api.sandbox.asapp.com", fetch: fetchFn = fetch, APIID, APISecret} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIID !== undefined) headers.set("asapp-api-id", APIID) if (APISecret !== undefined) headers.set("asapp-api-secret", APISecret) const url = `${baseUrl.replace(/\/+$/, '')}/mg-genagent/v1/engage${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 };