nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
70 lines (69 loc) • 2.24 kB
JavaScript
import { Resource } from './resource.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: `/v3/grants/${identifier}/folders`,
});
}
/**
* Return a Folder
* @return The folder
*/
find({ identifier, folderId, overrides, }) {
return super._find({
path: `/v3/grants/${identifier}/folders/${folderId}`,
overrides,
});
}
/**
* Create a Folder
* @return The created folder
*/
create({ identifier, requestBody, overrides, }) {
return super._create({
path: `/v3/grants/${identifier}/folders`,
requestBody,
overrides,
});
}
/**
* Update a Folder
* @return The updated Folder
*/
update({ identifier, folderId, requestBody, overrides, }) {
return super._update({
path: `/v3/grants/${identifier}/folders/${folderId}`,
requestBody,
overrides,
});
}
/**
* Delete a Folder
* @return The deleted Folder
*/
destroy({ identifier, folderId, overrides, }) {
return super._destroy({
path: `/v3/grants/${identifier}/folders/${folderId}`,
overrides,
});
}
}