{"version":3,"file":"MessagesApi.cjs","names":["BaseCrudApi"],"sources":["../../../src/apis/messages/MessagesApi.ts"],"sourcesContent":["import qs from 'qs'\nimport type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type {\n  Message,\n  CreateMessagePayload,\n  UpdateMessagePayload,\n  ForwardMessagesPayload,\n  ForwardMessagesResult,\n  SendVcardsPayload,\n  SendReactionPayload,\n  MagicTextPayload,\n  MagicTextResult,\n  CheckSummaryPayload,\n  CheckSummaryResult,\n  BulkDestroyPayload,\n  OutOfRangeResult,\n  LoadAroundQuery,\n} from './types'\n\nexport class MessagesApi extends BaseCrudApi<Message, CreateMessagePayload, UpdateMessagePayload> {\n  constructor(client: ApiClient) {\n    super(client, '/messages')\n  }\n\n  /** Forwards one or more messages to one or more contacts (max 20 messages to 5 contacts). */\n  forward(\n    body: ForwardMessagesPayload,\n    headers?: Record<string, string>,\n  ): Promise<ForwardMessagesResult> {\n    return this.client.post<ForwardMessagesResult, ForwardMessagesPayload>(\n      `${this.basePath}/forward`,\n      body,\n      headers,\n    )\n  }\n\n  /** Revokes (soft-deletes) a sent message so it is no longer visible to the recipient. */\n  revoke(id: string, headers?: Record<string, string>): Promise<Message> {\n    return this.client.post<Message>(`${this.basePath}/${id}/revoke`, undefined, headers)\n  }\n\n  /** Removes a previously sent reaction from a message. */\n  revokeReaction(id: string, headers?: Record<string, string>): Promise<boolean> {\n    return this.client.put<boolean>(`${this.basePath}/${id}/revoke-reaction`, undefined, headers)\n  }\n\n  /** Sends one or more contacts as vCard messages to a given contact. */\n  sendVcards(body: SendVcardsPayload, headers?: Record<string, string>): Promise<Message> {\n    return this.client.post<Message, SendVcardsPayload>(\n      `${this.basePath}/send-vcards`,\n      body,\n      headers,\n    )\n  }\n\n  /** Sends an emoji reaction to a message. */\n  sendReaction(\n    id: string,\n    body: SendReactionPayload,\n    headers?: Record<string, string>,\n  ): Promise<boolean> {\n    return this.client.post<boolean, SendReactionPayload>(\n      `${this.basePath}/${id}/send-reaction`,\n      body,\n      headers,\n    )\n  }\n\n  /** Uses AI to rewrite or correct a message text with a given tone (e.g. \"correct\", \"professional\", \"casual\"). */\n  magicText(body: MagicTextPayload, headers?: Record<string, string>): Promise<MagicTextResult> {\n    return this.client.post<MagicTextResult, MagicTextPayload>(\n      `${this.basePath}/magic-text`,\n      body,\n      headers,\n    )\n  }\n\n  /** Checks whether an AI-generated summary already exists for a given ticket. */\n  checkSummary(\n    body: CheckSummaryPayload,\n    headers?: Record<string, string>,\n  ): Promise<CheckSummaryResult> {\n    return this.client.post<CheckSummaryResult, CheckSummaryPayload>(\n      `${this.basePath}/check-summary`,\n      body,\n      headers,\n    )\n  }\n\n  /**\n   * Deletes multiple messages matching the given where clause.\n   * @permissions messages.destroy\n   */\n  bulkDestroy(body: BulkDestroyPayload, headers?: Record<string, string>): Promise<boolean> {\n    return this.client.request<boolean, BulkDestroyPayload>(\n      'DELETE',\n      `${this.basePath}/many`,\n      body,\n      headers,\n    )\n  }\n\n  /** Triggers an AI-generated summary for the conversation associated with the given message. */\n  summarize(id: string, headers?: Record<string, string>): Promise<void> {\n    return this.client.post<void>(`${this.basePath}/${id}/summarize`, undefined, headers)\n  }\n\n  /** Checks whether a message is out of the visible range (i.e. there are more than `limit` messages after it). */\n  outOfRange(\n    id: string,\n    limit?: number,\n    headers?: Record<string, string>,\n  ): Promise<OutOfRangeResult> {\n    const queryString = limit ? `?${qs.stringify({ limit })}` : ''\n    return this.client.get<OutOfRangeResult>(\n      `${this.basePath}/${id}/out-of-range${queryString}`,\n      headers,\n    )\n  }\n\n  /** Re-downloads and syncs the file attachment for a message from the messaging service. */\n  syncFile(id: string, headers?: Record<string, string>): Promise<unknown> {\n    return this.client.post<unknown>(`${this.basePath}/${id}/sync-file`, undefined, headers)\n  }\n\n  /** Loads messages surrounding a target message (N before and N after), useful for jumping to a specific point in a conversation. */\n  around(\n    id: string,\n    query?: LoadAroundQuery,\n    headers?: Record<string, string>,\n  ): Promise<Message[]> {\n    const queryString = query ? `?${qs.stringify(query)}` : ''\n    return this.client.get<Message[]>(`${this.basePath}/${id}/around${queryString}`, headers)\n  }\n}\n"],"mappings":";;;;;;;AAoBA,IAAa,cAAb,cAAiCA,qCAAiE;CAChG,YAAY,QAAmB;AAC7B,QAAM,QAAQ,YAAY;;;CAI5B,QACE,MACA,SACgC;AAChC,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,WACjB,MACA,QACD;;;CAIH,OAAO,IAAY,SAAoD;AACrE,SAAO,KAAK,OAAO,KAAc,GAAG,KAAK,SAAS,GAAG,GAAG,UAAU,QAAW,QAAQ;;;CAIvF,eAAe,IAAY,SAAoD;AAC7E,SAAO,KAAK,OAAO,IAAa,GAAG,KAAK,SAAS,GAAG,GAAG,mBAAmB,QAAW,QAAQ;;;CAI/F,WAAW,MAAyB,SAAoD;AACtF,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,eACjB,MACA,QACD;;;CAIH,aACE,IACA,MACA,SACkB;AAClB,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,GAAG,iBACvB,MACA,QACD;;;CAIH,UAAU,MAAwB,SAA4D;AAC5F,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,cACjB,MACA,QACD;;;CAIH,aACE,MACA,SAC6B;AAC7B,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,iBACjB,MACA,QACD;;;;;;CAOH,YAAY,MAA0B,SAAoD;AACxF,SAAO,KAAK,OAAO,QACjB,UACA,GAAG,KAAK,SAAS,QACjB,MACA,QACD;;;CAIH,UAAU,IAAY,SAAiD;AACrE,SAAO,KAAK,OAAO,KAAW,GAAG,KAAK,SAAS,GAAG,GAAG,aAAa,QAAW,QAAQ;;;CAIvF,WACE,IACA,OACA,SAC2B;EAC3B,MAAM,cAAc,QAAQ,IAAI,WAAG,UAAU,EAAE,OAAO,CAAC,KAAK;AAC5D,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,GAAG,GAAG,eAAe,eACtC,QACD;;;CAIH,SAAS,IAAY,SAAoD;AACvE,SAAO,KAAK,OAAO,KAAc,GAAG,KAAK,SAAS,GAAG,GAAG,aAAa,QAAW,QAAQ;;;CAI1F,OACE,IACA,OACA,SACoB;EACpB,MAAM,cAAc,QAAQ,IAAI,WAAG,UAAU,MAAM,KAAK;AACxD,SAAO,KAAK,OAAO,IAAe,GAAG,KAAK,SAAS,GAAG,GAAG,SAAS,eAAe,QAAQ"}