UNPKG

nylas

Version:

A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.

71 lines (70 loc) 2.11 kB
import { Resource } from './resource.js'; import { makePathParams } from '../utils.js'; /** * Nylas Threads API * * The Nylas Threads API allows you to list, find, update, and delete threads on user accounts. */ export class Threads extends Resource { /** * Return all Threads * @return A list of threads */ list({ identifier, queryParams, overrides, }) { const modifiedQueryParams = queryParams ? { ...queryParams } : undefined; // Transform some query params that are arrays into comma-delimited strings if (modifiedQueryParams && queryParams) { if (Array.isArray(queryParams?.anyEmail)) { delete modifiedQueryParams.anyEmail; modifiedQueryParams['any_email'] = queryParams.anyEmail.join(','); } } return super._list({ queryParams: modifiedQueryParams, overrides, path: makePathParams('/v3/grants/{identifier}/threads', { identifier }), }); } /** * Return a Thread * @return The thread */ find({ identifier, threadId, overrides, }) { return super._find({ path: makePathParams('/v3/grants/{identifier}/threads/{threadId}', { identifier, threadId, }), overrides, }); } /** * Update a Thread * @return The updated thread */ update({ identifier, threadId, requestBody, overrides, }) { return super._update({ path: makePathParams('/v3/grants/{identifier}/threads/{threadId}', { identifier, threadId, }), requestBody, overrides, }); } /** * Delete a Thread * @return The deleted thread */ destroy({ identifier, threadId, overrides, }) { return super._destroy({ path: makePathParams('/v3/grants/{identifier}/threads/{threadId}', { identifier, threadId, }), overrides, }); } }