UNPKG

gmail-getter

Version:

A simple tool that gets emails from the Gmail API

23 lines (22 loc) 1.09 kB
import { Email } from './api'; export type CheckInboxOptions<T extends boolean = false> = { token: string; timeout?: number; step?: number; all?: T; query?: string; logs?: boolean; }; /** * Check Gmail inbox * @param {CheckInboxOptions} options - The Options object * @param {string} options.token OAuth Access token * @param {number} [options.timeout=15000] Function timeout (ms) * @param {number} [options.step=1500] Time between retries (ms) * @param {boolean} [options.all=false] Whether to find a single email or all mathing the query criteria * @param {string} [options.query] Query that specifies search criteria (https://support.google.com/mail/answer/7190) * @param {boolean} [options.logs=true] Whether to log every attempt to get emails or not * @returns {Promise<Email | Email[]>} Email contents * @example const email = await checkInbox({token: 'ya01.a123456...', query: 'from:squier7 subject:Test!'}) */ export declare const checkInbox: <T extends boolean = false>(options: CheckInboxOptions<T>) => Promise<T extends true ? Email[] : Email>;