nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
75 lines (74 loc) • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = void 0;
const resource_js_1 = require("./resource.js");
const utils_js_1 = require("../utils.js");
/**
* Nylas Threads API
*
* The Nylas Threads API allows you to list, find, update, and delete threads on user accounts.
*/
class Threads extends resource_js_1.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: (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/threads', { identifier }),
});
}
/**
* Return a Thread
* @return The thread
*/
find({ identifier, threadId, overrides, }) {
return super._find({
path: (0, utils_js_1.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: (0, utils_js_1.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: (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/threads/{threadId}', {
identifier,
threadId,
}),
overrides,
});
}
}
exports.Threads = Threads;