crs-screening
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

crs-screening

This system has 3 screening processes.
1_ onFico
2_ onCriminalReport
3_ onEvictionReport

export class CrsScreening {
   private crs: CrsBase;

   constructor(crs: CrsBase) {
       this.crs = crs;
   }

   // Method for handling FICO-related screening
   public onFico: CrsScreeningProps["onFico"]["function"] = async (
       data: CrsScreeningProps["onFico"]["props"],
   ) => {
       // Validate FICO data using a FICO validator
       const valid = Validators.ValidatorFico.onValidate(data);
       if (valid !== true) {
           return valid; // Return validation error if data is not valid
       }

       // If data is valid, make a request to the FICO endpoint
       const url = "/equifax/credit-report";
       return await this.crs.onRequest<
           CrsScreeningProps["onFico"]["props"],
           CrsScreeningProps["onFico"]["result"]
       >(
           {
               url,
               data,
               method: "post",
           },
           {
               validateToken: true,
           },
       );
   };

   // Method for handling criminal report screening
   public onCriminalReport: CrsScreeningProps["onCriminalReport"]["function"] =
       async (data: CrsScreeningProps["onCriminalReport"]["props"]) => {
           // Validate criminal report data using a validator
           const valid = Validators.ValidatorCriminalReport.onValidate(data);
           if (valid !== true) {
               return valid; // Return validation error if data is not valid
           }

           // If data is valid, make a request to the criminal report endpoint
           const url = "/criminal/new-request";
           return await this.crs.onRequest<
               CrsScreeningProps["onCriminalReport"]["props"],
               CrsScreeningProps["onCriminalReport"]["result"]
           >(
               {
                   url,
                   data,
                   method: "post",
               },
               {
                   validateToken: true,
               },
           );
       };

   // Method for handling eviction report screening
   public onEvictionReport: CrsScreeningProps["onEvictionReport"]["function"] =
       async (data: CrsScreeningProps["onEvictionReport"]["props"]) => {
           // Validate eviction report data using a validator
           const valid = Validators.ValidatorEvictionReport.onValidate(data);
           if (valid !== true) {
               return valid; // Return validation error if data is not valid
           }

           // If data is valid, make a request to the eviction report endpoint
           const url = "/eviction/new-request";
           return await this.crs.onRequest<
               CrsScreeningProps["onEvictionReport"]["props"],
               CrsScreeningProps["onEvictionReport"]["result"]
           >(
               {
                   url,
                   data,
                   method: "post",
               },
               {
                   validateToken: true,
               },
           );
       };
}

This three methods (onFico, onCriminalReport, and onEvictionReport) handles different types of screening processes by validating the input data and making requests to specific endpoints using the onRequest method of the CrsBase class.

Readme

Keywords

Package Sidebar

Install

npm i crs-screening

Weekly Downloads

29

Version

1.1.6

License

ISC

Unpacked Size

42.7 kB

Total Files

89

Last publish

Collaborators

  • mauromiguel