UNPKG

@brandcast_app/zoomshift-api-client

Version:

Unofficial TypeScript/JavaScript client for ZoomShift employee scheduling API (reverse-engineered)

105 lines (104 loc) 3.1 kB
/** * ZoomShift API Client * * Unofficial TypeScript client for ZoomShift employee scheduling. * Based on reverse-engineering ZoomShift's internal JSON endpoints. * * @license MIT * @see https://github.com/jduncan-rva/zoomshift-api-client */ import { ZoomShiftClientOptions, ZoomShiftAuthResponse, ZoomShiftShift, GetShiftsRequest } from './types'; /** * Main ZoomShift API client class * * @example * ```typescript * const client = new ZoomShiftClient({ debug: true }); * * // Authenticate * await client.authenticate('user@example.com', 'password', '58369'); * * // Get shifts * const shifts = await client.getShifts({ * startDate: '2025-10-10', * endDate: '2025-10-17' * }); * ``` */ export declare class ZoomShiftClient { private client; private authenticated; private scheduleId; private cookieJar; private debug; private static readonly BASE_URL; constructor(options?: ZoomShiftClientOptions); /** * Authenticate with ZoomShift * * @param email - ZoomShift account email * @param password - ZoomShift account password * @param scheduleId - ZoomShift schedule ID (found in URL) * @returns Authentication response with schedule info * @throws {ZoomShiftError} If authentication fails * * @example * ```typescript * const auth = await client.authenticate( * 'manager@example.com', * 'mypassword', * '58369' * ); * console.log('Authenticated:', auth.authenticated); * ``` */ authenticate(email: string, password: string, scheduleId: string): Promise<ZoomShiftAuthResponse>; /** * Get shifts for a date range * * @param request - Request parameters (date range, filters) * @returns Array of shift objects * @throws {ZoomShiftError} If not authenticated or request fails * * @example * ```typescript * const shifts = await client.getShifts({ * startDate: '2025-10-10', * endDate: '2025-10-17', * employeeId: '12345', // optional * location: 'Main Store' // optional * }); * ``` */ getShifts(request: GetShiftsRequest): Promise<ZoomShiftShift[]>; /** * Transform ZoomShift API response to standardized format * ZoomShift uses JSON:API format with data/attributes structure */ private transformShifts; /** * Map ZoomShift status flags to our standard status * * ZoomShift doesn't have explicit status field, but we can infer from: * - published: boolean - shift is published to schedule * - confirmed: boolean - shift is confirmed by employee * - start_at/end_at timestamps - can determine if in progress or completed */ private mapStatus; /** * Check if client is authenticated */ isAuthenticated(): boolean; /** * Get the schedule ID */ getScheduleId(): string | null; /** * Create a standardized error object */ private createError; /** * Type guard for ZoomShiftError */ private isZoomShiftError; }