Skip to content
← Public packages

@danj/hey-email

HEY.com email for Kody: search threads, read messages, download PDF attachments, and write drafts. Sending is barred until you allow it.

src/entries.js

19 lines · 628 B · JavaScript
Raw
import { heyFetch } from './client.js'

/**
 * List entries (messages) in a HEY topic.
 * Use when reading full purchase/shipping thread bodies after search.
 *
 * @param {{ topicId: number|string }} input
 * @returns {Promise<unknown[]>}
 *
 * @example
 * import getEntries from 'kody:@danj/hey-email/entries'
 * const entries = await getEntries({ topicId: 123456789 })
 */
export default async function getEntries(input) {
  const topicId = input?.topicId
  if (topicId == null) throw new Error('topicId is required')
  const data = await heyFetch(`/topics/${topicId}/entries.json`)
  return Array.isArray(data) ? data : []
}