Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

13966 Sample email verifier service + component #399

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

severinbeauvais
Copy link
Collaborator

@severinbeauvais severinbeauvais commented Oct 19, 2022

Issue #: bcgov/entity#13966

This PR contains prototype code for exploration/discussion. Feel free to check it out and run it locally to see what it looks like, but I don't expect we'll be merging this code as it is currently.

Description of changes:

  • added Million Verifier service
  • sample email verifier in Business Contact Info
  • added Verified Email component
  • sample email sub-component in Documents Delivery + simplified logic
  • misc cleanup
  • added/updated unit tests

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the bcrs-entities-create-ui license (Apache 2.0).

@severinbeauvais severinbeauvais self-assigned this Oct 19, 2022
@codecov
Copy link

codecov bot commented Oct 19, 2022

Codecov Report

Merging #399 (65a2ea7) into main (984b613) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

❗ Current head 65a2ea7 differs from pull request most recent head 6148f84. Consider uploading reports for the commit 6148f84 to get more accurate results

@@            Coverage Diff             @@
##             main     #399      +/-   ##
==========================================
- Coverage   83.26%   83.15%   -0.11%     
==========================================
  Files         174      175       +1     
  Lines        3238     3266      +28     
  Branches      508      524      +16     
==========================================
+ Hits         2696     2716      +20     
- Misses        541      549       +8     
  Partials        1        1              
Impacted Files Coverage Δ
src/App.vue 100.00% <ø> (ø)
src/components/Conversion/ConversionNOB.vue 100.00% <ø> (ø)
...ponents/common/PeopleAndRoles/CurrentDirectors.vue 100.00% <ø> (ø)
...nents/common/PeopleAndRoles/ListPeopleAndRoles.vue 100.00% <ø> (ø)
...ponents/common/YourCompany/BusinessContactInfo.vue 100.00% <ø> (ø)
src/components/common/YourCompany/YourCompany.vue 100.00% <ø> (ø)
...-interfaces/PeopleAndRoles/org-person-interface.ts 100.00% <ø> (ø)
src/mixins/filing-template-mixin.ts 43.63% <ø> (ø)
src/store/state/state-model.ts 100.00% <ø> (ø)
...omponents/common/YourCompany/BusinessStartDate.vue 100.00% <100.00%> (ø)
... and 7 more

@severinbeauvais severinbeauvais force-pushed the 13966 branch 6 times, most recently from 42a5b4d to 39cbc09 Compare October 22, 2022 01:25
valid = await EmailVerificationService.isValidEmail(contactInfo.email)
} catch {
valid = true // if error, assume email is valid
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't use .catch(err => ...) here because we can't mock it in the unit tests.

if (!result) throw new Error('Invalid API response')
// accept OK or UNKNOWN status
return (result === ResultCodes.OK || result === ResultCodes.UNKNOWN)
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't catch errors here -- let the caller decide what to do about exceptions.

@@ -0,0 +1,87 @@
<template>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we like the way this component works, it could easily be moved to bcrs-shared-components repo.

We'd have to pass in a reference to the email verification service (as we do for NAICS lookup).

*/
static async isValidEmail (
email: string,
apiUrl = 'https://api.millionverifier.com/api/v3',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need external config for this since there's only 1 endpoint (no dev or test).

To prevent burning up credits while testing, this method automatically returns "valid" if no API key is configured.

- try email verifier in Business Contact Info
- added Verified Email component
- try email sub-component in Documents Delivery + simplify logic
- misc cleanup
- added/updated unit tests
@severinbeauvais severinbeauvais changed the title 13966 Sample Million Verifier service 13966 Sample email verifier service + component Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants