UNPKG

@plunk/node

Version:

Official Node.js library for useplunk.com

42 lines (41 loc) 1.53 kB
import type { PublishParams } from "../types/events"; import type { SendParams } from "../types/emails"; export declare class Plunk { private readonly key; private readonly apiUrl; private fetch; constructor(key: string, options?: { baseUrl?: string; }); /** * Resources */ events: { /** * Publishes an event to Plunk * @param {string} event.event - The event you want to publish * @param {string} event.email - The email associated with this event * @param {Object=} event.data - The user data associated with this event * @param {boolean=true} event.subscribed - Whether the user is subscribed to marketing emails */ track: (event: PublishParams) => Promise<{ success: true; }>; }; emails: { /** * Sends a transactional email with Plunk * * @param {string} body.to - The email you want to send to * @param {string} body.subject - The subject of the email * @param {string} body.body - The body of the email * @param {string=} body.from - The email you want to send from * @param {string=} body.name - The name you want to send as * @param {string=html} body.type - The type of email you want to send * @param {boolean=false} body.subscribed - Whether the user is subscribed to marketing emails */ send: (body: SendParams) => Promise<{ success: true; }>; }; }