UNPKG

extralife-donation-notifier

Version:

A node/browser library for giving realtime events when your extralife campaign receives a donation

57 lines (56 loc) 1.57 kB
import EventEmitter from 'eventemitter3'; export type ExtraLifeDonation = { participantID: number; amount: number; avatarImageURL: string; createdDateUTC: string; donationID: string; displayName?: string; message?: string; teamID?: number; donorID?: string; eventID: number; recipientName: string; links: { recipient: string; }; }; export type ExtraLifeDonationWatcherOptions = { participantId?: string; teamId?: string; }; export interface IExtraLifeDonationWatcher { start(): void; stop(): void; } export interface IExtraLifeDonationWatcherEvents { 'team-donation': (donation: ExtraLifeDonation) => void; 'participant-donation': (donation: ExtraLifeDonation) => void; ping: () => void; started: () => void; error: (e: any) => void; } export declare class ExtraLifeDonationWatcher extends EventEmitter<IExtraLifeDonationWatcherEvents> implements IExtraLifeDonationWatcher { private _participantId?; private _teamId?; private _donationCheckInterval?; private _lastCheck; private _stopped; constructor(options: ExtraLifeDonationWatcherOptions); /** * Begins listening on the configured participant and team IDs */ start(): void; /** * Stops the object from listening for more donations */ stop(): void; /** * Private methods */ private _runCycle; private _processDonations; private _emitRecentTeamDonations; private _emitRecentParticipantDonations; private _emitValidDonations; }