nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
81 lines (80 loc) • 2.64 kB
JavaScript
import { Resource } from './resource.js';
import { makePathParams } from '../utils.js';
/**
* Nylas Folder API
*
* Email providers use folders to store and organize email messages. Examples of common system folders include Inbox, Sent, Drafts, etc.
*
* If your team is migrating from Nylas APIv2, there were previously two separate endpoints for interacting with Folders (Microsoft) and Labels (Google).
* In Nylas API v3, these endpoints are consolidated under Folders.
*
* To simplify the developer experience, Nylas uses the same folders commands to manage both folders and labels, using the folder_id key to refer to the folder's ID on the provider.
* The API also exposes provider-specific fields such as background_color (Google only).
*
* Depending on the provider (Google, some IMAP providers, etc.), a message can be contained in more than one folder.
*/
export class Folders extends Resource {
/**
* Return all Folders
* @return A list of folders
*/
list({ identifier, queryParams, overrides, }) {
return super._list({
overrides,
queryParams,
path: makePathParams('/v3/grants/{identifier}/folders', { identifier }),
});
}
/**
* Return a Folder
* @return The folder
*/
find({ identifier, folderId, queryParams, overrides, }) {
return super._find({
path: makePathParams('/v3/grants/{identifier}/folders/{folderId}', {
identifier,
folderId,
}),
queryParams,
overrides,
});
}
/**
* Create a Folder
* @return The created folder
*/
create({ identifier, requestBody, overrides, }) {
return super._create({
path: makePathParams('/v3/grants/{identifier}/folders', { identifier }),
requestBody,
overrides,
});
}
/**
* Update a Folder
* @return The updated Folder
*/
update({ identifier, folderId, requestBody, overrides, }) {
return super._update({
path: makePathParams('/v3/grants/{identifier}/folders/{folderId}', {
identifier,
folderId,
}),
requestBody,
overrides,
});
}
/**
* Delete a Folder
* @return The deleted Folder
*/
destroy({ identifier, folderId, overrides, }) {
return super._destroy({
path: makePathParams('/v3/grants/{identifier}/folders/{folderId}', {
identifier,
folderId,
}),
overrides,
});
}
}