// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as SharedAPI from './shared'; import * as MessageAPI from '../message/message'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class Messages extends APIResource { /** * Get messages from a specific conversation with optional limit and date * filtering. */ list( conversationID: string, params: MessageListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'If-None-Match': ifNoneMatch, 'X-Error-Format': xErrorFormat, ...query } = params ?? {}; return this._client.get(path`/conversations/${conversationID}`, { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(ifNoneMatch != null ? { 'If-None-Match': ifNoneMatch } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Response model for getting conversation messages. * * Attributes: conversation (Conversation): The conversation details. messages * (list[Message]): List of messages in the conversation. attachments * (list[dict[str, Any]]): List of attachments related to the messages. */ export interface MessageListResponse { attachments: Array<{ [key: string]: unknown }>; /** * Conversation model. * * Attributes: id (str): The conversation ID. user*id (str): The user ID. title * (str | None): The conversation title. created_time (datetime): The creation * time. updated_time (datetime): The last update time. is_active (bool): Whether * the conversation is active. chatbot_id (str): The chatbot ID. is_anonymized * (bool): Whether the conversation is anonymized. deanonymized_mapping (dict[str, * str]): Mapping of anonymized to original values. first_matching_message_id (str * | None): First message ID that matches search query. first_matching_message (str * | None): First message that matches search query. metadata* (dict[str, Any] | * None): Additional metadata for the conversation. digital_employee_id (str | * None): The active Digital Employee's local id, or None if no Digital Employee is * active on this conversation. de_activated_at (datetime | None): When the active * Digital Employee became active. */ conversation: SharedAPI.Conversation; messages: Array; } export interface MessageListParams { /** * Query param: Maximum number of messages to return */ limit?: number | null; /** * Query param */ max_date?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param */ 'If-None-Match'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Messages { export { type MessageListResponse as MessageListResponse, type MessageListParams as MessageListParams }; }