// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; 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 Share extends APIResource { /** * Fetch the active share-link details for a conversation without mutating * anything. */ list( conversationID: string, params: ShareListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'If-None-Match': ifNoneMatch, 'X-Error-Format': xErrorFormat, } = params ?? {}; return this._client.get(path`/conversations/${conversationID}/share`, { ...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, ]), }); } /** * Create a shareable link for a conversation with optional expiry days. */ createOrUpdate( conversationID: string, params: ShareCreateOrUpdateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params ?? {}; return this._client.post(path`/conversations/${conversationID}/share`, { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Response model for sharing a conversation. * * Attributes: shared_conversation_id (str): The unique identifier for the shared * conversation. last_updated_time (datetime): The last time the shared * conversation was updated. expired_time (datetime | None): When the shared * conversation access id expires. Defaults to None (no expiry). */ export interface SharedConversation { last_updated_time: string; shared_conversation_id: string; expired_time?: string | null; } export interface ShareListParams { 'Accept-Language'?: string; 'If-None-Match'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface ShareCreateOrUpdateParams { /** * Body param */ expiry_days?: number | null; /** * Header param */ 'Accept-Language'?: 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 Share { export { type SharedConversation as SharedConversation, type ShareListParams as ShareListParams, type ShareCreateOrUpdateParams as ShareCreateOrUpdateParams, }; }