UNPKG

ci-validation

Version:

🇺🇾 Complete TypeScript/JavaScript library for validating Uruguayan CI (Cédula de Identidad) with official algorithm and government service integration

143 lines • 4.1 kB
/** * Interface for San Roque member data */ export interface SanRoqueMember { tipoDocumento: string; cedula: string; nombres: string; apellidos: string; email: string; estado: string; } /** * Interface for San Roque points data */ export interface SanRoquePoints { puntosDisponibles: string; vencimiento30: string; vencimiento60?: string; vencimiento90?: string; [key: string]: string | undefined; } /** * Interface for San Roque API response */ export interface SanRoqueApiResponse { socio?: SanRoqueMember; puntos?: SanRoquePoints; error?: string; } /** * Interface for San Roque service response */ export interface SanRoqueResponse { success: boolean; hasUser: boolean; error?: string; member?: { ci: string; documentType: string; firstName: string; lastName: string; email: string; status: 'active' | 'inactive' | 'unknown'; executionTime: number; }; points?: { available: number; expiring30Days: number; expiring60Days?: number; expiring90Days?: number; total: number; }; } /** * Interface for San Roque request parameters */ export interface SanRoqueRequest { ci: string; documentType?: string; } /** * San Roque Service Class * Handles member validation and points query for Tarjeta San Roque (tarjetasanroque.com.uy) * * This service checks if a user is a member of the San Roque loyalty program * and retrieves their points information. */ export declare class SanRoqueService { private readonly baseUrl; private readonly endpoint; private readonly timeout; /** * Default headers for San Roque requests * Based on the original curl request */ private getDefaultHeaders; /** * Creates request payload for the San Roque API * @param ci - Cédula de identidad (without dots or dashes) * @param documentType - Document type (default: "CI") * @returns Request payload object */ private createRequestPayload; /** * Validates CI format before making the request * @param ci - Cédula de identidad * @returns boolean */ private validateCI; /** * Normalizes CI by removing any formatting * @param ci - Cédula de identidad * @returns Normalized CI string */ private normalizeCI; /** * Converts string numbers to actual numbers, handling empty strings * @param value - String value that might be a number * @returns Number or 0 if invalid */ private parsePoints; /** * Parses the San Roque API response * @param response - Axios response * @param ci - Original CI for context * @returns Parsed SanRoqueResponse */ private parseResponse; /** * Checks if a user is a member of San Roque and retrieves their information * @param request - San Roque request parameters * @returns Promise<SanRoqueResponse> */ checkMember(request: SanRoqueRequest): Promise<SanRoqueResponse>; /** * Convenience method to check if a user is a member by CI only * @param ci - Cédula de identidad * @returns Promise<boolean> */ isMember(ci: string): Promise<boolean>; /** * Get member points from San Roque system * @param ci - Cédula de identidad * @returns Promise<number> */ getMemberPoints(ci: string): Promise<number>; /** * Get total member points (available + expiring) from San Roque system * @param ci - Cédula de identidad * @returns Promise<number> */ getTotalMemberPoints(ci: string): Promise<number>; /** * Get comprehensive member information from San Roque system * @param ci - Cédula de identidad * @param documentType - Document type (optional) * @returns Promise<SanRoqueResponse> */ getMemberInfo(ci: string, documentType?: string): Promise<SanRoqueResponse>; } declare const _default: SanRoqueService; export default _default; //# sourceMappingURL=SanRoque.d.ts.map