get-mexican-data-by-curp
Version:
Verify CURP and obtain personal information from the Mexican government CURP. It scrapes official site and another providers.
26 lines (25 loc) • 776 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MexicanFinder = void 0;
class MexicanFinder {
constructor(...providers) {
this.providers = providers;
this.startState = this.providers[0].constructor.name;
this.state = this.startState;
}
finalState() {
return this.state;
}
async findByCurp(id) {
this.state = this.startState;
for (const provider of this.providers) {
const mexican = await provider.provide(id);
this.state = provider.constructor.name;
if (mexican !== null) {
return mexican;
}
}
throw new Error('Server error. CURP not found.');
}
}
exports.MexicanFinder = MexicanFinder;