// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as ShareAPI from '../conversations/share'; import * as ConversationsSharedAPI from '../conversations/shared'; 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 Shared extends APIResource { /** * Get a shared conversation by its share ID, including all messages and * attachments. NOTE: This endpoint is DEPRECATED and will be removed soon. Please * use `GET /conversations/shared/{shared_conversation_id}` instead. * * @deprecated Use `conversations.shared.retrieve` instead. */ retrieve( sharedConversationID: string, params: SharedRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get(path`/conversation/shared/${sharedConversationID}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Fetch the active share-link details for a conversation without mutating * anything. NOTE: This endpoint is DEPRECATED and will be removed soon. Please use * `GET /conversations/{conversation_id}/share` instead. * * @deprecated Use `conversations.shaare.list` instead. */ list( conversationID: string, params: SharedListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get(path`/conversation/${conversationID}/share`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Delete a shared conversation by its share ID. NOTE: This endpoint is DEPRECATED * and will be removed soon. Please use * `DELETE /conversations/shared/{shared_conversation_id}` instead. * * @deprecated Use `conversations.shared.delete` instead. */ delete( sharedConversationID: string, params: SharedDeleteParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.delete(path`/conversation/shared/${sharedConversationID}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Clone a shared conversation to a new conversation. NOTE: This endpoint is * DEPRECATED and will be removed soon. Please use * `POST /conversations/shared/{shared_conversation_id}/clone` instead. * * @deprecated Use `conversations.shared.clone` instead. */ clone( sharedConversationID: string, params: SharedCloneParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/conversation/shared/${sharedConversationID}/clone`, { 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, ]), }); } } export type SharedDeleteResponse = { [key: string]: string }; export type SharedCloneResponse = unknown; export interface SharedRetrieveParams { 'Accept-Language'?: 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 SharedListParams { 'Accept-Language'?: 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 SharedDeleteParams { 'Accept-Language'?: 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 SharedCloneParams { /** * Body param */ old_parent_id: string; /** * Body param */ user_id: string; /** * Body param */ new_conversation_id?: string | 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 Shared { export { type SharedDeleteResponse as SharedDeleteResponse, type SharedCloneResponse as SharedCloneResponse, type SharedRetrieveParams as SharedRetrieveParams, type SharedListParams as SharedListParams, type SharedDeleteParams as SharedDeleteParams, type SharedCloneParams as SharedCloneParams, }; }