UNPKG

nylas

Version:

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

145 lines (144 loc) 5.8 kB
import { FormData } from 'formdata-node'; import APIClient from '../apiClient.js'; import { Overrides } from '../config.js'; import { CreateDraftRequest, SendMessageRequest, UpdateDraftRequest } from '../models/drafts.js'; import { CleanMessagesRequest, CleanMessagesResponse, FindMessageQueryParams, ListMessagesQueryParams, Message, ScheduledMessage, ScheduledMessagesList, StopScheduledMessageResponse, UpdateMessageRequest } from '../models/messages.js'; import { NylasBaseResponse, NylasListResponse, NylasResponse } from '../models/response.js'; import { AsyncListResponse, Resource } from './resource.js'; import { SmartCompose } from './smartCompose.js'; /** * The parameters for the {@link Messages.list} method * @property identifier The identifier of the grant to act upon * @property queryParams The query parameters to include in the request */ export interface ListMessagesParams { identifier: string; queryParams?: ListMessagesQueryParams; } /** * The parameters for the {@link Messages.find} method * @property identifier The identifier of the grant to act upon * @property messageId The id of the message to retrieve. * @property queryParams The query parameters to include in the request */ export interface FindMessageParams { identifier: string; messageId: string; queryParams?: FindMessageQueryParams; } /** * The parameters for the {@link Messages.update} method * @property identifier The identifier of the grant to act upon * @property messageId The id of the message to update * @property requestBody The values to update the message with */ export interface UpdateMessageParams { identifier: string; messageId: string; requestBody: UpdateMessageRequest; } /** * The parameters for the {@link Messages.destroy} method * @property identifier The identifier of the grant to act upon * @property messageId The id of the message to delete */ export interface DestroyMessageParams { identifier: string; messageId: string; } /** * The parameters for the {@link Messages.send} method * @property identifier The identifier of the grant to act upon * @property requestBody The message to send */ export interface SendMessageParams { identifier: string; requestBody: SendMessageRequest; } /** * The parameters for the {@link Messages.listScheduledMessages} method * @property identifier The identifier of the grant to act upon */ export interface ListScheduledMessagesParams { identifier: string; } /** * The parameters for the {@link Messages.findScheduledMessage} method * @property identifier The identifier of the grant to act upon * @property scheduleId The id of the scheduled message to retrieve. */ export interface FindScheduledMessageParams { identifier: string; scheduleId: string; } /** * The parameters for the {@link Messages.stopScheduledMessage} method * @property identifier The identifier of the grant to act upon * @property scheduleId The id of the scheduled message to destroy. */ export type StopScheduledMessageParams = FindScheduledMessageParams; /** * The parameters for the {@link Messages.cleanMessages} method * @property identifier The identifier of the grant to act upon * @property requestBody The values to clean the message with */ export interface CleanMessagesParams { identifier: string; requestBody: CleanMessagesRequest; } /** * Nylas Messages API * * The Nylas Messages API allows you to list, find, update, delete, schedule, and send messages on user accounts. */ export declare class Messages extends Resource { smartCompose: SmartCompose; static MAXIMUM_JSON_ATTACHMENT_SIZE: number; constructor(apiClient: APIClient); /** * Return all Messages * @return A list of messages */ list({ identifier, queryParams, overrides, }: ListMessagesParams & Overrides): AsyncListResponse<NylasListResponse<Message>>; /** * Return a Message * @return The message */ find({ identifier, messageId, overrides, queryParams, }: FindMessageParams & Overrides): Promise<NylasResponse<Message>>; /** * Update a Message * @return The updated message */ update({ identifier, messageId, requestBody, overrides, }: UpdateMessageParams & Overrides): Promise<NylasResponse<Message>>; /** * Delete a Message * @return The deleted message */ destroy({ identifier, messageId, overrides, }: DestroyMessageParams & Overrides): Promise<NylasBaseResponse>; /** * Send an email * @return The sent message */ send({ identifier, requestBody, overrides, }: SendMessageParams & Overrides): Promise<NylasResponse<Message>>; /** * Retrieve your scheduled messages * @return A list of scheduled messages */ listScheduledMessages({ identifier, overrides, }: ListScheduledMessagesParams & Overrides): Promise<NylasResponse<ScheduledMessagesList>>; /** * Retrieve a scheduled message * @return The scheduled message */ findScheduledMessage({ identifier, scheduleId, overrides, }: FindScheduledMessageParams & Overrides): Promise<NylasResponse<ScheduledMessage>>; /** * Stop a scheduled message * @return The confirmation of the stopped scheduled message */ stopScheduledMessage({ identifier, scheduleId, overrides, }: StopScheduledMessageParams & Overrides): Promise<NylasResponse<StopScheduledMessageResponse>>; /** * Remove extra information from a list of messages * @return The list of cleaned messages */ cleanMessages({ identifier, requestBody, overrides, }: CleanMessagesParams & Overrides): Promise<NylasListResponse<CleanMessagesResponse>>; static _buildFormRequest(requestBody: CreateDraftRequest | UpdateDraftRequest | SendMessageRequest): FormData; }