-
Notifications
You must be signed in to change notification settings - Fork 2
ILawyerVerificationService
Note: Bar Code can be called Bar ID, Bar number, or Licence Number as well. They all refer to the same thing. The API used for web scraping has not been updated in awhile.
This service is responsible for injecting the dependency for the web scrapper to verify the Lawyer's bar code, email, and if they are validated to perform lawyer duties. It scrapes the WSBA. It contains one method to be implemented.
string BuildUrl(int num);
async Task<BarInfo> FetchBarInfoAsync(string url);
public async Task<bool> IsValidLawyerAsync(int barNumber, string email)
This method takes in the Lawyer's bar code as number and their email as string. Within this method it calls on two helper methods defined in the class, LawyerVerificationService, which implemented the ILaywerVerificationService interface. After webscraping in the helper functions, the method will return true if and only if email matches the inputted email, if their occupation on WSBA is set to lawyer, and if they are considered to be eligible to practice law on WSBA.
This method creates the correct URL to web scrape depending on the Layer's inputted bar code. Bar codes can range from being 4 to 6 digits, however, the URL needs a 12 digit bar code. The current code will insert (prepend) as many 0 as it needs to make the bar code 12 digits long. Returns the URL as a string.
This is the actual web scraping. It instantiates a new ScrapingBrowser (Downloaded from NuGet) and navigates to the given url. It looks at the CSS of the given page and instantiates a new BarInfo object to store the information it received from scraping the CSS. The method returns the said BarInfo obj.